org.eclipse.jgit.api.MergeCommand.FastForwardMode Java Examples
The following examples show how to use
org.eclipse.jgit.api.MergeCommand.FastForwardMode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MergeConfig.java From onedev with MIT License | 5 votes |
private static FastForwardMode getFastForwardMode(Config config, String[] mergeOptions) { for (String option : mergeOptions) { for (FastForwardMode mode : FastForwardMode.values()) if (mode.matchConfigValue(option)) return mode; } FastForwardMode ffmode = FastForwardMode.valueOf(config.getEnum( ConfigConstants.CONFIG_KEY_MERGE, null, ConfigConstants.CONFIG_KEY_FF, FastForwardMode.Merge.TRUE)); return ffmode; }
Example #2
Source File: MergeConfig.java From onedev with MIT License | 4 votes |
private MergeConfig() { fastForwardMode = FastForwardMode.FF; squash = false; commit = true; }
Example #3
Source File: GitMirrorTest.java From centraldogma with Apache License 2.0 | 4 votes |
@Test void remoteToLocal_merge() throws Exception { pushMirrorSettings(null, null); // Mirror an empty git repository, which will; // - Create /mirror_state.json // - Remove the sample files created by createProject(). mirroringService.mirror().join(); // Create a text file, modify it in two branches ('master' and 'fork') and merge 'fork' into 'master'. addToGitIndex("alphabets.txt", // 'c' and 'x' are missing. "a\nb\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\ny\nz\n"); git.commit().setMessage("Add alphabets.txt").call(); //// Create a new branch 'fork' and add the missing 'x'. git.checkout().setCreateBranch(true).setName("fork").call(); addToGitIndex("alphabets.txt", // Add the missing 'x'. "a\nb\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n"); final RevCommit commit1 = git.commit().setMessage("Add missing 'x'").call(); //// Check out 'master' and add the missing 'c'. git.checkout().setName("master").call(); addToGitIndex("alphabets.txt", // Add the missing 'c'. "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\ny\nz\n"); final RevCommit commit2 = git.commit().setMessage("Add missing 'c'").call(); //// Merge 'fork' into 'master' to create a merge commit. final MergeResult mergeResult = git.merge() .include(commit1.getId()) .setFastForward(FastForwardMode.NO_FF) .setMessage("Merge 'fork'").call(); //// Make sure the merge commit has been added. assertThat(mergeResult.getMergeStatus()).isEqualTo(MergeStatus.MERGED); final RevCommit lastCommit = git.log().all().call().iterator().next(); assertThat(lastCommit.getParentCount()).isEqualTo(2); assertThat(lastCommit.getParents()).containsExactlyInAnyOrder(commit1, commit2); // Run the mirror and ensure alphabets.txt contains all alphabets. mirroringService.mirror().join(); final Revision headRev = client.normalizeRevision(projName, REPO_FOO, Revision.HEAD).join(); final Entry<JsonNode> expectedMirrorState = expectedMirrorState(headRev, "/"); final Entry<String> expectedAlphabets = Entry.ofText( headRev, "/alphabets.txt", "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n"); assertThat(client.getFiles(projName, REPO_FOO, Revision.HEAD, "/**").join().values()) .containsExactlyInAnyOrder(expectedMirrorState, expectedAlphabets); }
Example #4
Source File: MergeConfig.java From onedev with MIT License | 2 votes |
/** * Get the fast forward mode configured for this branch * * @return the fast forward mode configured for this branch */ public FastForwardMode getFastForwardMode() { return fastForwardMode; }