当前位置: 首页>>代码示例>>Java>>正文


Java PushCommand类代码示例

本文整理汇总了Java中org.eclipse.jgit.api.PushCommand的典型用法代码示例。如果您正苦于以下问题:Java PushCommand类的具体用法?Java PushCommand怎么用?Java PushCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PushCommand类属于org.eclipse.jgit.api包,在下文中一共展示了PushCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: push

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
/**
 * Push current state to remote repository.
 *
 * @param repositoryName for which repository
 * @param username committer username
 * @param password committer password
 */
public void push(String repositoryName, String username, String password)
{
    RepositoryContext repositoryContext = repositoryByName.get(repositoryName);

    try
    {
        PushCommand pushCommand = repositoryContext.git.push();
        pushCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password));
        pushCommand.call();
    }
    catch (GitAPIException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:23,代码来源:GitTestSupport.java

示例2: delete

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
@Override
public void delete() throws SCMException {
	try {
		final List<String> deleted = git.tagDelete().setTags(name()).call();
		if (!deleted.isEmpty()) {
			final PushCommand pushCommand = git.push().add(":refs/tags/" + name());
			if (remoteUrlOrNull != null) {
				pushCommand.setRemote(remoteUrlOrNull);
			}
			pushAndLogResult(pushCommand);
		}
		log.info(String.format("Deleted tag '%s' from repository", name()));
	} catch (final GitAPIException e) {
		throw new SCMException(e, "Remote tag '%s' could not be deleted!", name());
	}
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:17,代码来源:GitProposedTag.java

示例3: doCommitAndPush

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
public static RevCommit doCommitAndPush(Git git, String message, UserDetails userDetails, PersonIdent author, String branch, String origin, boolean pushOnCommit) throws GitAPIException {
    CommitCommand commit = git.commit().setAll(true).setMessage(message);
    if (author != null) {
        commit = commit.setAuthor(author);
    }

    RevCommit answer = commit.call();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Committed " + answer.getId() + " " + answer.getFullMessage());
    }

    if (pushOnCommit) {
        PushCommand push = git.push();
        configureCommand(push, userDetails);
        Iterable<PushResult> results = push.setRemote(origin).call();
        for (PushResult result : results) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Pushed " + result.getMessages() + " " + result.getURI() + " branch: " + branch + " updates: " + toString(result.getRemoteUpdates()));
            }
        }
    }
    return answer;
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:24,代码来源:GitHelpers.java

示例4: pushOne

import org.eclipse.jgit.api.PushCommand; //导入依赖的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

