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

Unified Diff: scm.py

Issue 501166: Remove more logic out of trychange.py into scm.py. (Closed)
Patch Set: Created 11 years 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/gclient_scm_test.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 d23ab62d60d924f31e0e7eb6716649da0fa67bcd..2e135558801223059bba50f4fa0b892f1f7e5571 100644
--- a/scm.py
+++ b/scm.py
@@ -14,6 +14,10 @@ import xml.dom.minidom
import gclient_utils
+def ValidateEmail(email):
+ return (re.match(r"^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", email)
+ is not None)
+
class GIT(object):
COMMAND = "git"
@@ -78,10 +82,15 @@ class GIT(object):
@staticmethod
def GetBranchRef(cwd):
- """Returns the short branch name, e.g. 'master'."""
+ """Returns the full branch reference, e.g. 'refs/heads/master'."""
return GIT.Capture(['symbolic-ref', 'HEAD'], cwd).strip()
@staticmethod
+ def GetBranch(cwd):
+ """Returns the short branch name, e.g. 'master'."""
+ return GIT.ShortBranchName(GIT.BranchRef(cwd))
+
+ @staticmethod
def IsGitSvn(cwd):
"""Returns true if this repo looks like it's using git-svn."""
# If you have any "svn-remote.*" config keys, we think you're using svn.
@@ -140,7 +149,7 @@ class GIT(object):
e.g. 'origin', 'refs/heads/master'
"""
remote = '.'
- branch = GIT.ShortBranchName(GIT.GetBranchRef(cwd))
+ branch = GIT.GetBranch(cwd)
upstream_branch = None
upstream_branch = GIT.Capture(
['config', 'branch.%s.merge' % branch], error_ok=True).strip()
@@ -181,6 +190,21 @@ class GIT(object):
diff[i] = '--- %s' % diff[i+1][4:]
return ''.join(diff)
+ @staticmethod
+ def GetPatchName(cwd):
+ """Constructs a name for this patch."""
+ short_sha = GIT.Capture(['rev-parse', '--short=4', 'HEAD'], cwd).strip()
+ return "%s-%s" % (GIT.GetBranch(cwd), short_sha)
+
+ @staticmethod
+ def GetCheckoutRoot(cwd):
+ """Returns the top level directory of the current repository.
+
+ The directory is returned as an absolute path.
+ """
+ return os.path.abspath(GIT.Capture(['rev-parse', '--show-cdup'],
+ cwd).strip())
+
class SVN(object):
COMMAND = "svn"
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698