This patch series makes improvements to StGit to make interoperability with
Gerrit more pleasant, as requested in Bug #18806, by running the commit-msg
hook on commit message changes.
Gerrit is a web-based code-review tool for Git used by many major Open Source
projects, including Android, Chromium, LibreOffice, MediaWiki, and OpenStack.
Gerrit and StGit are, in principle, very complementary tools, but at the
moment using them together is painful. The reason is that Gerrit uses a Git
commit-msg hook to insert a unique ID in each commit message. This enables
Gerrit to detect when a patch submission is an update to a previous review
request and not an entirely new review request. The ID takes the form of a
line beginning with "Change-Id: " followed by an SHA-like hash prefixed with
an 'I', and the commit-msg hook script supplied by Gerrit inserts it at the
beginning of the block of lines following the form of Signed-off-by.
It is currently possible to use StGit with Gerrit by, for example, doing
"stg commit; git commit --amend; stg uncommit" to ensure the commit-msg
hook gets run and the unique ID added. However, this is obviously less than
ideal even for a single patch and is extremely impractical for a whole
queue of patches (easy management of which is obviously the point of using
StGit).
This patch series makes the following changes to StGit:
- Ensure that the presence of the Change-Id line (or other non-standard
Signed-off-by lookalikes) does not adversely affect the placement of any
new signatures added by "stg edit --sign" or related commands.
- Adds utility functions for running hook scripts with the correct
environment variables set.
- Run the commit-msg hook when creating a patch with "stg new", after
editing a patch with "stg refresh -e" or "stg edit" (including
non-interactive edits, e.g. with "stg edit --sign"), and when squashing
patches with "stg squash".
While Gerrit interoperability was my main aim here (and has been
much-requested on this list by the looks of it), this should work correctly
for any commit-msg hook script. In particular, the hook is always run from
the root directory of the working copy, the same environment variables that
Git sets before running a hook are provided, and a failed status code from
the hook will abort the command. It should also be possible to build on the
utility functions to support at least some other types of hooks in the
future.
cheers,
Zane.
---
Zane Bitter (4):
Handle arbitrary annotations when inserting sign-off
Add a utility function for getting a hook
Add a utility function for running a hook on a string
Run commit-msg hook on new, edit, refresh -e, squash
stgit/argparse.py | 7 ++++++
stgit/commands/common.py | 19 +++++++++++++++++
stgit/commands/edit.py | 18 +++++++++++++----
stgit/commands/new.py | 6 +++++-
stgit/commands/refresh.py | 4 ++++
stgit/commands/squash.py | 20 ++++++++++++------
stgit/lib/git.py | 23 ++++++++++++---------
stgit/utils.py | 49 +++++++++++++++++++++++++++++++++++++++++----
8 files changed, 120 insertions(+), 26 deletions(-)
_______________________________________________
stgit-users mailing list
[email protected]
https://mail.gna.org/listinfo/stgit-users