Package com.google.gerrit.server.git
Class GroupCollector
java.lang.Object
com.google.gerrit.server.git.GroupCollector
Helper for assigning groups to commits during
ReceiveCommits
.
For each commit encountered along a walk between the branch tip and the tip of the push, the group of a commit is defined as follows:
- If the commit is an existing patch set of a change, the group is read from the group field
in the corresponding
PatchSet
record. - If all of a commit's parents are merged into the branch, then its group is its own SHA-1.
- If the commit has a single parent that is not yet merged into the branch, then its group is the same as the parent's group.
- For a merge commit, choose a parent and use that parent's group. If one of the parents has a group from a patch set, use that group, otherwise, use the group from the first parent. In addition to setting this merge commit's group, use the chosen group for all commits that would otherwise use a group from the parents that were not chosen.
- If a merge commit has multiple parents whose group comes from separate patch sets, concatenate the groups from those parents together. This indicates two side branches were pushed separately, followed by the merge.
Callers must call visit(RevCommit)
on all commits between the current branch tip and
the tip of a push, in reverse topo order (parents before children). Once all commits have been
visited, call getGroups()
for the result.
-
Method Summary
Modifier and TypeMethodDescriptionstatic GroupCollector
create
(com.google.gerrit.server.git.receive.ReceivePackRefCache receivePackRefCache, PatchSetUtil psUtil, ChangeNotes.Factory notesFactory, Project.NameKey project) Returns a newGroupCollector
instance.static com.google.common.collect.ImmutableList<String>
getDefaultGroups
(org.eclipse.jgit.lib.ObjectId commit) com.google.common.collect.SortedSetMultimap<org.eclipse.jgit.lib.ObjectId,
String> Returns the groups that got collected from visiting commits usingvisit(RevCommit)
.static com.google.common.collect.ImmutableList<String>
getGroups
(RevisionResource rsrc) void
visit
(org.eclipse.jgit.revwalk.RevCommit c) Process the givenRevCommit
.
-
Method Details
-
getDefaultGroups
public static com.google.common.collect.ImmutableList<String> getDefaultGroups(org.eclipse.jgit.lib.ObjectId commit) -
getGroups
-
create
public static GroupCollector create(com.google.gerrit.server.git.receive.ReceivePackRefCache receivePackRefCache, PatchSetUtil psUtil, ChangeNotes.Factory notesFactory, Project.NameKey project) Returns a newGroupCollector
instance.- See Also:
-
visit
Process the givenRevCommit
. Callers must callvisit(RevCommit)
on all commits between the current branch tip and the tip of a push, in reverse topo order (parents before children). Once all commits have been visited, callgetGroups()
for the result.- Throws:
IOException
- See Also:
-
getGroups
public com.google.common.collect.SortedSetMultimap<org.eclipse.jgit.lib.ObjectId,String> getGroups() throws IOExceptionReturns the groups that got collected from visiting commits usingvisit(RevCommit)
.- Throws:
IOException
-