本文整理汇总了Java中org.eclipse.jgit.api.PushCommand.call方法的典型用法代码示例。如果您正苦于以下问题:Java PushCommand.call方法的具体用法?Java PushCommand.call怎么用?Java PushCommand.call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.api.PushCommand
的用法示例。
在下文中一共展示了PushCommand.call方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: 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);
}
示例3: 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());
}
}
}
示例4: 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();
}
示例5: 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();
}
}
示例6: 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);
}
示例7: 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);
}
}
示例8: 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;
}
示例9: 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;
}
示例10: push
import org.eclipse.jgit.api.PushCommand; //导入方法依赖的package包/类
@Override
public boolean push(String sourceBranch, String destinationBranch) {
PushCommand command = _git.push();
boolean ret = true;
RefSpec refSpec = new RefSpec().setSourceDestination(sourceBranch, destinationBranch);
command.setRefSpecs(refSpec);
try {
List<Ref> remoteBranches = _git.branchList().setListMode(ListMode.REMOTE).call();
Iterable<PushResult> results = command.call();
for (PushResult pushResult : results) {
Collection<RemoteRefUpdate> resultsCollection = pushResult.getRemoteUpdates();
Map<PushResult,RemoteRefUpdate> resultsMap = new HashMap<>();
for(RemoteRefUpdate remoteRefUpdate : resultsCollection)
{
resultsMap.put(pushResult, remoteRefUpdate);
}
RemoteRefUpdate remoteUpdate = pushResult.getRemoteUpdate(destinationBranch);
if (remoteUpdate != null) {
org.eclipse.jgit.transport.RemoteRefUpdate.Status status =
remoteUpdate.getStatus();
ret =
status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.OK)
|| status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.UP_TO_DATE);
}
if(remoteUpdate == null && !remoteBranches.toString().contains(destinationBranch))
{
for(RemoteRefUpdate resultValue : resultsMap.values())
{
if(resultValue.toString().contains("REJECTED_OTHER_REASON"))
{
ret = false;
}
}
}
}
} catch (Throwable e) {
throw new RuntimeException(String.format(
"Failed to push [%s] into [%s]",
sourceBranch,
destinationBranch), e);
}
return ret;
}
示例11: execute
import org.eclipse.jgit.api.PushCommand; //导入方法依赖的package包/类
@Override
public void execute(Wandora wandora, Context context) {
try {
Git git = getGit();
if(git != null) {
if(isNotEmpty(getGitRemoteUrl())) {
if(pushUI == null) {
pushUI = new PushUI();
}
pushUI.setPassword(getPassword());
pushUI.setUsername(getUsername());
pushUI.setRemoteUrl(getGitRemoteUrl());
pushUI.openInDialog();
if(pushUI.wasAccepted()) {
setDefaultLogger();
setLogTitle("Git push");
String username = pushUI.getUsername();
String password = pushUI.getPassword();
String remoteUrl = pushUI.getRemoteUrl();
setUsername(username);
setPassword(password);
// setGitRemoteUrl(remoteUrl);
PushCommand push = git.push();
log("Pushing local changes to upstream.");
if(username != null && username.length() > 0) {
CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider( username, password );
push.setCredentialsProvider(credentialsProvider);
}
Iterable<PushResult> pushResults = push.call();
for(PushResult pushResult : pushResults) {
String pushResultMessage = pushResult.getMessages();
if(isNotEmpty(pushResultMessage)) {
log(pushResultMessage);
}
}
log("Ready.");
}
}
else {
log("Repository has no remote origin and can't be pushed. "
+"Initialize repository by cloning remote repository to set the remote origin.");
}
}
else {
logAboutMissingGitRepository();
}
}
catch(TransportException tre) {
if(tre.toString().contains("origin: not found.")) {
log("Git remote origin is not found. Check the remote url and remote git repository.");
}
}
catch(GitAPIException gae) {
log(gae.toString());
}
catch(NoWorkTreeException nwte) {
log(nwte.toString());
}
catch(Exception e) {
log(e);
}
setState(WAIT);
}