Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions ome_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ def __init__(self, filters, reset=False):
except:
log.error("Failed to find %s", repo_name, exc_info=1)
self.candidate_pulls = []
self.modifications = 0
self.find_candidates()

def find_candidates(self):
Expand Down Expand Up @@ -308,6 +307,12 @@ def info(self):
(pullrequest.pr.issue_url, pullrequest.get_title(), pullrequest.get_login())
print

def fast_forward(self, base, remote = "origin"):
"""Execute merge --ff-only against the current base"""
dbg("## Merging base to ensure closed PRs are included.")
p = subprocess.Popen(["git", "merge", "--ff-only", "%s/%s" % (remote, base)], stdout = subprocess.PIPE).communicate()[0]
log.info(p.rstrip("/n"))

def merge(self, comment=False):
"""Merge candidate pull requests."""
dbg("## Unique users: %s", self.unique_logins())
Expand All @@ -326,11 +331,10 @@ def merge(self, comment=False):
try:
call("git", "merge", "--no-ff", "-m", \
"%s: PR %s (%s)" % (self.commit_id(), pullrequest.get_number(), pullrequest.get_title()), pullrequest.get_sha())
self.modifications += 1
merged_pulls.append(pullrequest)
except:
call("git", "reset", "--hard", "%s" % premerge_sha)
conflictingPRs.append(data)
conflicting_pulls.append(pullrequest)

msg = "Conflicting PR #%g." % pullrequest.get_number()
if os.environ.has_key("JOB_NAME") and os.environ.has_key("BUILD_NUMBER"):
Expand Down Expand Up @@ -370,23 +374,22 @@ def submodules(self, info=False, comment=False):
try:
submodule_repo = None
cd(directory)
submodule_repo = Repository(filters, self.reset)
submodule_repo = Repository(self.filters, self.reset)
if info:
submodule_repo.info()
else:
submodule_repo.fast_forward(self.filters["base"])
submodule_repo.merge(comment)
submodule_repo.submodules(info)
self.modifications += submodule_repo.modifications
finally:
try:
if submodule_repo:
submodule_repo.cleanup()
finally:
cd(cwd)

if self.modifications:
call("git", "commit", "--allow-empty", "-a", "-n", "-m", \
"%s: Update all modules w/o hooks" % self.commit_id())
call("git", "commit", "--allow-empty", "-a", "-n", "-m", \
"%s: Update all modules w/o hooks" % self.commit_id())

def get_name(self):
"""Return name of the repository."""
Expand Down