-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make GerritStatusPush also work with GitPoller source
It would previously work with GerritChangeSource and GerritEventLogPoller only. But using events from these Gerrit specific changesources can be problematic for some users, and so we support GitPoller as well. Reviews are sent back to the Gerrit server for builds with refspecs matching: refs/changes/n/n/n
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,3 +103,30 @@ GerritStatusPush can send a separate review for each build that completes, or a | |
.. seealso:: | ||
|
||
:src:`master/docs/examples/git_gerrit.cfg` and :src:`master/docs/examples/repo_gerrit.cfg` in the Buildbot distribution provide a full example setup of Git+Gerrit or Repo+Gerrit of :bb:reporter:`GerritStatusPush`. | ||
|
||
:class:`GerritStatusPush` is usually used with either :class:`GerritChangeSource` or :class:`GerritEventLogPoller`. But it can also work with a :class:`GitPoller` (when it is configured with the `project` argument). For example, with a :class:`GitPoller` configured as follows, reviews are sent back to the Gerrit server by :class:`GerritStatusPush` for refspecs maching the `refs/changes/n/n/n` syntax: | ||
|
||
.. code-block:: python | ||
def accept_branch(refspec): | ||
# Allow the following forms: | ||
# refs/heads/main | ||
# refs/heads/master | ||
# refs/heads/1.2 | ||
branch_re=r'^refs/heads/(main|master|\d+\.\d+)$' | ||
if re.search(branch_re, refspec): | ||
return True | ||
# Allow the following forms: | ||
# refs/changes/81/281/2 | ||
branch_re=r'^refs/changes/\d+/\d+/\d+$' | ||
if re.search(branch_re, refspec): | ||
return True | ||
return False | ||
cs = changes.GitPoller( | ||
'git+ssh://[email protected]:29418/myproject', | ||
project='myproject', | ||
branches=accept_branch) | ||
c['change_source'].append(cs) |