org.eclipse.jgit.api.RemoteRemoveCommand Java Examples

The following examples show how to use org.eclipse.jgit.api.RemoteRemoveCommand. 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: AbstractGitTest.java    From spring-cloud-contract with Apache License 2.0 6 votes vote down vote up
void setOriginOnProjectToTmp(File origin, File project, boolean push)
		throws GitAPIException, IOException, URISyntaxException {
	try (Git git = openGitProject(project)) {
		RemoteRemoveCommand remove = git.remoteRemove();
		remove.setName("origin");
		remove.call();
		RemoteSetUrlCommand command = git.remoteSetUrl();
		command.setUri(new URIish(origin.toURI().toURL()));
		command.setName("origin");
		command.setPush(push);
		command.call();
		StoredConfig config = git.getRepository().getConfig();
		RemoteConfig originConfig = new RemoteConfig(config, "origin");
		originConfig
				.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
		originConfig.update(config);
		config.save();
	}
}
 
Example #2
Source File: GitContentRepository.java    From studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean removeRemote(String siteId, String remoteName) {
    logger.debug("Remove remote " + remoteName + " from the sandbox repo for the site " + siteId);
    Repository repo = helper.getRepository(siteId, SANDBOX);
    try (Git git = new Git(repo)) {
        RemoteRemoveCommand remoteRemoveCommand = git.remoteRemove();
        remoteRemoveCommand.setName(remoteName);
        remoteRemoveCommand.call();

    } catch (GitAPIException e) {
        logger.error("Failed to remove remote " + remoteName + " for site " + siteId, e);
        return false;
    }

    logger.debug("Remove remote record from database for remote " + remoteName + " and site " + siteId);
    Map<String, String> params = new HashMap<String, String>();
    params.put("siteId", siteId);
    params.put("remoteName", remoteName);
    remoteRepositoryDAO.deleteRemoteRepository(params);

    return true;
}
 
Example #3
Source File: RepositoryManagementServiceInternalImpl.java    From studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean removeRemote(String siteId, String remoteName) throws CryptoException {
    logger.debug("Remove remote " + remoteName + " from the sandbox repo for the site " + siteId);
    GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration);
    Repository repo = helper.getRepository(siteId, SANDBOX);
    try (Git git = new Git(repo)) {
        RemoteRemoveCommand remoteRemoveCommand = git.remoteRemove();
        remoteRemoveCommand.setName(remoteName);
        remoteRemoveCommand.call();

    } catch (GitAPIException e) {
        logger.error("Failed to remove remote " + remoteName + " for site " + siteId, e);
        return false;
    }

    logger.debug("Remove remote record from database for remote " + remoteName + " and site " + siteId);
    Map<String, String> params = new HashMap<String, String>();
    params.put("siteId", siteId);
    params.put("remoteName", remoteName);
    remoteRepositoryDao.deleteRemoteRepository(params);

    return true;
}
 
Example #4
Source File: UIGit.java    From hop with Apache License 2.0 5 votes vote down vote up
@Override
public void removeRemote() {
  RemoteRemoveCommand cmd = git.remoteRemove();
  cmd.setName( Constants.DEFAULT_REMOTE_NAME );
  try {
    cmd.call();
  } catch ( GitAPIException e ) {
    showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage() );
  }
}
 
Example #5
Source File: GitTestUtils.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
public static void setOriginOnProjectToTmp(File origin, File project)
		throws GitAPIException, MalformedURLException {
	try (Git git = openGitProject(project)) {
		RemoteRemoveCommand remove = git.remoteRemove();
		remove.setName("origin");
		remove.call();
		RemoteSetUrlCommand command = git.remoteSetUrl();
		command.setUri(new URIish(origin.toURI().toURL()));
		command.setName("origin");
		command.setPush(true);
		command.call();
	}
}
 
Example #6
Source File: GitTestUtils.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
public static void setOriginOnProjectToTmp(File origin, File project)
		throws GitAPIException, MalformedURLException {
	try (Git git = openGitProject(project)) {
		RemoteRemoveCommand remove = git.remoteRemove();
		remove.setName("origin");
		remove.call();
		RemoteSetUrlCommand command = git.remoteSetUrl();
		command.setUri(new URIish(origin.toURI().toURL()));
		command.setName("origin");
		command.setPush(true);
		command.call();
	}
}
 
Example #7
Source File: GitTestUtils.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
public static void setOriginOnProjectToTmp(File origin, File project)
		throws GitAPIException, MalformedURLException {
	try (Git git = openGitProject(project)) {
		RemoteRemoveCommand remove = git.remoteRemove();
		remove.setName("origin");
		remove.call();
		RemoteSetUrlCommand command = git.remoteSetUrl();
		command.setUri(new URIish(origin.toURI().toURL()));
		command.setName("origin");
		command.setPush(true);
		command.call();
	}
}