Showing posts with label Gerrit. Show all posts
Showing posts with label Gerrit. Show all posts

Thursday, December 3, 2015

Changing the author name for git/gerrit commit

So this was my second time having some adventure with gerrit for OpenDaylight (also read about the first time, if you are curious). This time, I pulled the remote changes and tried to commit my new changes by adding my changes. This created a merge as the commit from the remote repository and my local commits merged in a single pull request, and hence my commit failed with the below message.

$ git review

You are about to submit multiple commits. This is expected if you are
submitting a commit that is dependent on one or more in-review
commits. Otherwise you should consider squashing your changes into one
commit before submitting.

The outstanding commits are:

fe17631 (HEAD, master) Fix bug 4535/4541
475fae6 Use odlparent-lite as artifacts parent

Do you really want to submit the above commits?
Type 'yes' to confirm, other to cancel: yes
remote: Processing changes: refs: 1, done   
To ssh://pradeeban@git.opendaylight.org:29418/messaging4transport.git
 ! [remote rejected] HEAD -> refs/publish/master/bug/4535 (you are not allowed to upload merges)
error: failed to push some refs to 'ssh://pradeeban@git.opendaylight.org:29418/messaging4transport.git'

Now,
$ git statusOn branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean
 
So it indeed shows as 2 commits - one mine, and the one pulled from the remote repository.

I had to rebase to the master fix this.
$  git rebase origin/master

However, this left my commit attributed to the author of the previous commit in the commit log, when I try to git review.

I had to amend the author to finally fix the commit message successfully git review following that.
$ git commit --amend --author "FirstName LastName "

Friday, October 16, 2015

Git Rebase for OpenDaylight/Gerrit

I hate merge conflicts, and luckily so far I did not have to do a git rebase for gerrit in OpenDaylight. However, this time I had to. So here are the steps I followed.

https://git.opendaylight.org/gerrit/#/c/28471/1

pradeeban@llovizna:~/OpenDaylight/distribution$ git-review -d  28471
Creating a git remote called "gerrit" that maps to:
    ssh://pradeeban@git.opendaylight.org:29418/integration/distribution.git
Downloading refs/changes/71/28471/1 from gerrit
Switched to branch "review/pradeeban_kathiravelu/28471"
pradeeban@llovizna:~/OpenDaylight/distribution$


pradeeban@llovizna:~/OpenDaylight/distribution$ git rebase origin/master
First, rewinding head to replay your work on top of it...
Applying: Add messaging4transport to integration
Using index info to reconstruct a base tree...
M    features/index/pom.xml
M    features/index/src/main/resources/features.xml
M    features/test/src/main/resources/features.xml
M    pom.xml
Falling back to patching base and 3-way merge...
Auto-merging pom.xml
CONFLICT (content): Merge conflict in pom.xml
Auto-merging features/test/src/main/resources/features.xml
CONFLICT (content): Merge conflict in features/test/src/main/resources/features.xml
Auto-merging features/index/src/main/resources/features.xml
CONFLICT (content): Merge conflict in features/index/src/main/resources/features.xml
Auto-merging features/index/pom.xml
CONFLICT (content): Merge conflict in features/index/pom.xml
Failed to merge in the changes.
Patch failed at 0001 Add messaging4transport to integration
The copy of the patch that failed is found in:
   /home/pradeeban/OpenDaylight/distribution/.git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".




pradeeban@llovizna:~/OpenDaylight/distribution$ git status
rebase in progress; onto b524a56
You are currently rebasing branch 'review/pradeeban_kathiravelu/28471' on 'b524a56'.
  (fix conflicts and then run "git rebase --continue")
  (use "git rebase --skip" to skip this patch)
  (use "git rebase --abort" to check out the original branch)

Unmerged paths:
  (use "git reset HEAD ..." to unstage)
  (use "git add ..." to mark resolution)

    both modified:      features/index/pom.xml
    both modified:      features/index/src/main/resources/features.xml
    both modified:      features/test/src/main/resources/features.xml
    both modified:      pom.xml

no changes added to commit (use "git add" and/or "git commit -a")



Modify the offending files, the files that are marked as 'both modified'.

Add the modified files.
pradeeban@llovizna:~/OpenDaylight/distribution$ git add features/index/pom.xml features/index/src/main/resources/features.xml features/test/src/main/resources/features.xml pom.xml

pradeeban@llovizna:~/OpenDaylight/distribution$ git rebase --continue
Applying: Add messaging4transport to integration


pradeeban@llovizna:~/OpenDaylight/distribution$ git status
On branch review/pradeeban_kathiravelu/28471
nothing to commit, working directory clean

To amend or modify the commit message,
pradeeban@llovizna:~/OpenDaylight/distribution$ git commit --amend -s

Finally submitting the changes to gerrit,
pradeeban@llovizna:~/OpenDaylight/distribution$ git review
Your change was committed before the commit hook was installed.
Amending the commit to add a gerrit change id.
remote: Processing changes: updated: 1, refs: 1, done   
remote:
remote: Updated Changes:
remote:   https://git.opendaylight.org/gerrit/28471 Adding messaging4transport features.
remote:
To ssh://pradeeban@git.opendaylight.org:29418/integration/distribution.git
 * [new branch]      HEAD -> refs/publish/master/28471