Skip to content

Instantly share code, notes, and snippets.

@jrbalsano
Last active August 29, 2015 13:56
Show Gist options
  • Save jrbalsano/9053544 to your computer and use it in GitHub Desktop.
Save jrbalsano/9053544 to your computer and use it in GitHub Desktop.
Sh script to prepend bug description and append signed-off-by to a series of commits by a single author.
# Written by Jonathan Balsano <jrbalsano@gmail.com>
# Example usage: ./commit-wrapper.sh "Jonathan Balsano" "jrbalsano@gmail.com" master topic_branch "Bug 999 - Unwrapped Commits"
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] || [ -z "$5" ]; then
echo "usage: ./commit-wrapper.sh <author> <cla_email> <excl_oldest> <newest> <prepend_bug>"
exit 1
fi
export AUTHOR="$1"
export CLA_EMAIL="$2"
export EXCL_OLDEST="$3"
export NEWEST="$4"
export BUG="$5"
git filter-branch -f --msg-filter '
if [ "$GIT_AUTHOR_NAME" = "$AUTHOR" ]; then
echo "$BUG" && echo && cat && echo && echo "Signed-off-by: $AUTHOR <$CLA_EMAIL>"
else
cat
fi' \
$EXCL_OLDEST...$NEWEST
@paulweb515
Copy link

A good first attempt. But that will put the same Signed-off-by on each commit, but you need a different signed-off-by depending on who the read author for the commit is.

@jrbalsano
Copy link
Author

@paulweb515 the --author lets you filter by author, so each one of us would have to run the script for our own commits, or I could run them for each author. When I tested it earlier today it only touched the 5 commits I wrote, leaving everyone else's in tact. I figured this way it was more useful as a generic script in case you ever run into this problem with committers again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment