當前位置: 首頁>>代碼示例>>Java>>正文


Java RefSpec類代碼示例

本文整理匯總了Java中org.eclipse.jgit.transport.RefSpec的典型用法代碼示例。如果您正苦於以下問題:Java RefSpec類的具體用法?Java RefSpec怎麽用?Java RefSpec使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RefSpec類屬於org.eclipse.jgit.transport包,在下文中一共展示了RefSpec類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findRemoteBranchName

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
private String findRemoteBranchName () throws GitException {
    Ref ref = null;
    try {
        ref = getRepository().getRef(branchToMerge);
    } catch (IOException ex) {
        throw new GitException(ex);
    }
    if (ref != null) {
        for (String s : refSpecs) {
            RefSpec spec = new RefSpec(s);
            if (spec.matchDestination(ref)) {
                spec = spec.expandFromDestination(ref);
                String refName = spec.getSource();
                if (refName.startsWith(Constants.R_HEADS)) {
                    return refName.substring(Constants.R_HEADS.length());
                }
            }
        }
    }
    return branchToMerge;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:PullCommand.java

示例2: testAddRemote

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
public void testAddRemote () throws Exception {
    StoredConfig config = repository.getConfig();
    assertEquals(0, config.getSubsections("remote").size());
    
    GitClient client = getClient(workDir);
    GitRemoteConfig remoteConfig = new GitRemoteConfig("origin",
            Arrays.asList(new File(workDir.getParentFile(), "repo2").toURI().toString()),
            Arrays.asList(new File(workDir.getParentFile(), "repo2").toURI().toString()),
            Arrays.asList("+refs/heads/*:refs/remotes/origin/*"),
            Arrays.asList("refs/remotes/origin/*:+refs/heads/*"));
    client.setRemote(remoteConfig, NULL_PROGRESS_MONITOR);
    
    config.load();
    RemoteConfig cfg = new RemoteConfig(config, "origin");
    assertEquals(Arrays.asList(new URIish(new File(workDir.getParentFile(), "repo2").toURI().toString())), cfg.getURIs());
    assertEquals(Arrays.asList(new URIish(new File(workDir.getParentFile(), "repo2").toURI().toString())), cfg.getPushURIs());
    assertEquals(Arrays.asList(new RefSpec("+refs/heads/*:refs/remotes/origin/*")), cfg.getFetchRefSpecs());
    assertEquals(Arrays.asList(new RefSpec("refs/remotes/origin/*:+refs/heads/*")), cfg.getPushRefSpecs());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:RemotesTest.java

示例3: doOK

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
/**
 * Adds the remote as origin to the repository
 */
@Override
protected void doOK() {
	super.doOK();
	StoredConfig config;
	try {
		config = GitAccess.getInstance().getRepository().getConfig();
		RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
		URIish uri = new URIish(remoteRepoTextField.getText());
		remoteConfig.addURI(uri);
		RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
		remoteConfig.addFetchRefSpec(spec);
		remoteConfig.update(config);
		config.save();
	} catch (NoRepositorySelected | URISyntaxException | IOException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
	dispose();
}
 
開發者ID:oxygenxml,項目名稱:oxygen-git-plugin,代碼行數:24,代碼來源:AddRemoteDialog.java

示例4: getRefSpecs

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
@Override
protected List<RefSpec> getRefSpecs() {
    List<RefSpec> refSpecs = new LinkedList<>();

    if (sourceSettings.getBranchMonitorStrategy().getMonitored()) {
        refSpecs.add(BRANCHES.delegate());
    }
    if (sourceSettings.getTagMonitorStrategy().getMonitored()) {
        refSpecs.add(TAGS.delegate());
    }
    if (sourceSettings.getOriginMonitorStrategy().getMonitored() || sourceSettings.getForksMonitorStrategy().getMonitored()) {
        refSpecs.add(MERGE_REQUESTS.delegate());
    }

    return refSpecs;
}
 
開發者ID:Argelbargel,項目名稱:gitlab-branch-source-plugin,代碼行數:17,代碼來源:GitLabSCMSource.java

示例5: deleteRemoteBranch

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
public void deleteRemoteBranch(ScmBranch scmBranch,
                               Consumer<RemoteOperationValue> operationRezConsumer,
                               Consumer<RemoteOperationValue> operationErrConsumer) {

    Optional<ButtonType> dialogResult = getDeleteBranchConfirmDialogValue(scmBranch);
    if (dialogResult.isPresent() && dialogResult.get() == ButtonType.OK) {
        String nameOnRemoteSide = Constants.R_HEADS + scmBranch.getShortName();
        RefSpec refSpec = new RefSpec().setSource(null).setDestination(nameOnRemoteSide);
        Task<RemoteOperationValue> longTask = new Task<RemoteOperationValue>() {
            @Override
            protected RemoteOperationValue call() throws Exception {
                return remoteRepositoryOperation(
                        () -> GitemberApp.getRepositoryService().remoteRepositoryPush(
                                login, pwd, false,
                                new DefaultProgressMonitor((t, d) -> {
                                    updateTitle(t);
                                    updateProgress(d, 1.0);
                                }), refSpec)
                );
            }
        };
        prepareLongTask(longTask, operationRezConsumer, operationErrConsumer);
        new Thread(longTask).start();
    }
}
 
開發者ID:iazarny,項目名稱:gitember,代碼行數:26,代碼來源:GitemberServiceImpl.java

示例6: push

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
public void push(TrainIteration iteration) {

		ExecutionUtils.run(iteration, module -> {

			Branch branch = Branch.from(module);
			logger.log(module, "git push origin %s", branch);

			if (!branchExists(module.getProject(), branch)) {

				logger.log(module, "No branch %s in %s, skip push", branch, module.getProject().getName());
				return;
			}

			doWithGit(module.getProject(), git -> {

				Ref ref = git.getRepository().findRef(branch.toString());

				git.push()//
						.setRemote("origin")//
						.setRefSpecs(new RefSpec(ref.getName()))//
						.setCredentialsProvider(gitProperties.getCredentials())//
						.call();
			});
		});
	}
 
開發者ID:spring-projects,項目名稱:spring-data-dev-tools,代碼行數:26,代碼來源:GitOperations.java

示例7: doPushDelta

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
private List<RemoteRefUpdate> doPushDelta(Map<String, Ref> local) throws IOException {
  List<RemoteRefUpdate> cmds = new ArrayList<>();
  boolean noPerms = !pool.isReplicatePermissions();
  for (String src : delta) {
    RefSpec spec = matchSrc(src);
    if (spec != null) {
      // If the ref still exists locally, send it, otherwise delete it.
      Ref srcRef = local.get(src);

      // Second try to ensure that the ref is truly not found locally
      if (srcRef == null) {
        srcRef = git.exactRef(src);
      }

      if (srcRef != null && canPushRef(src, noPerms)) {
        push(cmds, spec, srcRef);
      } else if (config.isMirror()) {
        delete(cmds, spec);
      }
    }
  }
  return cmds;
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_replication,代碼行數:24,代碼來源:PushOne.java

示例8: syncCommentsAndReviews

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
/**
 * Fetches review and comment git notes and updates the local refs, performing
 * merges if necessary.
 */
public void syncCommentsAndReviews() throws GitClientException {
  RevWalk revWalk = null;
  try (Git git = new Git(repo)) {
    revWalk = new RevWalk(repo);

    // Fetch the latest.
    RefSpec spec = new RefSpec(DEVTOOLS_PULL_REFSPEC);
    git.fetch().setRefSpecs(spec).call();

    syncNotes(revWalk, COMMENTS_REF, COMMENTS_ORIGIN_REF);
    revWalk.reset();
    syncNotes(revWalk, REVIEWS_REF, REVIEWS_ORIGIN_REF);
  } catch (Exception e) {
    throw new GitClientException("Error syncing notes", e);
  } finally {
    if (revWalk != null) {
      revWalk.close();
    }
  }
}
 
開發者ID:google,項目名稱:git-appraise-eclipse,代碼行數:25,代碼來源:AppraiseGitReviewClient.java

示例9: pushOne

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
public static PushResult pushOne(
    TestRepository<?> testRepo,
    String source,
    String target,
    boolean pushTags,
    boolean force,
    List<String> pushOptions)
    throws GitAPIException {
  PushCommand pushCmd = testRepo.git().push();
  pushCmd.setForce(force);
  pushCmd.setPushOptions(pushOptions);
  pushCmd.setRefSpecs(new RefSpec((source != null ? source : "") + ":" + target));
  if (pushTags) {
    pushCmd.setPushTags();
  }
  Iterable<PushResult> r = pushCmd.call();
  return Iterables.getOnlyElement(r);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:19,代碼來源:GitUtil.java

示例10: mergeOnPushToBranch

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
@Test
public void mergeOnPushToBranch() throws Exception {
  grant(project, "refs/heads/master", Permission.PUSH);
  PushOneCommit.Result r =
      push("refs/for/master", PushOneCommit.SUBJECT, "a.txt", "some content");
  r.assertOkStatus();

  git().push().setRefSpecs(new RefSpec(r.getCommit().name() + ":refs/heads/master")).call();
  assertCommit(project, "refs/heads/master");

  ChangeData cd =
      Iterables.getOnlyElement(queryProvider.get().byKey(new Change.Key(r.getChangeId())));
  RevCommit c = r.getCommit();
  PatchSet.Id psId = cd.currentPatchSet().getId();
  assertThat(psId.get()).isEqualTo(1);
  assertThat(cd.change().getStatus()).isEqualTo(Change.Status.MERGED);
  assertSubmitApproval(psId);

  assertThat(cd.patchSets()).hasSize(1);
  assertThat(cd.patchSet(psId).getRevision().get()).isEqualTo(c.name());
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:22,代碼來源:SubmitOnPushIT.java

示例11: allowedButNotSubscribed

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
@Test
public void allowedButNotSubscribed() throws Exception {
  TestRepository<?> superRepo = createProjectWithPush("super-project");
  TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
  allowMatchingSubmoduleSubscription(
      "subscribed-to-project", "refs/heads/master", "super-project", "refs/heads/master");

  pushChangeTo(subRepo, "master");
  subRepo
      .branch("HEAD")
      .commit()
      .insertChangeId()
      .message("some change")
      .add("b.txt", "b contents for testing")
      .create();
  String refspec = "HEAD:refs/heads/master";
  PushResult r =
      Iterables.getOnlyElement(
          subRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec(refspec)).call());
  assertThat(r.getMessages()).doesNotContain("error");
  assertThat(r.getRemoteUpdate("refs/heads/master").getStatus())
      .isEqualTo(RemoteRefUpdate.Status.OK);

  assertThat(hasSubmodule(superRepo, "master", "subscribed-to-project")).isFalse();
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:26,代碼來源:SubmoduleSubscriptionsIT.java

示例12: pushChangeTo

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
protected ObjectId pushChangeTo(
    TestRepository<?> repo, String ref, String file, String content, String message, String topic)
    throws Exception {
  ObjectId ret =
      repo.branch("HEAD").commit().insertChangeId().message(message).add(file, content).create();

  String pushedRef = ref;
  if (!topic.isEmpty()) {
    pushedRef += "/" + name(topic);
  }
  String refspec = "HEAD:" + pushedRef;

  Iterable<PushResult> res =
      repo.git().push().setRemote("origin").setRefSpecs(new RefSpec(refspec)).call();

  RemoteRefUpdate u = Iterables.getOnlyElement(res).getRemoteUpdate(pushedRef);
  assertThat(u).isNotNull();
  assertThat(u.getStatus()).isEqualTo(Status.OK);
  assertThat(u.getNewObjectId()).isEqualTo(ret);

  return ret;
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:23,代碼來源:AbstractSubmoduleSubscription.java

示例13: pushChangesTo

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
protected ObjectId pushChangesTo(TestRepository<?> repo, String branch, int numChanges)
    throws Exception {
  for (int i = 0; i < numChanges; i++) {
    repo.branch("HEAD")
        .commit()
        .insertChangeId()
        .message("Message " + i)
        .add(name("file"), "content" + i)
        .create();
  }
  String remoteBranch = "refs/heads/" + branch;
  Iterable<PushResult> res =
      repo.git()
          .push()
          .setRemote("origin")
          .setRefSpecs(new RefSpec("HEAD:" + remoteBranch))
          .call();
  List<Status> status =
      StreamSupport.stream(res.spliterator(), false)
          .map(r -> r.getRemoteUpdate(remoteBranch).getStatus())
          .collect(toList());
  assertThat(status).containsExactly(Status.OK);
  return Iterables.getLast(res).getRemoteUpdate(remoteBranch).getNewObjectId();
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:25,代碼來源:AbstractSubmoduleSubscription.java

示例14: pushSubmoduleConfig

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
protected void pushSubmoduleConfig(TestRepository<?> repo, String branch, Config config)
    throws Exception {

  repo.branch("HEAD")
      .commit()
      .insertChangeId()
      .message("subject: adding new subscription")
      .add(".gitmodules", config.toText().toString())
      .create();

  repo.git()
      .push()
      .setRemote("origin")
      .setRefSpecs(new RefSpec("HEAD:refs/heads/" + branch))
      .call();
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:17,代碼來源:AbstractSubmoduleSubscription.java

示例15: deleteAllSubscriptions

import org.eclipse.jgit.transport.RefSpec; //導入依賴的package包/類
protected void deleteAllSubscriptions(TestRepository<?> repo, String branch) throws Exception {
  repo.git().fetch().setRemote("origin").call();
  repo.reset("refs/remotes/origin/" + branch);

  ObjectId expectedId =
      repo.branch("HEAD")
          .commit()
          .insertChangeId()
          .message("delete contents in .gitmodules")
          .add(".gitmodules", "") // Just remove the contents of the file!
          .create();
  repo.git()
      .push()
      .setRemote("origin")
      .setRefSpecs(new RefSpec("HEAD:refs/heads/" + branch))
      .call();

  ObjectId actualId =
      repo.git()
          .fetch()
          .setRemote("origin")
          .call()
          .getAdvertisedRef("refs/heads/master")
          .getObjectId();
  assertThat(actualId).isEqualTo(expectedId);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:27,代碼來源:AbstractSubmoduleSubscription.java


注:本文中的org.eclipse.jgit.transport.RefSpec類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。