Reputation: 4970
I have pushed a draft to gerrit via
git push ssh://[email protected]:29418/myproject HEAD:refs/drafts/master
but I need to update it mid-review.
I read https://review.openstack.org/Documentation/intro-quick.html#_reworking_the_change but I think that advice not aimed at specifically at drafts.
So can I just git amend my commit, then push it using exact same command as earlier? And what will it look like to reviewers?
Upvotes: 0
Views: 6759
Reputation: 4970
Since this was a painful experience, here are my notes; hopefully they are helpful...
First problem: the branch had moved since I had pushed my draft. I had to merge changes but I couldn't push new work to refs/drafts/master
as they included a merge ...
! [remote rejected] HEAD -> refs/drafts/master (you are not allowed to upload merges)
So I tried advice from: https://wiki.opendaylight.org/view/GIT_Cheat_Sheet but got same error.
I learned you can normally use the rebase button on gerrit webpage but not in my case as I had a conflict. I had to rebase manually as described at https://gerrit-review.googlesource.com/Documentation/intro-user.html#rebase. Though that page refers to HEAD:refs/for/master
, I just did same except for HEAD:refs/drafts/master
and rebase worked.
Next, I had to checkout the rebased change (as a single checkout two patch sets) from gerrit in my local branch. I then made my new change, making sure to use the correct Change-Id:
in the commit message, and pushed again this failed too (message was something like (you are not allowed to multiple drafts with same Change-Id:)
.
To fix that I had to git squash
my commits ie. the downloaded change + my edits. I pushed this and all is fine. It appears in gerrit webpage as 3 patch sets.
Eventually I hit publish button and that pushed to, I presume, to HEAD:refs/for/master
. It is important to remember to update the combined commit message with the text you want to appear in the git history (as no way easy to edit after publishing)
Also see https://gerrit-review.googlesource.com/Documentation/intro-user.html#submit
Upvotes: 0
Reputation: 608
git push ssh://[email protected]:29418/myproject HEAD:refs/drafts/master
Yes, command mentioned above will apply a new patchset to the draft.
The follow-up question is a bit fuzzy. The use case of draft is that you want to upload your change but not make it publicly accessible, e.g. because you don't want people to start reviewing it yet. Depending on the local policy, reviewers might get explicitly added or will pick up open changes and add themselves as reviewers.But the draft feature prevents this.If you do want someone to review your draft change, you can explicitly add him/her as a reviewer.
Refer here for more details
Upvotes: 2