Skip to content

Commit 0e5b93c

Browse files
committed
foo
Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent af3b914 commit 0e5b93c

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

β€Žhack/mirror-pr.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,28 @@ gh pr checkout --force "$PR_NUMBER" --repo "$UPSTREAM_REPO"
8484
# 2. Push the branch to your fork
8585
NEW_BRANCH_NAME="test-pr-${PR_NUMBER}-${PR_AUTHOR}"
8686

87-
echo "πŸ”„ Pushing changes to a new branch '${NEW_BRANCH_NAME}' on your fork (${FORK_REMOTE})..."
88-
# Force push in case the branch already exists from a previous test run
89-
git push "$FORK_REMOTE" "HEAD:${NEW_BRANCH_NAME}" --force
90-
9187
# check if we didn't already have a pull request open for this branch
9288
already_opened_pr=$(
9389
gh pr list --repo "$UPSTREAM_REPO" --head \
94-
"${FORK_REMOTE}:${NEW_BRANCH_NAME}" --json url --jq '.[0].url'
90+
"${NEW_BRANCH_NAME}" --json url --jq '.[0].url'
9591
)
92+
93+
if [[ -n ${already_opened_pr} ]]; then
94+
echo "πŸ”„ A pull request already exists for this branch, pushing to the pull request target: ${already_opened_pr}"
95+
96+
gh pr list --repo openshift-pipelines/pipelines-as-code --head ${NEW_BRANCH_NAME} --json headRepositoryOwner,headRepository --jq '.[0].headRepositoryOwner.login + "/" + .[0].headRepository.name'
97+
)"
98+
echo "πŸ”¨ Pushing changes to existing pull request branch '${NEW_BRANCH_NAME}' fork (${FORK_REMOTE})..."
99+
else
100+
101+
echo "πŸ”¨ Pushing changes to a new branch '${NEW_BRANCH_NAME}' on your fork (${FORK_REMOTE})..."
102+
fi
103+
104+
# Force push in case the branch already exists from a previous test run
105+
git push "$FORK_REMOTE" "HEAD:${NEW_BRANCH_NAME}" --force
106+
96107
if [[ -n ${already_opened_pr} ]]; then
97-
echo "πŸ”— A pull request already exists for this branch: ${already_opened_pr}"
108+
echo "πŸ”— Pull request has successfully been synched ${already_opened_pr}"
98109
exit 0
99110
fi
100111

0 commit comments

Comments
Β (0)