Page MenuHomePhabricator

Micro-task: Amend existing commit in Gerrit
Closed, ResolvedPublic

Description

In Github, an unit of work is pull request. When you start work on a bug or a feature, you create a new git branch and several commits in a branch. When you're happy with the work, you merge the branch to the master branch.

In Gerrit, an unit of work is a commit. Similar to Github, you create a new git branch and a commit in it. When you have some code, you should push it to Gerrit. (That is covered in task T248232.) If you want to make changes, you don't create new commits in the branch. Instead you amend the existing commit. You can amend the commit many times. When you're happy with the work, you merge the commit to the master branch.

This task will introduce you to the Gerrit workflow of amending a commit. I have created a commit and pushed it to Gerrit: 585759.

Your task is to fetch the patch to your machine, add your Phabricator username to tests/selenium/README.md, amend the commit and push it back to Gerrit.

Go to the mediawiki/core folder in your terminal. (You have cloned the repository in T248232.)

cd mediawiki/core

Fetch the patch.

git review -d 585759

Add your Phabricator username to tests/selenium/README.md. Use your favorite text editor.

nvim tests/selenium/README.md

Amend the commit. Do not change the commit message.

git add tests/selenium/README.md
git commit --amend

Push the amended commit back to Gerrit.

git review -R

For more information see Gerrit/Tutorial: Amending a change (your own or someone else's).

Students:

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 3 2020, 11:23 AM

Thanks @Aklapper, I was just looking for that. 😄

zeljkofilipin updated the task description. (Show Details)Apr 3 2020, 2:18 PM

Change 585759 had a related patch set uploaded (by Zfilipin; owner: Zfilipin):
[mediawiki/core@master] WIP Micro-task: Amend existing commit in Gerrit

https://gerrit.wikimedia.org/r/585759

zeljkofilipin updated the task description. (Show Details)Apr 3 2020, 2:35 PM
zeljkofilipin updated the task description. (Show Details)
zeljkofilipin updated the task description. (Show Details)Apr 3 2020, 2:58 PM
Soham added a subscriber: Soham.EditedApr 3 2020, 4:52 PM

Hey @zeljkofilipin , can we link multiple tasks under one commit using the

Bug: <task number>

In T249323#6027066, @AlQaholic007 wrote:

Hey @zeljkofilipin , can we link multiple tasks under one commit using the

Bug: <task number>

Yes, just add multiple lines that start with Bug: . Why do you need it for this task?

zeljkofilipin updated the task description. (Show Details)Apr 3 2020, 5:48 PM
zeljkofilipin updated the task description. (Show Details)Apr 3 2020, 5:59 PM
zeljkofilipin updated the task description. (Show Details)Apr 3 2020, 6:03 PM
Soham added a comment.Apr 3 2020, 7:33 PM
In T249323#6027066, @AlQaholic007 wrote:

Hey @zeljkofilipin , can we link multiple tasks under one commit using the

Bug: <task number>

Yes, just add multiple lines that start with Bug: . Why do you need it for this task?

Not for this task. Was asking in general if it were possible to link a commit to multiple tasks

Krinkle added a subscriber: Krinkle.Apr 3 2020, 7:34 PM

@zeljkofilipin Only +2ers are able to modify other people's patches. I assume the intended objective is to learn to amend a patch instead of making multiple commits in a chain (like is the convention on GitHub, with a sqaushed merge afterwards).

Maybe part of this should be to first create your own patch, push to gerrit, and then amend that patch set, and push again (PS2).

Soham updated the task description. (Show Details)Apr 3 2020, 7:35 PM
Soham added a comment.Apr 3 2020, 7:37 PM

@zeljkofilipin Only +2ers are able to modify other people's patches. I assume the intended objective is to learn to amend a patch instead of making multiple commits in a chain (like is the convention on GitHub, with a sqaushed merge afterwards).

Maybe part of this should be to first create your own patch, push to gerrit, and then amend that patch set, and push again (PS2).

I faced the same issue. I added a sub-task to this task taking reference from T230916: Cannot amend Gerrit changeset in MediaWiki Core repo (due to not being in addPatchSet?). Turns out there is some permission issue @Krinkle

Paladox added a subscriber: Paladox.Apr 4 2020, 5:23 AM

@zeljkofilipin Only +2ers are able to modify other people's patches. I assume the intended objective is to learn to amend a patch instead of making multiple commits in a chain (like is the convention on GitHub, with a sqaushed merge afterwards).

Maybe part of this should be to first create your own patch, push to gerrit, and then amend that patch set, and push again (PS2).

That’s not correct, you have to be in the trusted user group to add to someone else change.

Change 585865 had a related patch set uploaded (by Ashuro07; owner: Zfilipin):
[mediawiki/core@master] T249323

https://gerrit.wikimedia.org/r/585865

zeljkofilipin updated the task description. (Show Details)Apr 4 2020, 1:37 PM
This comment was removed by Ashuro07.
zeljkofilipin updated the task description. (Show Details)Apr 4 2020, 2:24 PM
zeljkofilipin updated the task description. (Show Details)Apr 4 2020, 3:01 PM
zeljkofilipin closed this task as Resolved.Apr 4 2020, 4:18 PM
zeljkofilipin claimed this task.
zeljkofilipin updated the task description. (Show Details)

Change 585759 abandoned by Zfilipin:
WIP Micro-task: Amend existing commit in Gerrit

Reason:
Than you everybody!

https://gerrit.wikimedia.org/r/585759