Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | #!/bin/sh |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 2 | # |
| 3 | # SPDX-License-Identifier: GPL-2.0-only |
| 4 | # |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | # Hook to add source component/revision info to commit message |
| 6 | # Parameter: |
| 7 | # $1 patch-file |
| 8 | # $2 revision |
| 9 | # $3 reponame |
| 10 | |
| 11 | patchfile=$1 |
| 12 | rev=$2 |
| 13 | reponame=$3 |
| 14 | |
| 15 | sed -i -e "0,/^Subject:/s#^Subject: \[PATCH\] \($reponame: \)*\(.*\)#Subject: \[PATCH\] $reponame: \2#" $patchfile |
| 16 | if grep -q '^Signed-off-by:' $patchfile; then |
| 17 | # Insert before Signed-off-by. |
| 18 | sed -i -e "0,/^Signed-off-by:/s#\(^Signed-off-by:.*\)#\(From $reponame rev: $rev\)\n\n\1#" $patchfile |
| 19 | else |
| 20 | # Insert before final --- separator, with extra blank lines removed. |
| 21 | perl -e "\$_ = join('', <>); s/^(.*\S[ \t]*)(\n|\n\s*\n)---\n/\$1\n\nFrom $reponame rev: $rev\n---\n/s; print;" $patchfile >$patchfile.tmp |
| 22 | mv $patchfile.tmp $patchfile |
| 23 | fi |