util/scripts/update_submodules: Fix branch name greping
The command "git branch -a | grep -q ${branch}" may not exit with 0 when pipefail is set. "grep -q" exits immediately with exit code 0 as soon as a match is found. However, at that point "git branch -a" may be still writing to the pipe, leading to SIGPIPE. When pipefail is set, PIPESTATUS 141 will be returned. Fix the problem by not using "grep -q". Also fix the branch name in the generated commit subject. Change-Id: Ic07efb5e2a4f3b7bbc6e76da9e026771bc685bdb Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/77085 Reviewed-by: Yidi Lin <yidilin@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
e67513e353
commit
42af60c166
|
@ -108,13 +108,13 @@ main() {
|
||||||
git fetch 2>/dev/null
|
git fetch 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if git branch -a | grep -q "origin/main"; then
|
declare -a branches=("origin/main" "origin/master" "origin/trunk")
|
||||||
branch_name="origin/main"
|
for branch in "${branches[@]}"; do
|
||||||
elif git branch -a | grep -q "origin/master"; then
|
if git branch -a | grep "${branch}" > /dev/null; then
|
||||||
branch_name="origin/master"
|
branch_name="${branch}"
|
||||||
elif git branch -a | grep -q "origin/trunk"; then
|
break
|
||||||
branch_name="origin/trunk"
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
updated_commit_id="$(git log --pretty='%h' -n 1 "${branch_name}" -- )"
|
updated_commit_id="$(git log --pretty='%h' -n 1 "${branch_name}" -- )"
|
||||||
updated_commit_description="$(git log --pretty='%ci - (%s)' -n 1 "${updated_commit_id}")"
|
updated_commit_description="$(git log --pretty='%ci - (%s)' -n 1 "${updated_commit_id}")"
|
||||||
|
@ -138,7 +138,7 @@ main() {
|
||||||
cd "${TOP}" || exit 1
|
cd "${TOP}" || exit 1
|
||||||
git add "${submodule}" > /dev/null 2>&1 || exit 1
|
git add "${submodule}" > /dev/null 2>&1 || exit 1
|
||||||
git commit -s -F- > /dev/null 2>&1 <<-EOF
|
git commit -s -F- > /dev/null 2>&1 <<-EOF
|
||||||
Update ${submodule##*/} submodule to upstream master
|
Update ${submodule##*/} submodule to upstream ${branch##*/}
|
||||||
|
|
||||||
Updating from commit id ${initial_commit_id}:
|
Updating from commit id ${initial_commit_id}:
|
||||||
$initial_commit_description
|
$initial_commit_description
|
||||||
|
|
Loading…
Reference in New Issue