Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Unified Diff: scm.py

Issue 1755018: Add a fallback to origin/trunk too when the branch is not tracked. (Closed)
Patch Set: Cleaner Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | trychange.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm.py
diff --git a/scm.py b/scm.py
index c4834116f9818a8a4c4f77596f8b5e5cb6922bbf..a9b1ecf84b4759b84c43125a6010cc1876342c8d 100644
--- a/scm.py
+++ b/scm.py
@@ -218,21 +218,30 @@ class GIT(object):
# Fall back on trying a git-svn upstream branch.
if GIT.IsGitSvn(cwd):
upstream_branch = GIT.GetSVNBranch(cwd)
- # Fall back on origin/master if it exits.
- elif GIT.Capture(['branch', '-r'], in_directory=cwd
- )[0].split().count('origin/master'):
- remote = 'origin'
- upstream_branch = 'refs/heads/master'
else:
- remote = None
- upstream_branch = None
+ # Else, try to guess the origin remote.
+ remote_branches = GIT.Capture(
+ ['branch', '-r'], in_directory=cwd)[0].split()
+ if 'origin/master' in remote_branches:
+ # Fall back on origin/master if it exits.
+ remote = 'origin'
+ upstream_branch = 'refs/heads/master'
+ elif 'origin/trunk' in remote_branches:
+ # Fall back on origin/trunk if it exists. Generally a shared
+ # git-svn clone
+ remote = 'origin'
+ upstream_branch = 'refs/heads/trunk'
+ else:
+ # Give up.
+ remote = None
+ upstream_branch = None
return remote, upstream_branch
@staticmethod
def GetUpstreamBranch(cwd):
"""Gets the current branch's upstream branch."""
remote, upstream_branch = GIT.FetchUpstreamTuple(cwd)
- if remote != '.':
+ if remote != '.' and upstream_branch:
upstream_branch = upstream_branch.replace('heads', 'remotes/' + remote)
return upstream_branch
« no previous file with comments | « no previous file | trychange.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698