Java Code Examples for org.eclipse.jgit.lib.Constants#MASTER

The following examples show how to use org.eclipse.jgit.lib.Constants#MASTER . 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: RepositoryS3Test.java    From github-bucket with ISC License 5 votes vote down vote up
public RepositoryS3Test() {
    try {
        this.repository = new TestRepository<>(new InMemoryRepository(new DfsRepositoryDescription()));
        this.uut = new RepositoryS3(BUCKET, repository.getRepository(), amazonS3, new Branch(Constants.MASTER));
    }
    catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example 2
Source File: RepositoryS3Test.java    From github-bucket with ISC License 5 votes vote down vote up
public RepositoryS3Test() {
    try {
        this.repository = new TestRepository<>(new InMemoryRepository(new DfsRepositoryDescription()));
        this.uut = new RepositoryS3(BUCKET, repository.getRepository(), amazonS3, new Branch(Constants.MASTER));
    }
    catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example 3
Source File: GitAPITestCase.java    From git-client-plugin with MIT License 5 votes vote down vote up
/**
 * UT for {@link GitClient#getBranchesContaining(String, boolean)}. The main
 * testing case is retrieving remote branches.
 * @throws Exception on exceptions occur
 */
public void test_branchContainingRemote() throws Exception {
    final WorkingArea r = new WorkingArea();
    r.init();

    r.commitEmpty("c1");
    ObjectId c1 = r.head();

    w.git.clone_().url("file://" + r.repoPath()).execute();
    final URIish remote = new URIish(Constants.DEFAULT_REMOTE_NAME);
    final List<RefSpec> refspecs = Collections.singletonList(new RefSpec(
            "refs/heads/*:refs/remotes/origin/*"));
    final String remoteBranch = getRemoteBranchPrefix() + Constants.DEFAULT_REMOTE_NAME + "/"
            + Constants.MASTER;
    final String bothBranches = Constants.MASTER + "," + remoteBranch;
    w.git.fetch_().from(remote, refspecs).execute();
    checkoutTimeout = 1 + random.nextInt(60 * 24);
    w.git.checkout().ref(Constants.MASTER).timeout(checkoutTimeout).execute();

    assertEquals(Constants.MASTER,
            formatBranches(w.git.getBranchesContaining(c1.name(), false)));
    assertEquals(bothBranches, formatBranches(w.git.getBranchesContaining(c1.name(), true)));

    r.commitEmpty("c2");
    ObjectId c2 = r.head();
    w.git.fetch_().from(remote, refspecs).execute();
    assertEquals("", formatBranches(w.git.getBranchesContaining(c2.name(), false)));
    assertEquals(remoteBranch, formatBranches(w.git.getBranchesContaining(c2.name(), true)));
}
 
Example 4
Source File: GitBranchTest.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
@Test
public void testCreateTrackingBranch() throws Exception {
	createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
	IPath[] clonePaths = createTestProjects(workspaceLocation);

	for (IPath clonePath : clonePaths) {
		// clone a  repo
		JSONObject clone = clone(clonePath);
		String cloneLocation = clone.getString(ProtocolConstants.KEY_LOCATION);
		String cloneContentLocation = clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
		String branchesLocation = clone.getString(GitConstants.KEY_BRANCH);

		// overwrite user settings, do not rebase when pulling, see bug 372489
		StoredConfig cfg = getRepositoryForContentLocation(cloneContentLocation).getConfig();
		cfg.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, false);
		cfg.save();

		// get project/folder metadata
		WebRequest request = getGetRequest(cloneContentLocation);
		WebResponse response = webConversation.getResponse(request);
		assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
		JSONObject project = new JSONObject(response.getText());

		JSONObject gitSection = project.getJSONObject(GitConstants.KEY_GIT);
		String gitHeadUri = gitSection.getString(GitConstants.KEY_HEAD);
		String gitRemoteUri = gitSection.optString(GitConstants.KEY_REMOTE);

		// create local branch tracking origin/master
		final String BRANCH_NAME = "a";
		final String REMOTE_BRANCH = Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER;

		branch(branchesLocation, BRANCH_NAME, REMOTE_BRANCH);

		// modify, add, commit
		JSONObject testTxt = getChild(project, "test.txt");
		modifyFile(testTxt, "some change");
		addFile(testTxt);
		request = GitCommitTest.getPostGitCommitRequest(gitHeadUri, "commit1", false);
		response = webConversation.getResponse(request);
		assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

		// push
		ServerStatus pushStatus = push(gitRemoteUri, 1, 0, Constants.MASTER, Constants.HEAD, false);
		assertEquals(true, pushStatus.isOK());

		// TODO: replace with RESTful API for git pull when available
		// try to pull - up to date status is expected
		Git git = Git.wrap(getRepositoryForContentLocation(cloneContentLocation));
		PullResult pullResults = git.pull().call();
		assertEquals(Constants.DEFAULT_REMOTE_NAME, pullResults.getFetchedFrom());
		assertEquals(MergeStatus.ALREADY_UP_TO_DATE, pullResults.getMergeResult().getMergeStatus());
		assertNull(pullResults.getRebaseResult());

		// checkout branch which was created a moment ago
		response = checkoutBranch(cloneLocation, BRANCH_NAME);
		assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

		// TODO: replace with RESTful API for git pull when available
		// try to pull again - now fast forward update is expected
		pullResults = git.pull().call();
		assertEquals(Constants.DEFAULT_REMOTE_NAME, pullResults.getFetchedFrom());
		assertEquals(MergeStatus.FAST_FORWARD, pullResults.getMergeResult().getMergeStatus());
		assertNull(pullResults.getRebaseResult());
	}
}
 
Example 5
Source File: BranchTest.java    From github-bucket with ISC License 4 votes vote down vote up
@Test
public void shouldBeValid() throws Exception {
    Branch branch = new Branch(Constants.R_HEADS + Constants.MASTER);
    assertThat(branch.getShortRef(), is(Constants.MASTER));
    assertThat(branch.getFullRef(), is(Constants.R_HEADS + Constants.MASTER));
}
 
Example 6
Source File: BranchTest.java    From github-bucket with ISC License 4 votes vote down vote up
@Test
public void shouldBeValid() throws Exception {
    Branch branch = new Branch(Constants.R_HEADS + Constants.MASTER);
    assertThat(branch.getShortRef(), is(Constants.MASTER));
    assertThat(branch.getFullRef(), is(Constants.R_HEADS + Constants.MASTER));
}
 
Example 7
Source File: SvnTestServer.java    From git-as-svn with GNU General Public License v2.0 4 votes vote down vote up
@NotNull
public static SvnTestServer createEmpty(@Nullable UserDBConfig userDBConfig, @Nullable Function<Path, RepositoryMappingConfig> mappingConfigCreator, boolean anonymousRead, @NotNull LfsMode lfsMode, @NotNull SharedConfig... shared) throws Exception {
  return new SvnTestServer(TestHelper.emptyRepository(), Constants.MASTER, "", false, userDBConfig, mappingConfigCreator, anonymousRead, lfsMode, shared);
}