mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
scripts/sync_makefiles.sh: delete merged branch
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
a5beb627ff
commit
ab5ea8d5e1
|
@ -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
|
||||||
|
@ -119,6 +122,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…
Reference in a new issue