diff --git a/dangerfile.py b/dangerfile.py index ee77f13cd1..531e05bb18 100644 --- a/dangerfile.py +++ b/dangerfile.py @@ -23,11 +23,13 @@ import gitlab def added_lines(target_branch, paths): import subprocess - subprocess.check_output( - ["/usr/bin/git", "fetch", "--depth", "1", "origin", target_branch] - ) + # Hazard fetches the target branch itself, so there is no need to fetch it + # explicitly using `git fetch --depth 1000 origin `. The + # refs/remotes/origin/ ref is also expected to be readily + # usable by the time this file is executed. + diff = subprocess.check_output( - ["/usr/bin/git", "diff", "FETCH_HEAD..", "--"] + paths + ["/usr/bin/git", "diff", f"origin/{target_branch}...", "--"] + paths ) added_lines = [] for line in diff.splitlines():