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

The following examples show how to use org.eclipse.jgit.lib.Constants#R_REMOTES . 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: RemoteBranch.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
private String getName(boolean fullName, boolean encode) {
	String name = Constants.R_REMOTES + remote.getName() + "/" + this.name; //$NON-NLS-1$
	if (!fullName)
		name = Repository.shortenRefName(name);
	if (encode)
		name = GitUtils.encode(name);
	return name;
}
 
Example 2
Source File: Log.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
private String computeRemoteBranchName(String targetRefName, Remote remote) {
	String prefix = Constants.R_REMOTES + remote.getName() + "/"; //$NON-NLS-1$
	return targetRefName.substring(prefix.length());
}
 
Example 3
Source File: FetchJob.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
private IStatus doFetch(IProgressMonitor monitor) throws IOException, CoreException, URISyntaxException, GitAPIException {
	ProgressMonitor gitMonitor = new EclipseGitProgressTransformer(monitor);
	Repository db = null;
	try {
		db = getRepository();
		Git git = Git.wrap(db);
		FetchCommand fc = git.fetch();
		fc.setProgressMonitor(gitMonitor);

		RemoteConfig remoteConfig = new RemoteConfig(git.getRepository().getConfig(), remote);
		credentials.setUri(remoteConfig.getURIs().get(0));
		if (this.cookie != null) {
			fc.setTransportConfigCallback(new TransportConfigCallback() {
				@Override
				public void configure(Transport t) {
					if (t instanceof TransportHttp && cookie != null) {
						HashMap<String, String> map = new HashMap<String, String>();
						map.put(GitConstants.KEY_COOKIE, cookie.getName() + "=" + cookie.getValue());
						((TransportHttp) t).setAdditionalHeaders(map);
					}
				}
			});
		}
		fc.setCredentialsProvider(credentials);
		fc.setRemote(remote);
		if (branch != null) {
			// refs/heads/{branch}:refs/remotes/{remote}/{branch}
			String remoteBranch = branch;
			if (branch.startsWith("for/")) {
				remoteBranch = branch.substring(4);
			}

			RefSpec spec = new RefSpec(Constants.R_HEADS + remoteBranch + ":" + Constants.R_REMOTES + remote + "/" + branch); //$NON-NLS-1$ //$NON-NLS-2$
			spec = spec.setForceUpdate(force);
			fc.setRefSpecs(spec);
		}
		FetchResult fetchResult = fc.call();
		if (monitor.isCanceled()) {
			return new Status(IStatus.CANCEL, GitActivator.PI_GIT, "Cancelled");
		}
		GitJobUtils.packRefs(db, gitMonitor);
		if (monitor.isCanceled()) {
			return new Status(IStatus.CANCEL, GitActivator.PI_GIT, "Cancelled");
		}
		return handleFetchResult(fetchResult);
	} finally {
		if (db != null) {
			db.close();
		}
	}
}
 
Example 4
Source File: Remote.java    From github-bucket with ISC License 4 votes vote down vote up
public String getFullRef() {
    return Constants.R_REMOTES + remote;
}
 
Example 5
Source File: RemoteTest.java    From github-bucket with ISC License 4 votes vote down vote up
@Test
public void shouldBeValid() throws Exception {
    Remote remote = new Remote(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME);
    assertThat(remote.getShortRef(), is(Constants.DEFAULT_REMOTE_NAME));
    assertThat(remote.getFullRef(), is(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME));
}
 
Example 6
Source File: Remote.java    From github-bucket with ISC License 4 votes vote down vote up
public String getFullRef() {
    return Constants.R_REMOTES + remote;
}
 
Example 7
Source File: RemoteTest.java    From github-bucket with ISC License 4 votes vote down vote up
@Test
public void shouldBeValid() throws Exception {
    Remote remote = new Remote(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME);
    assertThat(remote.getShortRef(), is(Constants.DEFAULT_REMOTE_NAME));
    assertThat(remote.getFullRef(), is(Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME));
}