From 64e6ad439c0e338328248c27377a2d3518773273 Mon Sep 17 00:00:00 2001
From: Athanasius <github@miggy.org>
Date: Fri, 31 Jul 2020 13:28:28 +0100
Subject: [PATCH] Try remote-add/fetch in separate step

---
 .github/workflows/pr-checks.yml | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml
index 8d66a6b9..4e0a0a79 100644
--- a/.github/workflows/pr-checks.yml
+++ b/.github/workflows/pr-checks.yml
@@ -20,16 +20,28 @@ jobs:
     ####################################################################
     # Checkout the necessary commits
     ####################################################################
-    # We need the commits from the 'head' of the PR, not what it's
+    # We need the repo from the 'head' of the PR, not what it's
     # based on.
-    - name: Checkout commits
+    - name: Checkout head commits
       # https://github.com/actions/checkout
       uses: actions/checkout@v2
       with:
         repository: ${{github.event.pull_request.head.repo.full_name}}
         fetch-depth: 0
-    ####################################################################
 
+    # But we do need the base references
+    - name: Fetch base commits
+      env:
+        BASE_REPO_URL: ${{github.event.pull_request.base.repo.svn_url}}
+        BASE_REPO_OWNER: ${{github.event.pull_request.base.repo.owner.login}}
+
+      run: |
+        # Add the 'base' repo as a new remote
+        git remote add ${BASE_REPO_OWNER} ${BASE_REPO_URL}
+        # And then fetch its references
+        git fetch ${BASE_REPO_OWNER}
+    ####################################################################
+    
     ####################################################################
     # Get Python set up
     ####################################################################
@@ -63,12 +75,6 @@ jobs:
         BASE_REF: ${{github.base_ref}}
 
       run: |
-        # We have checked out the 'head' repo, so we need the references
-        # for the 'base' repo in order to do the 'git diff' below
-        # So, add the 'base' repo as a new remote
-        git remote add ${BASE_REPO_OWNER} ${BASE_REPO_URL}
-        # And then fetch its references
-        git fetch ${BASE_REPO_OWNER}
         # stop the build if there are Python syntax errors or undefined names, ignore existing 
         git diff "refs/remotes/${BASE_REPO_OWNER}/${BASE_REF}" -- | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --diff
         # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide