Search in sources :

Example 21 with RefSpec

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");
}
Also used : RefSpec(org.eclipse.jgit.transport.RefSpec) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 22 with RefSpec

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);
}
Also used : RefSpec(org.eclipse.jgit.transport.RefSpec)

Example 23 with RefSpec

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);
}
Also used : RefSpec(org.eclipse.jgit.transport.RefSpec)

Example 24 with RefSpec

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;
}
Also used : Ref(org.eclipse.jgit.lib.Ref) RefSpec(org.eclipse.jgit.transport.RefSpec) NoSuchProjectException(com.google.gerrit.server.project.NoSuchProjectException) Branch(com.google.gerrit.reviewdb.client.Branch) OpenRepo(com.google.gerrit.server.git.MergeOpRepoManager.OpenRepo) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 25 with RefSpec

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);
    }
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) RefSpec(org.eclipse.jgit.transport.RefSpec) ArrayList(java.util.ArrayList) SubscribeSection(com.google.gerrit.common.data.SubscribeSection)

Aggregations

RefSpec (org.eclipse.jgit.transport.RefSpec)46 Test (org.junit.Test)17 RevCommit (org.eclipse.jgit.revwalk.RevCommit)15 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)12 IOException (java.io.IOException)11 ObjectId (org.eclipse.jgit.lib.ObjectId)11 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)9 Git (org.eclipse.jgit.api.Git)8 PushCommand (org.eclipse.jgit.api.PushCommand)8 File (java.io.File)7 PushResult (org.eclipse.jgit.transport.PushResult)7 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)6 UsernamePasswordCredentialsProvider (org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider)6 AppServicePlan (com.microsoft.azure.management.appservice.AppServicePlan)5 PublishingProfile (com.microsoft.azure.management.appservice.PublishingProfile)5 ArrayList (java.util.ArrayList)5 FetchCommand (org.eclipse.jgit.api.FetchCommand)5 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)4 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)4 GitException (org.eclipse.che.api.git.exception.GitException)4