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