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

Unified Diff: git_cl.py

Issue 1156223008: Added message when upstream branch is gone. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fixed tests Created 5 years, 6 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 | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 5ff11fc152c0d6e12e2124944ad8f152968001a5..6329db8e27b6e642907e7e959597066fbe95b7da 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -138,6 +138,13 @@ def IsGitVersionAtLeast(min_version):
LooseVersion(version[len(prefix):]) >= LooseVersion(min_version))
+def BranchExists(branch):
+ """Return True if specified branch exists."""
+ code, _ = RunGitWithCode(['rev-parse', '--verify', branch],
+ suppress_stderr=True)
+ return not code
+
+
def ask_for_data(prompt):
try:
return raw_input(prompt)
@@ -718,8 +725,12 @@ or verify this branch is set up to track another (via the --track argument to
return remote, upstream_branch
def GetCommonAncestorWithUpstream(self):
+ upstream_branch = self.GetUpstreamBranch()
+ if not BranchExists(upstream_branch):
+ DieWithError('The upstream for the current branch (%s) does not exist '
+ 'anymore.\nPlease fix it and try again.' % self.GetBranch())
return git_common.get_or_create_merge_base(self.GetBranch(),
- self.GetUpstreamBranch())
+ upstream_branch)
def GetUpstreamBranch(self):
if self.upstream_branch is None:
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698