本文整理了Java中org.eclipse.jgit.api.Git.rebase()
方法的一些代码示例,展示了Git.rebase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.rebase()
方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:rebase
[英]Return a command object to execute a Rebase command
[中]返回命令对象以执行Rebase命令
代码示例来源:origin: centic9/jgit-cookbook
RebaseResult result = git.rebase().setUpstream("origin/master").runInteractively(handler).call();
System.out.println("Rebase had state: " + result.getStatus() + ": " + result.getConflicts());
result = git.rebase().setUpstream("origin/master").runInteractively(handler).setOperation(RebaseCommand.Operation.ABORT).call();
System.out.println("Aborted reabse with state: " + result.getStatus() + ": " + result.getConflicts());
代码示例来源:origin: centic9/jgit-cookbook
RebaseResult result = git.rebase().setUpstream("origin/master").runInteractively(handler).call();
System.out.println("Rebase had state: " + result.getStatus() + ": " + result.getConflicts());
result = git.rebase().setUpstream("origin/master").runInteractively(handler).setOperation(RebaseCommand.Operation.ABORT).call();
System.out.println("Aborted reabse with state: " + result.getStatus() + ": " + result.getConflicts());
代码示例来源:origin: stackoverflow.com
InteractiveHandler handler = new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
// loop through steps and use setAction to change action
}
public String modifyCommitMessage(String oldMessage) {
return oldMessage;
}
};
Repository repo = FileRepositoryBuilder.create(gitDir);
Git git = Git.wrap(repo);
git.rebase().setUpstream(commitA).runInteractively(handler).call();
代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin
/**
* Abort rebasing if there are any conflicts
* @param git
* @throws GitAPIException
*/
private void rebaseAbort(Git git) throws Exception {
try {
git.rebase()
.setOperation(RebaseCommand.Operation.ABORT)
.call();
} catch (GitAPIException e) {
throw new Exception(GIT_COMMAND_REASON, e);
}
}
代码示例来源:origin: com.societegenerale.ci-droid.tasks-consumer/ci-droid-tasks-consumer-infrastructure
public RebaseResult rebaseFrom(Git git, String branchName) throws GitAPIException {
return git.rebase()
.setUpstream("origin/" + branchName)
// preserving merge commits, otherwise they are removed and it becomes confusing :
// we seem to lose some commits during the rebase, even if we don't lose information (since the merge commit is empty)
.setPreserveMerges(true)
.call();
}
代码示例来源:origin: com.societegenerale.ci-droid.tasks-consumer/ci-droid-tasks-consumer-infrastructure
public RebaseResult abortRebase(Git git, String defaultBranch) throws GitAPIException {
return git.rebase().setUpstream("origin/" + defaultBranch).setOperation(RebaseCommand.Operation.ABORT).call();
}
代码示例来源:origin: Verigreen/verigreen
@Override
public boolean rebase(String upStreamBranchName) {
RebaseCommand command = _git.rebase();
RebaseResult result = null;
try {
command.setUpstream(upStreamBranchName);
result = command.call();
// if there are merge conflicts (rebase interactive) - reset the repository
if (!result.getStatus().isSuccessful()) {
_git.rebase().setOperation(Operation.ABORT).call();
}
} catch (Throwable e) {
throw new RuntimeException(String.format(
"Failed to rebase with upstream [%s]",
upStreamBranchName), e);
}
return result.getStatus().isSuccessful();
}
代码示例来源:origin: sheimi/SGit
public boolean rebase() {
try {
mRepo.getGit().rebase().setUpstream(mUpstream).call();
} catch (StopTaskException e) {
return false;
} catch (Throwable e) {
setException(e);
return false;
}
return true;
}
}
代码示例来源:origin: maks/MGit
public boolean rebase() {
try {
mRepo.getGit().rebase().setUpstream(mUpstream).call();
} catch (StopTaskException e) {
return false;
} catch (Throwable e) {
setException(e);
return false;
}
return true;
}
}
代码示例来源:origin: jenkinsci/git-client-plugin
@Override
public void execute() throws GitException, InterruptedException {
try (Repository repo = getRepository()) {
Git git = git(repo);
RebaseResult rebaseResult = git.rebase().setUpstream(upstream).call();
if (!rebaseResult.getStatus().isSuccessful()) {
git.rebase().setOperation(Operation.ABORT).call();
throw new GitException("Failed to rebase " + upstream);
}
} catch (GitAPIException e) {
throw new GitException("Failed to rebase " + upstream, e);
}
}
};
代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin
git.rebase().runInteractively(squashHandler).setUpstream("HEAD~" + numberOfCommits).call();
} catch (GitAPIException e) {
allExceptions.add("Failed to squash last commits", e);
try {
git.rebase().setOperation(RebaseCommand.Operation.ABORT).call();
} catch (GitAPIException e1) {
allExceptions.add("Failed to abort rebase", e1);
代码示例来源:origin: indeedeng/proctor
@Override
public Void call() {
try {
LOGGER.info("Undo local changes due to failure of git operations");
try {
git.rebase().setOperation(RebaseCommand.Operation.ABORT).call();
} catch (WrongRepositoryStateException e) {
// ignore rebasing exception when in wrong state
}
final String remoteBranch = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + '/' + git.getRepository().getBranch();
git.reset().setMode(ResetType.HARD).setRef(remoteBranch).call();
git.clean().setCleanDirectories(true).call();
try {
final ObjectId head = git.getRepository().resolve(Constants.HEAD);
LOGGER.info("Undo local changes completed. HEAD is " + head.getName());
} catch (final Exception e) {
LOGGER.warn("Failed to fetch HEAD", e);
}
} catch (final Exception e) {
LOGGER.error("Unable to undo changes", e);
}
return null;
}
});
代码示例来源:origin: com.indeed/proctor-store-git
@Override
public Void call() {
try {
LOGGER.info("Undo local changes due to failure of git operations");
try {
git.rebase().setOperation(RebaseCommand.Operation.ABORT).call();
} catch (WrongRepositoryStateException e) {
// ignore rebasing exception when in wrong state
}
final String remoteBranch = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + '/' + git.getRepository().getBranch();
git.reset().setMode(ResetType.HARD).setRef(remoteBranch).call();
git.clean().setCleanDirectories(true).call();
try {
final ObjectId head = git.getRepository().resolve(Constants.HEAD);
LOGGER.info("Undo local changes completed. HEAD is " + head.getName());
} catch (final Exception e) {
LOGGER.warn("Failed to fetch HEAD", e);
}
} catch (final Exception e) {
LOGGER.error("Unable to undo changes", e);
}
return null;
}
});
代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin
git.rebase().runInteractively(renameHandler).setUpstream("HEAD~" + rebaseSize).call();
} catch (GitAPIException e) {
try {
allExceptions.add("Error during editing commits messages", e);
git.rebase().setOperation(RebaseCommand.Operation.ABORT).call();
} catch (GitAPIException e1) {
allExceptions.add("Error during aborting rebase", e);
代码示例来源:origin: com.atlassian.jgitflow/jgit-flow-core
/**
*
* @return nothing
* @throws NotInitializedException
* @throws JGitFlowGitAPIException
* @throws DirtyWorkingTreeException
* @throws JGitFlowIOException
* @throws LocalBranchMissingException
*/
@Override
public Void call() throws NotInitializedException, JGitFlowGitAPIException, DirtyWorkingTreeException, JGitFlowIOException, LocalBranchMissingException
{
requireGitFlowInitialized();
requireCleanWorkingTree();
requireLocalBranchExists(branchName);
try
{
git.checkout().setName(branchName).call();
git.rebase().call();
}
catch (GitAPIException e)
{
throw new JGitFlowGitAPIException(e);
}
return null;
}
代码示例来源:origin: org.kie.workbench/kie-wb-common-cli-pom-migration
assertEquals(pullRes.getRebaseResult().getStatus(), RebaseResult.Status.UP_TO_DATE);
RebaseCommand rb = cloned.rebase().setUpstream("origin/master");
RebaseResult rbResult = rb.setPreserveMerges(true).call();
assertTrue(rbResult.getStatus().isSuccessful());
代码示例来源:origin: sheimi/SGit
public boolean reset() {
try {
mRepo.getGit().getRepository().writeMergeCommitMsg(null);
mRepo.getGit().getRepository().writeMergeHeads(null);
try {
mRepo.getGit().rebase().setOperation(RebaseCommand.Operation.ABORT).call();
} catch (Exception e) {
}
mRepo.getGit().reset().setMode(ResetCommand.ResetType.HARD).call();
} catch (StopTaskException e) {
return false;
} catch (Throwable e) {
setException(e);
return false;
}
return true;
}
}
代码示例来源:origin: maks/MGit
public boolean reset() {
try {
mRepo.getGit().getRepository().writeMergeCommitMsg(null);
mRepo.getGit().getRepository().writeMergeHeads(null);
try {
// if a rebase is in-progress, need to abort it
mRepo.getGit().rebase().setOperation(RebaseCommand.Operation.ABORT).call();
} catch (WrongRepositoryStateException e) {
// Ignore this, it happens if rebase --abort is called without a rebase in progress.
Timber.i(e, "Couldn't abort rebase while reset.");
} catch (Exception e) {
setException(e, R.string.error_rebase_abort_failed_in_reset);
return false;
}
mRepo.getGit().reset().setMode(ResetCommand.ResetType.HARD).call();
} catch (StopTaskException e) {
return false;
} catch (Throwable e) {
setException(e);
return false;
}
return true;
}
}
代码示例来源:origin: external.atlassian.jgitflow/jgit-flow-core
/**
* @return nothing
* @throws com.atlassian.jgitflow.core.exception.NotInitializedException
* @throws com.atlassian.jgitflow.core.exception.JGitFlowGitAPIException
* @throws com.atlassian.jgitflow.core.exception.DirtyWorkingTreeException
* @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException
* @throws com.atlassian.jgitflow.core.exception.LocalBranchMissingException
*/
@Override
public Void call() throws NotInitializedException, JGitFlowGitAPIException, DirtyWorkingTreeException, JGitFlowIOException, LocalBranchMissingException
{
String prefixedBranchName = gfConfig.getPrefixValue(JGitFlowConstants.PREFIXES.FEATURE.configKey()) + getBranchName();
enforcer().requireGitFlowInitialized();
enforcer().requireCleanWorkingTree(isAllowUntracked());
enforcer().requireLocalBranchExists(prefixedBranchName);
try
{
git.checkout().setName(prefixedBranchName).call();
git.rebase().setUpstream(gfConfig.getDevelop()).call();
}
catch (GitAPIException e)
{
throw new JGitFlowGitAPIException(e);
}
return null;
}
代码示例来源:origin: io.ultreia.java4all.jgitflow/jgitflow-core
/**
* @return nothing
* @throws com.atlassian.jgitflow.core.exception.NotInitializedException
* @throws com.atlassian.jgitflow.core.exception.JGitFlowGitAPIException
* @throws com.atlassian.jgitflow.core.exception.DirtyWorkingTreeException
* @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException
* @throws com.atlassian.jgitflow.core.exception.LocalBranchMissingException
*/
@Override
public Void call() throws NotInitializedException, JGitFlowGitAPIException, DirtyWorkingTreeException, JGitFlowIOException, LocalBranchMissingException
{
String prefixedBranchName = gfConfig.getPrefixValue(JGitFlowConstants.PREFIXES.FEATURE.configKey()) + getBranchName();
enforcer().requireGitFlowInitialized();
enforcer().requireCleanWorkingTree(isAllowUntracked());
enforcer().requireLocalBranchExists(prefixedBranchName);
try
{
git.checkout().setName(prefixedBranchName).call();
git.rebase().setUpstream(gfConfig.getDevelop()).call();
}
catch (GitAPIException e)
{
throw new JGitFlowGitAPIException(e);
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!