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