2

A colleague sent me a Gerrrit code review "draft" (I suppose via "refs/drafts/master" instead of "refs/for/master") and then left on holiday. Without downloading the patch and submitting it myself, how can I promote his draft to a full regular code-review so I can approve it & submit it for merging?

I think this is a similar question, but it's for git-review, not Gerrit. Also I'm interested in doing it from the Gerrit web GUI if at all possible. And I don't see a "Publish" button on my Gerrit web GUI for that draft. (And currently it doesn't say anything about merge conflicts, as long as I hurry....)

If I click on the "Patch Sets" link in the top right of the GUI, this is what I see: What I see when I click on "Patch Sets"

In the top left it says "Change 58358 - Draft", and in the middle of the window it shows this: enter image description here

phonetagger
  • 7,701
  • 3
  • 31
  • 55

3 Answers3

3

Only the change owner can publish a draft patch set. Using the UI's cherry-pick option as described in other answers won't work because the cherry-pick implementation preserves the draft status on the new change or patch set.

As far as I know the only way to force the change into NEW state is to manually download the commit and push a new patch set using refs/for/master instead of refs/drafts/master.

Note that if you're not rebasing the change onto a new parent at the same time, you might need to slightly edit the commit message to make gerrit accept it. Otherwise it'll reject with no new changes.

David Pursehouse
  • 933
  • 6
  • 14
0

If your colleague add you as reviewer, you can. You can cherry-pick this commit.

Click on download link at the right-top corner, and there are aliases for commands above. But as you updated your question, you don't want to check out and manually push or cherry pick to master branch. You can use cherry-pick\merge button on ui, if you are confident in this mr, and it should be on master branch. Also you can publish this commit for other reviewers.

enter image description here

p.s. updated (you can cherry-pick, merge, publish via UI)

lord_hokage
  • 189
  • 7
  • I updated my question with what I see in the top-right corner when I click on "Patch Sets". I don't see the aliases you mention....? – phonetagger Aug 22 '18 at 19:29
  • I'm sorry, give me a second, I'm writting new changes in my answer) – lord_hokage Aug 22 '18 at 19:33
  • I clicked "Cherry Pick" and it asks me what branch, so I try to type "refs/for/master" but it doesn't like that (says "Code Review - Error, Branch refs/for/master does not exist"). If I just type "master", it accepts that and says I now have "Uploaded patch set 3", but in the top right it still says "Change 58358 - Draft", and it doesn't start a test build. Any more ideas? – phonetagger Aug 22 '18 at 19:43
  • Strange, do you see 'publish button' at the top over Owner, Reviewers titles, and do you have grants for +2? – lord_hokage Aug 22 '18 at 19:47
  • I already +2'ed it. But I don't see a "Publish" button. The only instance of "Publish" is in the History section, in text that says "Patch Set 2: Published edit on patch set 1". – phonetagger Aug 22 '18 at 19:50
  • What submit type do you use ? You can check it 'Projects'->'General' – lord_hokage Aug 22 '18 at 19:57
  • It says "Submit Type: Cherry Pick" – phonetagger Aug 22 '18 at 20:12
  • try to enter in cherry-pick input, 'master:refs/for/master' without quotes – lord_hokage Aug 22 '18 at 20:26
  • Oh I was so hoping that would work, but: "Branch master:refs/for/master does not exist." – phonetagger Aug 22 '18 at 20:52
  • Maybe it's helped refs/heads/master:refs/for/master, but I'm not sure.I know way to do this using console, but it isn't fitted for you. Also try follows: 1) Change your branch strategy to Merge if nessecary and submit this commit, 2) Have a look at your gerrit.config, in the branch section. – lord_hokage Aug 22 '18 at 21:05
  • Open download at the top-right corner, copy checkout link, open git bash, paste it. Then you can 'git pull --rebase orign master', and 'git review master'. Then +2 by yourself, +1 from jenkins (if you use it) and then cherry-pick to master. (Because cherry pick is your gerrit strategy) – lord_hokage Aug 22 '18 at 21:11
  • Well, thank you very much for your help, but that didn't work either. `$ git review master` results in `git: 'review' is not a git command. See 'git --help'.` – phonetagger Aug 23 '18 at 00:31
  • If you feel that there's no value to this question & its answers, feel free to delete your answer. If both of the answers are deleted, I can then delete the question. – phonetagger Aug 23 '18 at 16:11
0

Do the following procedure:

1) Go to the draft change page

2) Click on Cherry Pick button

3) Write "master" in the Cherry Pick to Branch field

4) Adjust the Cherry Pick Commit Message if needed

5) Click on Cherry Pick Change button

It'll be created a NEW CHANGE cherry-picked from the draft change. Go to the new change page and follow the regular Gerrit process (review, approve, submit). The original draft change can be abandoned or deleted.

  • Following those instructions the best I can (I'm not totally sure what the "draft change page" or "new change page" is), it added a history line that says "Uploaded patch set 4.", but that's all. It didn't start a build, it still says that I've +2'ed it, and it won't give me a submit button. – phonetagger Aug 23 '18 at 02:32
  • What's the Gerrit version? Have you clicked on the "Cherry Pick" button? You haven't clicked on "Rebase" button, have you? – Marcelo Ávila de Oliveira Aug 23 '18 at 10:18
  • So my people here tell me I can't do these things because I'm not the owner of the draft. In any case, this has turned out to be way too much trouble, and I'm handling it differently. Thank you for your help. – phonetagger Aug 23 '18 at 12:23
  • If you weren't able to click on the "Cherry Pick" button you shouldn't have said that you had clicked on it. – Marcelo Ávila de Oliveira Aug 23 '18 at 12:54
  • Well, I can click on the "Cherry Pick" button. It then asks me what branch, and I typed "master", then clicked on the "Cherry Pick Change" button, then it adds a new patch set to the history, but it never converts the submission from "draft" to "Needs Code-Review", and never starts a build of it on Jenkins. It just keeps sitting there saying "Uploaded patch set X.". – phonetagger Aug 23 '18 at 16:08
  • Apparently we're using Gerrit Code Review version 2.11.3, if that's important. But by this point we've taken care of the problem by just submitting a new code review from a manual merge of the changes. Again, thank you for trying to help. I'm sorry it didn't work for me. – phonetagger Aug 23 '18 at 16:10
  • If you feel that there's no value to this question & its answers, feel free to delete your answer. If both of the answers are deleted, I can then delete the question. – phonetagger Aug 23 '18 at 16:11
  • The "Cherry Pick" button creates a NEW change. It doesn't create a new patchset in the change where you have clicked the button. Click on "My > Changes", you must see the changes you've created when you clicked on "Cherry Pick". – Marcelo Ávila de Oliveira Aug 23 '18 at 17:15
  • @MarceloÁviladeOliveira using the UI to cherry-pick a change to the same destination branch is effectively the same as doing a rebase. IIRC the reason it doesn't publish the change is because the cherry-pick action preserves the draft status. – David Pursehouse Aug 24 '18 at 06:48
  • :-o I think this's totally unexpected behaviour. Thanks David. – Marcelo Ávila de Oliveira Aug 24 '18 at 11:19