Skip to content

Commit 96a65e0

Browse files
committed
Accept all
1 parent 87ec66b commit 96a65e0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

accept-all-prs.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,35 @@
22

33
all_pr_branches=("update-cypress-dependencies-and-containers" "update-gradle" "update-npm-dependencies")
44
remote_name="origin"
5-
65
cd ..
76
for item in *; do
87
if [[ -d "$item" ]]; then
98
cd "${item}" || exit
109
if [ -f Makefile ]; then
1110
if grep -q "^accept-prs:" Makefile; then
1211
echo "---*** Accept PR Makefile command found in $item ***---"
12+
if git ls-remote --exit-code --heads "$remote_name" "master"; then
13+
master_branch="master"
14+
fi
15+
if git ls-remote --exit-code --heads "$remote_name" "main"; then
16+
master_branch="main"
17+
fi
18+
if [ -n "${master_branch}" ]; then
19+
git checkout "${master_branch}"
20+
fi
1321
git pull
1422
git fetch -p
1523
for branch_name in "${all_pr_branches[@]}"; do
1624
if git ls-remote --exit-code --heads "$remote_name" "$branch_name"; then
1725
echo "Remote branch '$branch_name' exists on '$remote_name'."
1826
make accept-prs
27+
if [ -n "${master_branch}" ]; then
28+
git checkout "${branch_name}"
29+
git merge origin/"${master_branch}" --no-edit
30+
git push
31+
gh pr merge $(gh pr list --base "${master_branch}" --head "${branch_name}" --json number --jq '.[0].number' | xargs echo) --auto --merge
32+
git checkout "${master_branch}"
33+
fi
1934
fi
2035
done
2136
fi

0 commit comments

Comments
 (0)