Skip to content

Instantly share code, notes, and snippets.

@slobo
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slobo/e553eee6515d70c1c3c0 to your computer and use it in GitHub Desktop.
Save slobo/e553eee6515d70c1c3c0 to your computer and use it in GitHub Desktop.
Add Change-ID to git commits so they can be accepted for review by gerrit
#!/usr/bin/env perl
# run as `git filter-branch --msg-filter /path/to/add-missing-change-id.pl [REF_SPEC]`
# where REF_SPEC is optional or something like origin/master..HEAD
use strict;
use warnings;
my $has_change_id;
while (<>) {
$has_change_id ||= m{Change-Id:};
print;
}
print "\nChange-Id: I$ENV{GIT_COMMIT}\n"
unless $has_change_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment