Skip to content

Commit

Permalink
Merge pull request buildbot#7760 from tdesveaux/gitpoller/fix-merges
Browse files Browse the repository at this point in the history
Gitpoller: fix merges processing
  • Loading branch information
p12tic authored Jul 7, 2024
2 parents af0cf9e + 3150d22 commit 347a883
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
4 changes: 2 additions & 2 deletions master/buildbot/changes/gitpoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def process(git_output):
return d

def _get_commit_files(self, rev):
args = ['--name-only', '--no-walk', r'--format=%n', rev, '--']
args = ['--name-only', '--no-walk', r'--format=%n', '-m', '--first-parent', rev, '--']
d = self._dovccmd('log', args, path=self.workdir)

def decode_file(file):
Expand Down Expand Up @@ -489,7 +489,7 @@ def _process_changes(self, newRev, branch):

# get the change list
revListArgs = (
['--ignore-missing']
['--ignore-missing', '--first-parent']
+ ['--format=%H', f'{newRev}']
+ ['^' + rev for rev in sorted(self.lastRev.values())]
+ ['--']
Expand Down
59 changes: 40 additions & 19 deletions master/buildbot/test/unit/changes/test_gitpoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,16 @@ def test_get_commit_files(self):
filesRes = ['file1', 'file2', 'file_octal', 'file space']
return self._perform_git_output_test(
self.poller._get_commit_files,
['log', '--name-only', '--no-walk', '--format=%n', self.dummyRevStr, '--'],
[
'log',
'--name-only',
'--no-walk',
'--format=%n',
'-m',
'--first-parent',
self.dummyRevStr,
'--',
],
filesBytes,
filesRes,
emptyRaisesException=False,
Expand All @@ -194,7 +203,16 @@ def test_get_commit_files_with_space_in_changed_files(self):
filesStr = bytes2unicode(filesBytes)
return self._perform_git_output_test(
self.poller._get_commit_files,
['log', '--name-only', '--no-walk', '--format=%n', self.dummyRevStr, '--'],
[
'log',
'--name-only',
'--no-walk',
'--format=%n',
'-m',
'--first-parent',
self.dummyRevStr,
'--',
],
filesBytes,
[l for l in filesStr.splitlines() if l.strip()],
emptyRaisesException=False,
Expand Down Expand Up @@ -387,6 +405,7 @@ def test_poll_failLog(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^fa3ae8ed68e664d4db24798611b352e3c6509930',
Expand Down Expand Up @@ -470,6 +489,7 @@ def test_poll_nothingNew(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^4423cdbcbb89c14e50dd5f4152415afd686c5241',
Expand Down Expand Up @@ -580,6 +600,7 @@ def test_poll_multipleBranches(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^bf0b01df6d00ae8d1ffa0b2e2acbe642a6cd35d5',
Expand All @@ -604,6 +625,7 @@ def test_poll_multipleBranches(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'9118f4ab71963d23d02d4bdc54876ac8bf05acf2',
'^4423cdbcbb89c14e50dd5f4152415afd686c5241',
Expand Down Expand Up @@ -741,6 +763,7 @@ def test_poll_multipleBranches_buildPushesWithNoCommits_default(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^4423cdbcbb89c14e50dd5f4152415afd686c5241',
Expand Down Expand Up @@ -793,6 +816,7 @@ def test_poll_multipleBranches_buildPushesWithNoCommits_true(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^4423cdbcbb89c14e50dd5f4152415afd686c5241',
Expand Down Expand Up @@ -892,6 +916,7 @@ def test_poll_multipleBranches_buildPushesWithNoCommits_true_fast_forward(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^0ba9d553b7217ab4bbad89ad56dc0332c7d57a8c',
Expand Down Expand Up @@ -995,6 +1020,7 @@ def test_poll_multipleBranches_buildPushesWithNoCommits_true_not_tip(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^0ba9d553b7217ab4bbad89ad56dc0332c7d57a8c',
Expand Down Expand Up @@ -1090,6 +1116,7 @@ def test_poll_allBranches_single(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^fa3ae8ed68e664d4db24798611b352e3c6509930',
Expand Down Expand Up @@ -1200,6 +1227,7 @@ def test_poll_noChanges(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^4423cdbcbb89c14e50dd5f4152415afd686c5241',
Expand Down Expand Up @@ -1247,6 +1275,7 @@ def test_poll_allBranches_multiple(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^bf0b01df6d00ae8d1ffa0b2e2acbe642a6cd35d5',
Expand All @@ -1271,6 +1300,7 @@ def test_poll_allBranches_multiple(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'9118f4ab71963d23d02d4bdc54876ac8bf05acf2',
'^4423cdbcbb89c14e50dd5f4152415afd686c5241',
Expand Down Expand Up @@ -1378,6 +1408,7 @@ def test_poll_callableFilteredBranches(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^bf0b01df6d00ae8d1ffa0b2e2acbe642a6cd35d5',
Expand Down Expand Up @@ -1489,6 +1520,7 @@ def test_poll_branchFilter(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'9118f4ab71963d23d02d4bdc54876ac8bf05acf2',
'^bf0b01df6d00ae8d1ffa0b2e2acbe642a6cd35d5',
Expand Down Expand Up @@ -1595,6 +1627,7 @@ def test_poll_old(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^fa3ae8ed68e664d4db24798611b352e3c6509930',
Expand Down Expand Up @@ -1709,6 +1742,7 @@ def test_poll_callableCategory(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'4423cdbcbb89c14e50dd5f4152415afd686c5241',
'^fa3ae8ed68e664d4db24798611b352e3c6509930',
Expand Down Expand Up @@ -1833,6 +1867,7 @@ def test_startService_loadLastRev(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'fa3ae8ed68e664d4db24798611b352e3c6509930',
'^fa3ae8ed68e664d4db24798611b352e3c6509930',
Expand Down Expand Up @@ -1943,6 +1978,7 @@ async def test_poll_found_head(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'737b94eca1ddde3dd4a0040b25c8a25fe973fe09',
'^4423cdbcbb89c14e50dd5f4152415afd686c5241',
Expand Down Expand Up @@ -1993,6 +2029,7 @@ async def test_poll_found_head_not_found(self):
'git',
'log',
'--ignore-missing',
'--first-parent',
'--format=%H',
'737b94eca1ddde3dd4a0040b25c8a25fe973fe09',
'^4423cdbcbb89c14e50dd5f4152415afd686c5241',
Expand Down Expand Up @@ -2657,30 +2694,14 @@ async def test_poll_from_last(self):
'src': 'git',
'when_timestamp': 1717855320,
},
{
'author': 'test user <[email protected]>',
'branch': 'main',
'category': None,
'codebase': None,
'comments': 'Feature 1',
'committer': 'test user <[email protected]>',
'files': ['README.md'],
'project': '',
'properties': {},
'repository': self.repo_url,
'revision': self.FEATURE_1_SHA,
'revlink': '',
'src': 'git',
'when_timestamp': 1717855380,
},
{
'author': 'test user <[email protected]>',
'branch': 'main',
'category': None,
'codebase': None,
'comments': "Merge branch 'feature/1'",
'committer': 'test user <[email protected]>',
'files': [],
'files': ['README.md'],
'project': '',
'properties': {},
'repository': self.repo_url,
Expand Down
1 change: 1 addition & 0 deletions newsfragments/git-poller-on-merge-commits.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``GitPoller`` merge commit processing. ``GitPoller`` now correctly list merge commit files. (:issue:`7494`)

0 comments on commit 347a883

Please sign in to comment.