From a5c1c85ba61f7f57420897e210ab0cdb7a6a1446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Esperancinha?= Date: Wed, 27 Nov 2024 09:05:36 +0100 Subject: [PATCH] accepts for repo --- accept-all-repo-prs.sh | 49 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/accept-all-repo-prs.sh b/accept-all-repo-prs.sh index d281263..1e5d1ed 100755 --- a/accept-all-repo-prs.sh +++ b/accept-all-repo-prs.sh @@ -1,34 +1,25 @@ #!/usr/bin/env bash -all_pr_branches=("update-cypress-dependencies-and-containers" "update-gradle" "update-npm-dependencies") remote_name="origin" -if [ -f Makefile ]; then - if grep -q "^accept-prs:" Makefile; then - echo "---*** Accept PR Makefile command found in $item ***---" - if git ls-remote --exit-code --heads "$remote_name" "master"; then - master_branch="master" - fi - if git ls-remote --exit-code --heads "$remote_name" "main"; then - master_branch="main" - fi - if [ -n "${master_branch}" ]; then - git checkout "${master_branch}" - fi +if git ls-remote --exit-code --heads "$remote_name" "master"; then + master_branch="master" +fi +if git ls-remote --exit-code --heads "$remote_name" "main"; then + master_branch="main" +fi +if [ -n "${master_branch}" ]; then + git checkout "${master_branch}" +fi +git pull +git fetch -p +for branch_name in $(git branch -r | grep -v '\->' | sed 's/origin\///' | grep -v 'master' | grep -v 'main' | grep -v 'migration-to-kotlin' | grep -v '1.0.0-eol-continuous-release-branch-recovered' | grep -v 'migrate-to-kotlin'); do + echo "Processing branch: $branch_name" + if [ -n "${master_branch}" ]; then + git checkout "${branch_name}" git pull - git fetch -p - make accept-prs - for branch_name in "${all_pr_branches[@]}"; do - if git ls-remote --exit-code --heads "$remote_name" "$branch_name"; then - echo "Remote branch '$branch_name' exists on '$remote_name'." - if [ -n "${master_branch}" ]; then - git checkout "${branch_name}" - git pull - git merge origin/"${master_branch}" --no-edit - git push - gh pr merge $(gh pr list --base "${master_branch}" --head "${branch_name}" --json number --jq '.[0].number' | xargs echo) --auto --merge - git checkout "${master_branch}" - fi - fi - done + git merge origin/"${master_branch}" --no-edit + git push + gh pr merge $(gh pr list --base "${master_branch}" --head "${branch_name}" --json number --jq '.[0].number' | xargs echo) --auto --merge + git checkout "${master_branch}" fi -fi +done