use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class CheckMergeabilityIT method checkInvalidStrategy.
@Test
public void checkInvalidStrategy() throws Exception {
RevCommit initialHead = getRemoteHead();
testRepo.branch("HEAD").commit().insertChangeId().message("first commit").add("a.txt", "a contents ").create();
testRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/master")).call();
testRepo.reset(initialHead);
testRepo.branch("HEAD").commit().insertChangeId().message("some change in a too").add("a.txt", "a contents too").create();
testRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/test")).call();
assertBadRequest("master", "test", "octopus", "invalid merge strategy: octopus");
}
use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class SubscribeSection method addMatchingRefSpec.
public void addMatchingRefSpec(String spec) {
RefSpec r = new RefSpec(spec);
matchingRefSpecs.add(r);
}
use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class SubscribeSection method addMultiMatchRefSpec.
public void addMultiMatchRefSpec(String spec) {
RefSpec r = new RefSpec(spec, RefSpec.WildcardMode.ALLOW_MISMATCH);
multiMatchRefSpecs.add(r);
}
use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class SubmoduleOp method getDestinationBranches.
private Collection<Branch.NameKey> getDestinationBranches(Branch.NameKey src, SubscribeSection s) throws IOException {
Collection<Branch.NameKey> ret = new HashSet<>();
logDebug("Inspecting SubscribeSection " + s);
for (RefSpec r : s.getMatchingRefSpecs()) {
logDebug("Inspecting [matching] ref " + r);
if (!r.matchSource(src.get())) {
continue;
}
if (r.isWildcard()) {
// refs/heads/*[:refs/somewhere/*]
ret.add(new Branch.NameKey(s.getProject(), r.expandFromSource(src.get()).getDestination()));
} else {
// e.g. refs/heads/master[:refs/heads/stable]
String dest = r.getDestination();
if (dest == null) {
dest = r.getSource();
}
ret.add(new Branch.NameKey(s.getProject(), dest));
}
}
for (RefSpec r : s.getMultiMatchRefSpecs()) {
logDebug("Inspecting [all] ref " + r);
if (!r.matchSource(src.get())) {
continue;
}
OpenRepo or;
try {
or = orm.getRepo(s.getProject());
} catch (NoSuchProjectException e) {
// thrown.
continue;
}
for (Ref ref : or.repo.getRefDatabase().getRefs(RefNames.REFS_HEADS).values()) {
if (r.getDestination() != null && !r.matchDestination(ref.getName())) {
continue;
}
Branch.NameKey b = new Branch.NameKey(s.getProject(), ref.getName());
if (!ret.contains(b)) {
ret.add(b);
}
}
}
logDebug("Returning possible branches: " + ret + "for project " + s.getProject());
return ret;
}
use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class ProjectConfig method saveSubscribeSections.
private void saveSubscribeSections(Config rc) {
for (Project.NameKey p : subscribeSections.keySet()) {
SubscribeSection s = subscribeSections.get(p);
List<String> matchings = new ArrayList<>();
for (RefSpec r : s.getMatchingRefSpecs()) {
matchings.add(r.toString());
}
rc.setStringList(SUBSCRIBE_SECTION, p.get(), SUBSCRIBE_MATCH_REFS, matchings);
List<String> multimatchs = new ArrayList<>();
for (RefSpec r : s.getMultiMatchRefSpecs()) {
multimatchs.add(r.toString());
}
rc.setStringList(SUBSCRIBE_SECTION, p.get(), SUBSCRIBE_MULTI_MATCH_REFS, multimatchs);
}
}
Aggregations