Skip to content

Commit

Permalink
Fix remote url handling when a PR from a fork is created
Browse files Browse the repository at this point in the history
  • Loading branch information
wsipak committed Sep 17, 2021
1 parent 97c843d commit 745fcf3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ diff_cmd="git diff FECH_HEAD"
if [ -f "$event_file" ]; then
pr_branch=$(python3 -c "import sys, json; print(json.load(sys.stdin)['pull_request']['head']['ref'])" < event.json)
base_branch=$(python3 -c "import sys, json; print(json.load(sys.stdin)['pull_request']['base']['ref'])" < event.json)
git fetch origin "$pr_branch"
clone_url=$(python3 -c "import sys, json; print(json.load(sys.stdin)['pull_request']['head']['repo']['clone_url'])" < event.json)
echo "remotes:"
git remote -v
echo "adding new remote: $clone_url"
git remote add pr_repo "$clone_url"
echo "remotes:"
git remote -v
echo "fetching:"
git fetch pr_repo "$pr_branch"
git checkout "$pr_branch"
echo "current HEAD is: "
git rev-parse HEAD
echo "the PR branch is $pr_branch"
echo "the base branch is $base_branch"
diff_cmd="git diff $base_branch $pr_branch"
Expand Down

0 comments on commit 745fcf3

Please sign in to comment.