[Development] Convenient script for contributors: git gpush

marius.storm-olsen at nokia.com marius.storm-olsen at nokia.com
Mon Apr 23 22:14:27 CEST 2012


Hi,

I've just pushed a convenience script to the qtrepotools repository, 
which makes it easier to push patch-sets with reviewers added.

If you ensure that you have <qt5>/qtrepotools/bin in your path, you can 
simply do
     git gpush +<reviewer1> +<reviewer2> =<CC user1> =<CC user2>

This pushes HEAD to the remote 'gerrit' to the remote branch which HEAD 
is tracking, and ensures that reviewer1 and reviewer2 are added as 
reviewers to every commit pushed.

The script handles aliases, and I've added a few IRC nicks to the alias 
list already. Contributions welcome for missing IRC aliases.
Note that you can add your own local aliases too simply by
     git config --global gpush.alias.<IRC nick> <Gerrit user>

Examples:
   (note that $TRB below means the tracking remote branch, most
    often 'master', if you are not working on some special branch.)

   git gpush
   # Pushes HEAD:refs/for/$TRB to 'gerrit', without any reviewers

   git gpush +mariuso =thiago
   # Pushes HEAD:refs/for/$TRB to 'gerrit', adding me as a reviewer
   # and sends Thiago a CC mail.

   git gpush :refs/for/buildsystem
   # Pushes HEAD:refs/for/buildsystem to 'gerrit', no reviewers

   git gpush myremote +mstormo
   # Pushes HEAD:refs/for/$TRB to 'myremote', adding me as a reviewer

   git gpush some-branch: +stormols
   # Pushes some-branch:refs/for/$TRB to 'gerrit', adding me as
   # a reviewer

   git gpush -n -v +mariusso +thiago
   # Does a verbose dry-run of the push, showing alias resolving
   # and the final 'git push' command used (comma-separated arguments)

which produces an output like:
  mariusso = stormols
  thiago = thiago-intel
+git,push,-n,-v,--receive-pack=git receive-pack --reviewer=stormols 
--reviewer=thiago-intel,gerrit,HEAD:refs/for/master
Pushing to ssh://stormols@codereview.qt-project.org:29418/qt/qtrepotools
To ssh://stormols@codereview.qt-project.org:29418/qt/qtrepotools
  * [new branch]      HEAD -> refs/for/master

------

Usage:
     git gpush [opts] [remote] [[sha1/ref-from]:[ref-to]] [+<reviewer>] 
[=<CC user>] [-- <push opts>]

     Pushes changes to Gerrit and adds reviewers and CC to the patch
     sets

Description:
     This script is used to push patch sets to Gerrit, and at the same
     time add reviewers and CCs to the patch sets pushed.

     You can use email addresses, Gerrit usernames or aliases for the
     name of the reviewers/CCs. Aliases are read from the
         .git-gpush-aliases
     located next to the script, then from the git config which may
     have aliases set either locally in the current repository,
     globally (in your ~/.gitconfig), or system-wide.

     You can and alias in your global git config like this:
         git config --global gpush.alias.<alias key> <alias value>
     and if you only want it local in the current repository, just drop
     the --global option.

     If no sha1 or ref-from is specified or configured, 'HEAD' is used.
     You may configure a ref-from like this
         git config gpush.ref-from <ref-from value>

     If no ref-to is specified or configured, the remote tracking
     branch for 'ref-from' is used as
         'refs/for/<remote tracking branch>'.
     You may configure a ref-to like this
         git config gpush.ref-to <ref-from value>

     If no remote is specified or configured, 'gerrit' is used. You may
     configure a remote like this:
         git config gpush.remote <remote name>

     If all the options above have been populated, the remainder
     options are passed on directly to the normal 'git push' command.
     If you want to avoid specifying all options first, any options
     specified after a '--' are also passed on directly to the
     underlying 'git push' command.

Options:
     -v, --verbose
         Shows the alias resolving, and final 'git push' command as a
         comma-separated list of arguments.

     -n, --dry-run
         Do everything except actually send the updates.
         Can be combined with --verbose to see the final command gpush
         will run.

     --aliases
         Reports all registered aliases.

Copyright:
     Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
     Contact: http://www.qt-project.org/

License:
     You may use this file under the terms of the 3-clause BSD license.

-- 
.marius



More information about the Development mailing list