aboutsummaryrefslogtreecommitdiff
path: root/util/scripts
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2023-08-08 17:54:05 +0800
committerFelix Held <felix-coreboot@felixheld.de>2023-08-10 12:40:54 +0000
commit42af60c166cd1e0a02f687f39e7da1fbf519820a (patch)
tree4c0d210a98d183bbfb93a5442f9b2279930f63cf /util/scripts
parente67513e353cd5fa5793e973cf0679a332d930e05 (diff)
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>
Diffstat (limited to 'util/scripts')
-rwxr-xr-xutil/scripts/update_submodules16
1 files changed, 8 insertions, 8 deletions
diff --git a/util/scripts/update_submodules b/util/scripts/update_submodules
index 4ca2925ff7..9f6c14f5b0 100755
--- a/util/scripts/update_submodules
+++ b/util/scripts/update_submodules
@@ -108,13 +108,13 @@ main() {
git fetch 2>/dev/null
fi
- if git branch -a | grep -q "origin/main"; then
- branch_name="origin/main"
- elif git branch -a | grep -q "origin/master"; then
- branch_name="origin/master"
- elif git branch -a | grep -q "origin/trunk"; then
- branch_name="origin/trunk"
- fi
+ declare -a branches=("origin/main" "origin/master" "origin/trunk")
+ for branch in "${branches[@]}"; do
+ if git branch -a | grep "${branch}" > /dev/null; then
+ branch_name="${branch}"
+ break
+ fi
+ done
updated_commit_id="$(git log --pretty='%h' -n 1 "${branch_name}" -- )"
updated_commit_description="$(git log --pretty='%ci - (%s)' -n 1 "${updated_commit_id}")"
@@ -138,7 +138,7 @@ main() {
cd "${TOP}" || exit 1
git add "${submodule}" > /dev/null 2>&1 || exit 1
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}:
$initial_commit_description