From 5bdfcd8f3397c0a51b1539d672a9ed10d4caf239 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Tue, 3 Nov 2020 17:27:15 +0000 Subject: [PATCH] Add `main` when guessing origin remote This fixes presubmit checks that rely on FetchUpstreamTuple which is used in patching. R=ehmaldonado@chromium.org Bug: 1143724 Change-Id: I163fa0ea6f1b356280d497196869bb206463ad4f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2515268 Auto-Submit: Josip Sokcevic Commit-Queue: Edward Lesmes Reviewed-by: Edward Lesmes --- scm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scm.py b/scm.py index 662ab7e51..c374a66e7 100644 --- a/scm.py +++ b/scm.py @@ -226,7 +226,11 @@ class GIT(object): return remote, upstream_branch # Else, try to guess the origin remote. - if 'origin/master' in GIT.GetRemoteBranches(cwd): + remote_branches = GIT.GetRemoteBranches(cwd) + if 'origin/main' in remote_branches: + # Fall back on origin/main if it exits. + return 'origin', 'refs/heads/main' + elif 'origin/master' in remote_branches: # Fall back on origin/master if it exits. return 'origin', 'refs/heads/master'