aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEmma Foley <efoley@redhat.com>2021-12-09 15:32:10 +0000
committerEmma Foley <efoley@redhat.com>2021-12-17 09:42:21 +0000
commitd6865dee56b4648727943b9528ea86ddc4485310 (patch)
tree6cd8a5727b7030a3dbcf547de369e9304c0d8deb /src
parente21e1e13a29189b024801cb344093688f772890a (diff)
[src/collectd] Update collectd_apply_pull_requests.sh to check out PR
Update collectd_apply_pull_request.sh to check out PR when only one PR is given. A comma-separated list of PR_IDs will still result in rebasing on top of the checked-out branch. Signed-off-by: Emma Foley <efoley@redhat.com> Change-Id: I22012c950be80dce26a51fcf02b13469f27e1ca8
Diffstat (limited to 'src')
-rwxr-xr-xsrc/collectd/collectd_apply_pull_request.sh18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/collectd/collectd_apply_pull_request.sh b/src/collectd/collectd_apply_pull_request.sh
index 35af2981..403d78dd 100755
--- a/src/collectd/collectd_apply_pull_request.sh
+++ b/src/collectd/collectd_apply_pull_request.sh
@@ -35,8 +35,16 @@ IFS=', ' read -a PULL_REQUESTS <<< "$COLLECTD_PULL_REQUESTS"
git config user.email "barometer-experimental@container"
git config user.name "BarometerExperimental"
-for PR_ID in "${PULL_REQUESTS[@]}"
-do
- echo "Applying pull request $PR_ID"
- git pull --rebase origin pull/$PR_ID/head
-done
+# If there's a single PR listed, just check it out
+if [ "${#PULL_REQUESTS[@]}" -eq "1" ];
+then
+ echo "Checking out pull request $COLLECTD_PULL_REQUESTS"
+ git fetch origin pull/$COLLECTD_PULL_REQUESTS/head && git checkout FETCH_HEAD
+else
+# if there are multiple PRs, rebase them on top of the checked out branch
+ for PR_ID in "${PULL_REQUESTS[@]}"
+ do
+ echo "Applying pull request $PR_ID"
+ git pull --rebase origin pull/$PR_ID/head
+ done
+fi