Use static factory methods instead of overloaded constructors
Change-Id: Ib10e0798dcfb9f1b611caec393926c95eff4c2a2
This commit is contained in:
parent
53616a85ef
commit
ec0d78d093
|
@ -321,7 +321,7 @@ public RebaseResult call() throws GitAPIException, NoHeadException,
|
||||||
}
|
}
|
||||||
return finishRebase(newHead, lastStepWasForward);
|
return finishRebase(newHead, lastStepWasForward);
|
||||||
} catch (CheckoutConflictException cce) {
|
} catch (CheckoutConflictException cce) {
|
||||||
return new RebaseResult(cce.getConflictingPaths());
|
return RebaseResult.conflicts(cce.getConflictingPaths());
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new JGitInternalException(ioe.getMessage(), ioe);
|
throw new JGitInternalException(ioe.getMessage(), ioe);
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ private RebaseResult processStep(RebaseTodoLine step, boolean shouldPick)
|
||||||
RevCommit commitToPick = walk.parseCommit(ids.iterator().next());
|
RevCommit commitToPick = walk.parseCommit(ids.iterator().next());
|
||||||
if (shouldPick) {
|
if (shouldPick) {
|
||||||
if (monitor.isCancelled())
|
if (monitor.isCancelled())
|
||||||
return new RebaseResult(commitToPick, Status.STOPPED);
|
return RebaseResult.result(Status.STOPPED, commitToPick);
|
||||||
RebaseResult result = cherryPickCommit(commitToPick);
|
RebaseResult result = cherryPickCommit(commitToPick);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
return result;
|
return result;
|
||||||
|
@ -403,8 +403,8 @@ private RebaseResult cherryPickCommit(RevCommit commitToPick)
|
||||||
switch (cherryPickResult.getStatus()) {
|
switch (cherryPickResult.getStatus()) {
|
||||||
case FAILED:
|
case FAILED:
|
||||||
if (operation == Operation.BEGIN)
|
if (operation == Operation.BEGIN)
|
||||||
return abort(new RebaseResult(
|
return abort(RebaseResult.failed(cherryPickResult
|
||||||
cherryPickResult.getFailingPaths()));
|
.getFailingPaths()));
|
||||||
else
|
else
|
||||||
return stop(commitToPick, Status.STOPPED);
|
return stop(commitToPick, Status.STOPPED);
|
||||||
case CONFLICTING:
|
case CONFLICTING:
|
||||||
|
@ -735,7 +735,7 @@ private RebaseResult stop(RevCommit commitToPick, RebaseResult.Status status)
|
||||||
// Remove cherry pick state file created by CherryPickCommand, it's not
|
// Remove cherry pick state file created by CherryPickCommand, it's not
|
||||||
// needed for rebase
|
// needed for rebase
|
||||||
repo.writeCherryPickHead(null);
|
repo.writeCherryPickHead(null);
|
||||||
return new RebaseResult(commitToPick, status);
|
return RebaseResult.result(status, commitToPick);
|
||||||
}
|
}
|
||||||
|
|
||||||
String toAuthorScript(PersonIdent author) {
|
String toAuthorScript(PersonIdent author) {
|
||||||
|
|
|
@ -190,28 +190,36 @@ private RebaseResult(Status status) {
|
||||||
currentCommit = null;
|
currentCommit = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private RebaseResult(Status status, RevCommit commit) {
|
||||||
* Create <code>RebaseResult</code> with status {@link Status#STOPPED}
|
|
||||||
*
|
|
||||||
* @param commit
|
|
||||||
* current commit
|
|
||||||
* @param status
|
|
||||||
*/
|
|
||||||
RebaseResult(RevCommit commit, RebaseResult.Status status) {
|
|
||||||
this.status = status;
|
this.status = status;
|
||||||
currentCommit = commit;
|
currentCommit = commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create <code>RebaseResult</code>
|
||||||
|
*
|
||||||
|
* @param status
|
||||||
|
* @param commit
|
||||||
|
* current commit
|
||||||
|
* @return the RebaseResult
|
||||||
|
*/
|
||||||
|
static RebaseResult result(RebaseResult.Status status,
|
||||||
|
RevCommit commit) {
|
||||||
|
return new RebaseResult(status, commit);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create <code>RebaseResult</code> with status {@link Status#FAILED}
|
* Create <code>RebaseResult</code> with status {@link Status#FAILED}
|
||||||
*
|
*
|
||||||
* @param failingPaths
|
* @param failingPaths
|
||||||
* list of paths causing this rebase to fail
|
* list of paths causing this rebase to fail
|
||||||
|
* @return the RebaseResult
|
||||||
*/
|
*/
|
||||||
RebaseResult(Map<String, MergeFailureReason> failingPaths) {
|
static RebaseResult failed(
|
||||||
status = Status.FAILED;
|
Map<String, MergeFailureReason> failingPaths) {
|
||||||
currentCommit = null;
|
RebaseResult result = new RebaseResult(Status.FAILED);
|
||||||
this.failingPaths = failingPaths;
|
result.failingPaths = failingPaths;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,11 +227,12 @@ private RebaseResult(Status status) {
|
||||||
*
|
*
|
||||||
* @param conflicts
|
* @param conflicts
|
||||||
* the list of conflicting paths
|
* the list of conflicting paths
|
||||||
|
* @return the RebaseResult
|
||||||
*/
|
*/
|
||||||
RebaseResult(List<String> conflicts) {
|
static RebaseResult conflicts(List<String> conflicts) {
|
||||||
status = Status.CONFLICTS;
|
RebaseResult result = new RebaseResult(Status.CONFLICTS);
|
||||||
currentCommit = null;
|
result.conflicts = conflicts;
|
||||||
this.conflicts = conflicts;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue