]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make fetching target branch reliable
authorMichał Kępień <michal@isc.org>
Wed, 3 Jun 2020 13:45:28 +0000 (15:45 +0200)
committerMichał Kępień <michal@isc.org>
Wed, 3 Jun 2020 13:45:28 +0000 (15:45 +0200)
As GitLab Runner Docker executor caches Git repositories between jobs,
prevent the Danger script from attempting to update local refs to ensure
"git fetch" returns with an exit code of 0.  Use the FETCH_HEAD ref for
determining the differences between the merge request branch and its
target branch.

dangerfile.py

index 9bbcc005b8493b9031eecd5c30c7ae8dae34d3c1..09f28cb4d6502dfbe012d798c4bac38319d67016 100644 (file)
@@ -16,9 +16,9 @@ import re
 def added_lines(target_branch, paths):
     import subprocess
     subprocess.check_output(['/usr/bin/git', 'fetch', '--depth', '1', 'origin',
-                             f'{target_branch}:{target_branch}'])
-    diff = subprocess.check_output(['/usr/bin/git', 'diff',
-                                    f'{target_branch}..', '--'] + paths)
+                             target_branch])
+    diff = subprocess.check_output(['/usr/bin/git', 'diff', 'FETCH_HEAD..',
+                                    '--'] + paths)
     added_lines = []
     for line in diff.splitlines():
         if line.startswith(b'+'):