Prior to invoking the submit_rule(X)
query for a change, Gerrit initializes
the Prolog engine with a set of facts (current data) about this change.
The following table provides an overview of the provided facts.
Important
|
All the terms listed below are defined in the gerrit package. To use any
of them we must use a qualified name like gerrit:change_branch(X) .
|
Fact | Example | Description |
---|---|---|
|
|
Destination Branch for the change as string atom |
|
|
Owner of the change as |
|
|
Name of the project as string atom |
|
|
Topic name as string atom |
|
|
Author of the commit as |
|
|
ID, full name and the email of the commit author. The full name and the email are string atoms |
|
|
Committer of the commit as |
|
|
ID, full name and the email of the commit committer. The full name and the email are string atoms |
|
|
Set of votes on the last patch-set |
|
||
|
|
Commit message as string atom |
|
|
Number of parent commits of a commit. Can be used to detect merge commits |
|
|
Number of files modified, number of insertions and the number of deletions. |
|
|
`files(file('a.txt', 'M', 'REGULAR')).' A list of tuples: The first argument is a file name of the current patchset. The second argument is the modification type of this file, with the options being 'A' for 'added', 'M' for 'modified', 'D' for 'deleted', 'R' for 'renamed', 'C' for 'COPIED' and 'W' for 'rewrite'. The third argument is the type of file, with the options being a submodule file 'SUBMODULE' and a non-submodule file being 'REGULAR'. |
|
|
Pure revert as integer atom (1 if the change is a pure revert, 0 otherwise) |
|
|
Uploader as |
|
|
The number of unresolved comments as an integer atom |
In addition Gerrit provides a set of built-in helper predicates that can be used
when implementing the submit_rule
predicate. The most common ones are listed in
the following table.
Predicate | Example usage | Description |
---|---|---|
|
|
True if any file name from the last patch set matches the given regex. |
|
|
Returns the change type (via Possible values for the change type are the following symbols: |
|
|
Like |
|
|
True if any of the files matched by the file name regex (first parameter)
have edited lines that match the regex in the second parameter. This
example will be true if there is a modification of a |
|
|
True if the commit message matches the given regex. |
Note
|
For a complete list of built-in helpers read the gerrit_common.pl and
all Java classes whose name matches PRED_*.java from Gerrit’s source code.
|
Part of Gerrit Code Review