Skip to content

Instantly share code, notes, and snippets.

@schnell18
Created November 25, 2013 06:03
Show Gist options
  • Save schnell18/7636993 to your computer and use it in GitHub Desktop.
Save schnell18/7636993 to your computer and use it in GitHub Desktop.
Format the commit message to follow "ticket: short comment" pattern.
git filter-branch --msg-filter 'perl -e '\''while(<>) {print join(q/: /, split(/\s*:\s*/, $_, 2))}'\''' -- --all
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
@schnell18
Copy link
Author

The ''' (single quote, backslash, two consecutive single quotes) is the bash way to indicate a single quote embedded in another single quote. This is necessary as both the --msg-filter and -e of Perl expect the command be single quoted.

@schnell18
Copy link
Author

Here is test case for the commit message command:

cat << EOF | perl -e 'while(<>) {print join(q/: /, split(/\s*:\s*/, $_, 2))}'
UCA-1022:refine the warning message for parameter file
UCA-1022:mark war for the line ignored in parameter file
UCA-1022:ignore the lines not start with -- in parameter file
UCA-1022:refine the code
UCA-1022:refine the code
UCA-1022:refine the merge option function
UCA-1022:parameters can be reached from command line or parameter_file
UCA-1136 : remove unused code
UCA-1136: Change label font to Arial and size to 10
UCA-1136: define label format to print 'Arial' font
UCA-1136: define label format to print 'Arial' font
UCA-1136: set data font size 11 if font is 'Calibri'
UCA-1136: set data font size 11 if font is 'Calibri'
UCA-1136: Lost comma
UCA-1136: Lost comma : sdfa
UCA-1136: rewrite log detail report with excel::writer::xlsx
UCA-1136: remove unused code
UCA-1136:   set dateIn and dateOut field as date type
UCA-1136  : rewrite log detail sheet with Excel::Writer::XLSX
EOF

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