Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from ivanov17/git-first-parent-behavior-fix
Browse files Browse the repository at this point in the history
Fix incorrect behavior of `git_buildbot.py` when using `--first-parent` option
  • Loading branch information
p12tic authored Sep 28, 2024
2 parents 1b7f653 + f8e1b66 commit e34f0bf
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions master/contrib/git_buildbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ def connected(remote):

def grab_commit_info(c, rev):
# Extract information about committer and files using git show
f = subprocess.Popen(shlex.split("git show --raw --pretty=full %s" % rev),
options = "--raw --pretty=full"
if first_parent:
# Show the full diff for merges to avoid losing changes
# when builds are not triggered for merged in commits
options += " --diff-merges=first-parent"
f = subprocess.Popen(shlex.split("git show %s %s" % (options, rev)),
stdout=subprocess.PIPE)

files = []
Expand All @@ -172,7 +177,8 @@ def grab_commit_info(c, rev):
logging.debug("Got author: %s", m.group(1))
c['who'] = text_type(m.group(1))

if re.match(r"^Merge: .*$", line):
# Retain default behavior if all commits trigger builds
if not first_parent and re.match(r"^Merge: .*$", line):
files.append('merge')

c['comments'] = ''.join(comments)
Expand Down Expand Up @@ -227,11 +233,14 @@ def gen_create_branch_changes(newrev, refname, branch):
f2 = subprocess.Popen(shlex.split("grep -v %s" % branchref),
stdin=f.stdout,
stdout=subprocess.PIPE)
f3 = subprocess.Popen(
shlex.split("git rev-list --reverse --pretty=oneline --stdin %s" % newrev),
stdin=f2.stdout,
stdout=subprocess.PIPE
)
options = "--reverse --pretty=oneline --stdin"
if first_parent:
# Don't add merged commits to avoid running builds twice for the same
# changes, as they should only be done for first parent commits
options += " --first-parent"
f3 = subprocess.Popen(shlex.split("git rev-list %s %s" % (options, newrev)),
stdin=f2.stdout,
stdout=subprocess.PIPE)

gen_changes(f3, branch)

Expand Down

0 comments on commit e34f0bf

Please sign in to comment.