Package com.google.gerrit.server.git
Class GroupCollector
- java.lang.Object
-
- com.google.gerrit.server.git.GroupCollector
-
public class GroupCollector extends Object
Helper for assigning groups to commits duringReceiveCommits
.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, callgetGroups()
for the result. - If the commit is an existing patch set of a change, the group is read from the group field
in the corresponding
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GroupCollector
create(com.google.gerrit.server.git.receive.ReceivePackRefCache receivePackRefCache, PatchSetUtil psUtil, ChangeNotes.Factory notesFactory, Project.NameKey project)
Returns a newGroupCollector
instance.static List<String>
getDefaultGroups(org.eclipse.jgit.lib.ObjectId commit)
com.google.common.collect.SortedSetMultimap<org.eclipse.jgit.lib.ObjectId,String>
getGroups()
Returns the groups that got collected from visiting commits usingvisit(RevCommit)
.static List<String>
getGroups(RevisionResource rsrc)
void
visit(org.eclipse.jgit.revwalk.RevCommit c)
Process the givenRevCommit
.
-
-
-
Method Detail
-
getGroups
public static List<String> getGroups(RevisionResource rsrc)
-
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:
for what this class does.
-
visit
public void visit(org.eclipse.jgit.revwalk.RevCommit c) throws IOException
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:
for what this class does.
-
getGroups
public com.google.common.collect.SortedSetMultimap<org.eclipse.jgit.lib.ObjectId,String> getGroups() throws IOException
Returns the groups that got collected from visiting commits usingvisit(RevCommit)
.- Throws:
IOException
-
-