示例5: pushAndLogResult

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
private void pushAndLogResult(final PushCommand pushCommand)
		throws GitAPIException, InvalidRemoteException, TransportException {
	for (final PushResult result : pushCommand.call()) {
		for (final RemoteRefUpdate upd : result.getRemoteUpdates()) {
			log.info(upd.toString());
		}
	}
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:9,代码来源:GitProposedTag.java

示例6: tagAndPush

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
@Override
public void tagAndPush() throws SCMException {
	log.info(String.format("About to tag the repository with %s", name()));
	try {
		final PushCommand pushCommand = git.push().add(saveAtHEAD());
		if (remoteUrlOrNull != null) {
			pushCommand.setRemote(remoteUrlOrNull);
		}
		pushAndLogResult(pushCommand);
	} catch (final GitAPIException e) {
		throw new SCMException(e, "Tag '%s' could not be pushed!", name());
	}
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:14,代码来源:GitProposedTag.java

示例7: pushTags

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
@Override
public void pushTags(Collection<AnnotatedTag> tags) throws GitAPIException {
    PushCommand pushCommand = git.push();
    if (remoteUrl != null) {
        pushCommand.setRemote(remoteUrl);
    }

    for (AnnotatedTag tag : tags) {
        pushCommand.add(tag.saveAtHEAD(git));
    }

    pushCommand.call();
}
 
开发者ID:danielflower,项目名称:multi-module-maven-release-plugin,代码行数:14,代码来源:LocalGitRepo.java

示例8: pushCommentsAndReviews

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
/**
 * Pushes the local comments and reviews back to the origin.
 */
private void pushCommentsAndReviews() throws Exception {
  try (Git git = new Git(repo)) {
    RefSpec spec = new RefSpec(DEVTOOLS_PUSH_REFSPEC);
    PushCommand pushCommand = git.push();
    pushCommand.setRefSpecs(spec);
    pushCommand.call();
  }
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:12,代码来源:AppraiseGitReviewClient.java

示例9: pushTag

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
public static PushResult pushTag(TestRepository<?> testRepo, String tag, boolean force)
    throws GitAPIException {
  PushCommand pushCmd = testRepo.git().push();
  pushCmd.setForce(force);
  pushCmd.setRefSpecs(new RefSpec("refs/tags/" + tag + ":refs/tags/" + tag));
  Iterable<PushResult> r = pushCmd.call();
  return Iterables.getOnlyElement(r);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:GitUtil.java

示例10: pushBranchOrAllDetails

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
private void pushBranchOrAllDetails(RepoHelperBuilder.AuthDialogResponse response, PushType pushType,
                                    PushCommand push) throws
        TransportException {
    try{
        RepositoryMonitor.resetFoundNewChanges(false);
        RepoHelper helper = theModel.getCurrentRepoHelper();
        if (response != null) {
            helper.ownerAuth =
                    new UsernamePasswordCredentialsProvider(response.username, response.password);
        }
        if (pushType == PushType.BRANCH) {
            helper.pushCurrentBranch(push);
        } else if (pushType == PushType.ALL) {
            helper.pushAll(push);
        } else {
            assert false : "PushType enum case not handled";
        }
        gitStatus();
    } catch (InvalidRemoteException e) {
        showNoRemoteNotification();
    } catch (PushToAheadRemoteError e) {
        showPushToAheadRemoteNotification(e.isAllRefsRejected());
    } catch (TransportException e) {
        throw e;
    } catch(Exception e) {
        showGenericErrorNotification();
        e.printStackTrace();
    }
}
 
开发者ID:dmusican,项目名称:Elegit,代码行数:30,代码来源:SessionController.java

示例11: cloneThenPushTestWithoutAuthentication

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
@Test
public void cloneThenPushTestWithoutAuthentication() throws Exception {
    File authData = new File(testFileLocation + "httpUsernamePassword.txt");

    // If a developer does not have this file present, test should just pass.
    if (!authData.exists() && looseTesting)
        return;

    Scanner scanner = new Scanner(authData);
    String ignoreURL = scanner.next();
    String username = scanner.next();
    String password = scanner.next();
    UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(username, password);

    String remoteURL = "https://github.com/TheElegitTeam/PushPullTests.git";
    //String remoteURL = "https://github.com/connellyj/HelloWorld.git";

    Path repoPathPush = directoryPath.resolve("clonepush");
    ClonedRepoHelper helperPush = new ClonedRepoHelper(repoPathPush, remoteURL, credentials);
    assertNotNull(helperPush);
    helperPush.obtainRepository(remoteURL);

    // Update the file, then commit and push
    Path readmePath = repoPathPush.resolve("README.md");
    System.out.println(readmePath);
    String timestamp = (new Date()).toString() + "\n";
    Files.write(readmePath, timestamp.getBytes(), StandardOpenOption.APPEND);
    helperPush.addFilePathTest(readmePath);
    helperPush.commit("added a character");
    PushCommand push = helperPush.prepareToPushAll();
    helperPush.pushAll(push);

}
 
开发者ID:dmusican,项目名称:Elegit,代码行数:34,代码来源:PushPullTest.java

示例12: pushAllChangesToGit

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
/**
 * Must be called after #{createGitRepository()}
 */
public void pushAllChangesToGit() throws IOException {
    if (localRepository == null) {
        throw new IOException("Git has not been created, call createGitRepositoryFirst");
    }
    try {
        UserService userService = new UserService();
        userService.getClient().setOAuth2Token(oAuthToken);
        User user = userService.getUser();
        String name = user.getLogin();
        String email = user.getEmail();
        if (email == null) {
            // This is the e-mail addressed used by GitHub on web commits where the users mail is private. See:
            // https://github.com/settings/emails
            email = name + "@users.noreply.github.com";
        }

        localRepository.add().addFilepattern(".").call();
        localRepository.commit()
                .setMessage("Initial commit")
                .setCommitter(name, email)
                .call();
        PushCommand pushCommand = localRepository.push();
        addAuth(pushCommand);
        pushCommand.call();
    } catch (GitAPIException e) {
        throw new IOException("Error pushing changes to GitHub", e);
    }
}
 
开发者ID:WASdev,项目名称:tool.accelerate.core,代码行数:32,代码来源:GitHubConnector.java

示例13: execute

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
@Override
public void execute() {
    if (this.provider != null) {
        ((PushCommand) this.command).setCredentialsProvider(this.provider);
    }
    new GitAsyncTask(callingActivity, true, false, this).execute(this.command);
}
 
开发者ID:zeapo,项目名称:Android-Password-Store,代码行数:8,代码来源:PushOperation.java

示例14: pushChanges

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
/**
 * adds, commits and pushes changes only, if there are actually changes
 * 
 * @param message
 * @return false, if there were no changes to be pushed
 * @throws Exception
 */
public boolean pushChanges(String message) throws Exception {

	if (repository.diff().call().isEmpty()) {
		return false;
	}

	repository.add().addFilepattern(".").call();
	repository.commit().setMessage(message).call();

	PushCommand pushCmd = repository.push();
	credentialsProvider.ifPresent(c -> pushCmd.setCredentialsProvider(c));
	pushCmd.call();
	return true;
}
 
开发者ID:warmuuh,项目名称:pactbroker-maven-plugin,代码行数:22,代码来源:GitApi.java

示例15: call

import org.eclipse.jgit.api.PushCommand; //导入依赖的package包/类
public Git call(final GitOperationsStep gitOperationsStep, Git git,
    CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
    throws IllegalArgumentException, IOException,
    InvalidRemoteException, TransportException, GitAPIException {

  PushCommand pc = git.push().setDryRun(dryRun).setForce(force)
      .setThin(thin);
  if (cp != null) {
    pc = pc.setCredentialsProvider(cp);
  }
  if (!Const.isEmpty(this.receivePack)) {
    pc = pc.setReceivePack(gitOperationsStep
        .environmentSubstitute(receivePack));
  }
  if (!Const.isEmpty(this.referenceToPush)) {
    pc = pc.add(gitOperationsStep
        .environmentSubstitute(this.referenceToPush));
  }
  if (!Const.isEmpty(this.remote)) {
    pc = pc.setRemote(gitOperationsStep
        .environmentSubstitute(this.remote));
  }
  if (this.pushAllBranches) {
    pc = pc.setPushAll();
  }
  if (this.pushAllTags) {
    pc = pc.setPushTags();
  }
  pc.call();
  return git;
}
 
开发者ID:ivylabs,项目名称:ivy-pdi-git-steps,代码行数:32,代码来源:PushGitCommand.java


注:本文中的org.eclipse.jgit.api.PushCommand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。