Skip to content

Commit

Permalink
Add the ability to tell if a commit is in a specific tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraham committed Feb 4, 2015
1 parent e9ec97a commit b15c6f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
3 changes: 2 additions & 1 deletion wptrunner/update/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def create(self, state):
local_tree.add_new(os.path.relpath(state.tests_path,
local_tree.root))
updated = local_tree.update_patch(include=[state.tests_path,
state.metadata_path])
state.metadata_path])
local_tree.commit_patch()

if not updated:
self.logger.info("Nothing to sync")
Expand Down
26 changes: 22 additions & 4 deletions wptrunner/update/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ def update_patch(self, include=None):
def commit_patch(self):
self.hg("qfinish")

def contains_commit(self, commit):
try:
self.hg("identify", "-r", commit.sha1)
return True
except subprocess.CalledProcessError:
return False


class GitTree(object):
name = "git"
Expand Down Expand Up @@ -237,20 +244,24 @@ def update_patch(self, include=None):
of filenames (which must already be in the repo)
to commit
"""
assert self.message is not None

if include is not None:
args = tuple(include)
else:
args = ()

if self.git("status", "-uno", "-z", *args).strip():
self.git("commit", "-m", self.message, *args)
self.git("add", *args)
return True
return False

def commit_patch(self):
pass
assert self.message is not None

if self.git("diff", "--name-only", "--staged", "-z").strip():
self.git("commit", "-m", self.message)
return True

return False

def init(self):
self.git("init")
Expand Down Expand Up @@ -320,6 +331,13 @@ def submodules(self):
rv.append(parts[1])
return rv

def contains_commit(self, commit):
try:
self.git("rev-parse", "--verify", commit.sha1)
return True
except subprocess.CalledProcessError:
return False


class CommitMessage(object):
def __init__(self, text):
Expand Down

0 comments on commit b15c6f0

Please sign in to comment.