mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
Use jgit client library for diff with conflict
This commit is contained in:
@@ -12,7 +12,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class GitDiffCommand_Merge_Test extends AbstractGitCommandTestBase {
|
||||
|
||||
static final String DIFF_HEADER = "diff --git a/Main.java b/Main.java";
|
||||
static final String DIFF_FILE_A_MULTIPLE_REVISIONS = "--- a/Main.java\n" +
|
||||
static final String DIFF_FILE_NO_CONFLICT = "--- a/Main.java\n" +
|
||||
"+++ b/Main.java\n" +
|
||||
"@@ -1,5 +1,5 @@\n" +
|
||||
" class Main {\n" +
|
||||
@@ -21,6 +21,22 @@ public class GitDiffCommand_Merge_Test extends AbstractGitCommandTestBase {
|
||||
" System.out.println(\"Expect nothing more to happen.\");\n" +
|
||||
" System.out.println(\"This is for demonstration, only.\");\n" +
|
||||
" }\n";
|
||||
static final String DIFF_FILE_CONFLICT = "--- a/Main.java\n" +
|
||||
"+++ b/Main.java\n" +
|
||||
"@@ -1,6 +1,13 @@\n" +
|
||||
"+import java.util.Arrays;\n" +
|
||||
"+\n" +
|
||||
" class Main {\n" +
|
||||
" public static void main(String[] args) {\n" +
|
||||
" System.out.println(\"Expect nothing more to happen.\");\n" +
|
||||
"+<<<<<<< HEAD\n" +
|
||||
" System.out.println(\"This is for demonstration, only.\");\n" +
|
||||
"+=======\n" +
|
||||
"+ System.out.println(\"Parameters:\");\n" +
|
||||
"+ Arrays.stream(args).map(arg -> \"- \" + arg).forEach(System.out::println);\n" +
|
||||
"+>>>>>>> feature/print_args\n" +
|
||||
" }\n" +
|
||||
" }\n";
|
||||
|
||||
@Rule
|
||||
public BindTransportProtocolRule transportProtocolRule = new BindTransportProtocolRule();
|
||||
@@ -30,12 +46,12 @@ public class GitDiffCommand_Merge_Test extends AbstractGitCommandTestBase {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository, new SimpleGitWorkdirFactory(new WorkdirProvider()));
|
||||
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
|
||||
diffCommandRequest.setRevision("feature/rename_variable");
|
||||
diffCommandRequest.setMergeChangeset("integration");
|
||||
diffCommandRequest.setConflictBranch("integration");
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
gitDiffCommand.getDiffResult(diffCommandRequest).accept(output);
|
||||
assertThat(output.toString())
|
||||
.contains(DIFF_HEADER)
|
||||
.contains(DIFF_FILE_A_MULTIPLE_REVISIONS);
|
||||
.contains(DIFF_FILE_NO_CONFLICT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -43,12 +59,12 @@ public class GitDiffCommand_Merge_Test extends AbstractGitCommandTestBase {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository, new SimpleGitWorkdirFactory(new WorkdirProvider()));
|
||||
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
|
||||
diffCommandRequest.setRevision("feature/print_args");
|
||||
diffCommandRequest.setMergeChangeset("integration");
|
||||
diffCommandRequest.setConflictBranch("integration");
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
gitDiffCommand.getDiffResult(diffCommandRequest).accept(output);
|
||||
assertThat(output.toString())
|
||||
.contains(DIFF_HEADER)
|
||||
.contains(DIFF_FILE_A_MULTIPLE_REVISIONS);
|
||||
.contains(DIFF_FILE_CONFLICT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user