Add additional RebaseResult for editing commits
With the new RebaseResult.EDIT a client can now distinguish if rebase stopped due to a conflict or because the commit was marked for edit in an interactive rebase. Change-Id: I40f2311cf43ed5f290dcda65a7bd85ba770a85f5 Signed-off-by: Stefan Lay <stefan.lay@sap.com>
This commit is contained in:
parent
765896febb
commit
cce2561e9f
|
@ -1941,7 +1941,7 @@ public String modifyCommitMessage(String commit) {
|
||||||
return ""; // not used
|
return ""; // not used
|
||||||
}
|
}
|
||||||
}).call();
|
}).call();
|
||||||
assertEquals(Status.STOPPED, res.getStatus());
|
assertEquals(Status.EDIT, res.getStatus());
|
||||||
RevCommit toBeEditted = git.log().call().iterator().next();
|
RevCommit toBeEditted = git.log().call().iterator().next();
|
||||||
assertEquals("updated file1 on master", toBeEditted.getFullMessage());
|
assertEquals("updated file1 on master", toBeEditted.getFullMessage());
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,7 @@ public RebaseResult call() throws GitAPIException, NoHeadException,
|
||||||
RevCommit commitToPick = walk
|
RevCommit commitToPick = walk
|
||||||
.parseCommit(ids.iterator().next());
|
.parseCommit(ids.iterator().next());
|
||||||
if (monitor.isCancelled())
|
if (monitor.isCancelled())
|
||||||
return new RebaseResult(commitToPick);
|
return new RebaseResult(commitToPick, Status.STOPPED);
|
||||||
try {
|
try {
|
||||||
monitor.beginTask(MessageFormat.format(
|
monitor.beginTask(MessageFormat.format(
|
||||||
JGitText.get().applyingCommit,
|
JGitText.get().applyingCommit,
|
||||||
|
@ -328,9 +328,9 @@ public RebaseResult call() throws GitAPIException, NoHeadException,
|
||||||
return abort(new RebaseResult(
|
return abort(new RebaseResult(
|
||||||
cherryPickResult.getFailingPaths()));
|
cherryPickResult.getFailingPaths()));
|
||||||
else
|
else
|
||||||
return stop(commitToPick);
|
return stop(commitToPick, Status.STOPPED);
|
||||||
case CONFLICTING:
|
case CONFLICTING:
|
||||||
return stop(commitToPick);
|
return stop(commitToPick, Status.STOPPED);
|
||||||
case OK:
|
case OK:
|
||||||
newHead = cherryPickResult.getNewHead();
|
newHead = cherryPickResult.getNewHead();
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ public RebaseResult call() throws GitAPIException, NoHeadException,
|
||||||
continue;
|
continue;
|
||||||
case EDIT:
|
case EDIT:
|
||||||
rebaseState.createFile(AMEND, commitToPick.name());
|
rebaseState.createFile(AMEND, commitToPick.name());
|
||||||
return stop(commitToPick);
|
return stop(commitToPick, Status.EDIT);
|
||||||
case COMMENT:
|
case COMMENT:
|
||||||
break;
|
break;
|
||||||
case SQUASH:
|
case SQUASH:
|
||||||
|
@ -673,7 +673,8 @@ private PersonIdent parseAuthor() throws IOException {
|
||||||
return parseAuthor(raw);
|
return parseAuthor(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RebaseResult stop(RevCommit commitToPick) throws IOException {
|
private RebaseResult stop(RevCommit commitToPick, RebaseResult.Status status)
|
||||||
|
throws IOException {
|
||||||
PersonIdent author = commitToPick.getAuthorIdent();
|
PersonIdent author = commitToPick.getAuthorIdent();
|
||||||
String authorScript = toAuthorScript(author);
|
String authorScript = toAuthorScript(author);
|
||||||
rebaseState.createFile(AUTHOR_SCRIPT, authorScript);
|
rebaseState.createFile(AUTHOR_SCRIPT, authorScript);
|
||||||
|
@ -691,7 +692,7 @@ private RebaseResult stop(RevCommit commitToPick) throws IOException {
|
||||||
// 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);
|
return new RebaseResult(commitToPick, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
String toAuthorScript(PersonIdent author) {
|
String toAuthorScript(PersonIdent author) {
|
||||||
|
|
|
@ -84,6 +84,15 @@ public boolean isSuccessful() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Stopped for editing in the context of an interactive rebase
|
||||||
|
*/
|
||||||
|
EDIT {
|
||||||
|
@Override
|
||||||
|
public boolean isSuccessful() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Failed; the original HEAD was restored
|
* Failed; the original HEAD was restored
|
||||||
*/
|
*/
|
||||||
|
@ -183,9 +192,10 @@ private RebaseResult(Status status) {
|
||||||
*
|
*
|
||||||
* @param commit
|
* @param commit
|
||||||
* current commit
|
* current commit
|
||||||
|
* @param status
|
||||||
*/
|
*/
|
||||||
RebaseResult(RevCommit commit) {
|
RebaseResult(RevCommit commit, RebaseResult.Status status) {
|
||||||
status = Status.STOPPED;
|
this.status = status;
|
||||||
currentCommit = commit;
|
currentCommit = commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue