Refresh remote HEAD if matches legacy default
If remote HEAD returns legacy default branch, refresh HEAD by running
set-head to check if there are any changes.
R=gavinmak@google.com
Change-Id: I5891a899b512e81fccfb086a056d497c906df4b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3152593
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
diff --git a/scm.py b/scm.py
index 5275d43..39f8c58 100644
--- a/scm.py
+++ b/scm.py
@@ -201,6 +201,12 @@
try:
# Try using local git copy first
ref = 'refs/remotes/%s/HEAD' % remote
+ ref = GIT.Capture(['symbolic-ref', ref], cwd=cwd)
+ if not ref.endswith('master'):
+ return ref
+ # Check if there are changes in the default branch for this particular
+ # repository.
+ GIT.Capture(['remote', 'set-head', '-a', remote], cwd=cwd)
return GIT.Capture(['symbolic-ref', ref], cwd=cwd)
except subprocess2.CalledProcessError:
pass