blob: 11547a982691fa353fb9c53df45808ba75a9e28d [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
Brad Bishopc342db32019-05-15 21:57:59 -04002#
3# SPDX-License-Identifier: GPL-2.0-only
4#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005# Hook to add source component/revision info to commit message
6# Parameter:
7# $1 patch-file
8# $2 revision
9# $3 reponame
10
11patchfile=$1
12rev=$2
13reponame=$3
14
15sed -i -e "0,/^Subject:/s#^Subject: \[PATCH\] \($reponame: \)*\(.*\)#Subject: \[PATCH\] $reponame: \2#" $patchfile
16if 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
19else
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
23fi