Browse Source

Merge pull request #6018 from simonpasquier/delete-remote-makefile-common-branch

scripts/sync_makefiles.sh: delete merged branch
post-processing
Julien Pivotto 4 years ago committed by GitHub
parent
commit
894354a03c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      scripts/sync_repo_files.sh

13
scripts/sync_repo_files.sh

@ -39,6 +39,9 @@ fetch_repos() {
push_branch() { push_branch() {
# stdout and stderr are redirected to /dev/null otherwise git-push could leak # stdout and stderr are redirected to /dev/null otherwise git-push could leak
# the token in the logs. # the token in the logs.
# Delete the remote branch in case it was merged but not deleted.
git push --quiet "https://${GITHUB_TOKEN}:@github.com/${1}" \
":${branch}" 1>/dev/null 2>&1
git push --quiet \ git push --quiet \
"https://${GITHUB_TOKEN}:@github.com/${1}" \ "https://${GITHUB_TOKEN}:@github.com/${1}" \
--set-upstream "${branch}" 1>/dev/null 2>&1 --set-upstream "${branch}" 1>/dev/null 2>&1
@ -121,6 +124,16 @@ for org in ${orgs}; do
# at most but it should be enough for us as there are less than 40 repositories # at most but it should be enough for us as there are less than 40 repositories
# currently. # currently.
fetch_repos "${org}" | while read -r repo; do fetch_repos "${org}" | while read -r repo; do
# Check if a PR is already opened for the branch.
prLink=$(curl --show-error --silent \
-u "${GITHUB_USER}:${GITHUB_TOKEN}" \
"https://api.github.com/repos/${org}/${repo}/pulls?head=${repo}:${branch}" | jq '.[0].url')
if [[ "${prLink}" != "null" ]]; then
echo "Pull request already opened for branch '${branch}': ${prLink}"
echo "Either close it or merge it before running this script again!"
continue
fi
if ! process_repo "${org}/${repo}"; then if ! process_repo "${org}/${repo}"; then
echo "Failed to process '${org}/${repo}'" echo "Failed to process '${org}/${repo}'"
exit 1 exit 1

Loading…
Cancel
Save