org.eclipse.jgit.api.errors.InvalidRemoteException Java Examples

The following examples show how to use org.eclipse.jgit.api.errors.InvalidRemoteException. 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: GitRepository.java    From Getaviz with Apache License 2.0 6 votes vote down vote up
private File cloneToTmpDir(String pathToRemoteGitRepository) throws GitAPIException, InvalidRemoteException, TransportException {
	File localDir;
	TmpDirCreator tmpDirCreator = new TmpDirCreator(pathToRemoteGitRepository);
	localDir = tmpDirCreator.getLocalTempDir();
	if(!localDir.exists()){
		messageOutputStream.println("Caching git repository " + pathToRemoteGitRepository + "...");
		Git.cloneRepository().setURI(pathToRemoteGitRepository)
							 .setDirectory(localDir)
							 .setProgressMonitor(new GitProgressMonitor())
							 .call();
		localDir.mkdirs();
		messageOutputStream.println("\nCaching finished succesfully...");
		tmpDirCreator.writeIdFileToTempDir();
	}
	return localDir;
}
 
Example #2
Source File: JGitUtil.java    From mcg-helper with Apache License 2.0 6 votes vote down vote up
public static boolean cloneRepository(String remoteUrl, String branch, String projectPath, String user, String pwd) throws InvalidRemoteException, TransportException, GitAPIException {
   	File projectDir = new File(projectPath);

       UsernamePasswordCredentialsProvider provider = new UsernamePasswordCredentialsProvider(user, pwd);
       try (Git git = Git.cloneRepository()
               .setURI(remoteUrl)
               .setBranch(branch)
               .setDirectory(projectDir)
               .setCredentialsProvider(provider)
               .setProgressMonitor(new CloneProgressMonitor())
               .call()) {
       	
       }
       
       return true;
}
 
Example #3
Source File: GitWorkspaceSync.java    From milkman with MIT License 6 votes vote down vote up
private Git refreshRepository(GitSyncDetails syncDetails, File syncDir)
		throws GitAPIException, InvalidRemoteException, TransportException, IOException,
		WrongRepositoryStateException, InvalidConfigurationException, CanceledException, RefNotFoundException,
		RefNotAdvertisedException, NoHeadException {
	Git repo;
	if (!syncDir.exists()) {
		syncDir.mkdirs();
		repo = initWith(Git.cloneRepository(), syncDetails)
			.setURI(syncDetails.getGitUrl())
			.setDirectory(syncDir)
			.setCloneAllBranches(true)
			.setBranch("master")
			.call();
		
		
	} else {
		repo = Git.open(syncDir);
		initWith(repo.pull(), syncDetails)
			.call();
	}
	return repo;
}
 
Example #4
Source File: GitControl.java    From juneau with Apache License 2.0 5 votes vote down vote up
public void pushToRepo() throws IOException, JGitInternalException, InvalidRemoteException, GitAPIException {
	PushCommand pc = git.push();
	pc.setCredentialsProvider(cp).setForce(true).setPushAll();
	try {
		Iterator<PushResult> it = pc.call().iterator();
		if (it.hasNext()) {
			System.out.println(it.next().toString());
		}
	} catch (InvalidRemoteException e) {
		e.printStackTrace();
	}
}
 
Example #5
Source File: XacmlAdminUI.java    From XACML with MIT License 5 votes vote down vote up
/**
   * Initializes a user's git repository.
   * 
   * 
   * @param workspacePath
   * @param userId
   * @param email
   * @return
   * @throws IOException
   * @throws InvalidRemoteException
   * @throws TransportException
   * @throws GitAPIException
   */
  private static Path initializeUserRepository(Path workspacePath, String userId, URI email) throws IOException, InvalidRemoteException, TransportException, GitAPIException {
  	Path gitPath = null;
//
// Initialize the User's Git repository
//
if (Files.notExists(workspacePath)) {
	logger.info("Creating user workspace: " + workspacePath.toAbsolutePath().toString());
	//
	// Create our user's directory
	//
	Files.createDirectory(workspacePath);
}
gitPath = Paths.get(workspacePath.toString(), XacmlAdminUI.repositoryPath.getFileName().toString());
if (Files.notExists(gitPath)) {
	//
	// It doesn't exist yet, so Clone it and check it out
	//
	logger.info("Cloning user git directory: " + gitPath.toAbsolutePath().toString());
	Git.cloneRepository().setURI(XacmlAdminUI.repositoryPath.toUri().toString())
					.setDirectory(gitPath.toFile())
					.setNoCheckout(false)
					.call();
	//
	// Set userid
	//
	Git git = Git.open(gitPath.toFile());
	StoredConfig config = git.getRepository().getConfig();
	config.setString("user", null, "name", userId);
	if (email != null && email.getPath() != null) {
		config.setString("user", null, "email", email.toString());
	}
	config.save();
}
return gitPath;
  }
 
Example #6
Source File: JGitEnvironmentRepositoryConcurrencyTests.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
@Override
public FetchResult call()
		throws GitAPIException, InvalidRemoteException, TransportException {
	try {
		Thread.sleep(250);
	}
	catch (InterruptedException e) {
		e.printStackTrace();
	}
	return super.call();
}
 
Example #7
Source File: JGitEnvironmentRepositoryConcurrencyTests.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
@Override
public Git call()
		throws GitAPIException, InvalidRemoteException, TransportException {
	try {
		Thread.sleep(250);
	}
	catch (InterruptedException e) {
		e.printStackTrace();
	}
	return super.call();
}
 
Example #8
Source File: DevicesGit.java    From Flashtool with GNU General Public License v3.0 5 votes vote down vote up
public static void gitSync() throws IOException, InvalidRemoteException, org.eclipse.jgit.api.errors.TransportException, GitAPIException {
	SshSessionFactory.setInstance(new JschConfigSessionFactory() {
		  public void configure(Host hc, Session session) {
		    session.setConfig("StrictHostKeyChecking", "no");
		  };
		}
	);
	if (openRepository()) {
		pullRepository();
	}
	else cloneRepository();
}
 
Example #9
Source File: RepositoryCloner.java    From compiler with Apache License 2.0 5 votes vote down vote up
public static void clone(String[] args)
			throws IOException, InvalidRemoteException, TransportException, GitAPIException {
		// prepare a new folder for the cloned repository
		String localPath = args[1];
		String url = args[0];
		File localGitDir = new File(localPath + "/.git");
		// then clone
		Git result = null;

		java.lang.System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
		try {
			result = Git.cloneRepository().setURI(url).setBare(true).setDirectory(localGitDir).call();
			// Note: the call() returns an opened repository already which
			// needs
			// to be closed to avoid file handle leaks!
			// workaround for
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=474093
			result.getRepository().close();
			/*
		} catch (Exception e) {
			System.err.println("Error cloning " + url);
			e.printStackTrace();
			*/
		} finally {
			if (result != null && result.getRepository() != null) {
//				System.out.println("Cloned repo " + url);
				result.getRepository().close();
			}
		} 
	}
 
Example #10
Source File: RepositoryClonerWorker.java    From compiler with Apache License 2.0 5 votes vote down vote up
public void clone(int from, int to)
		throws InvalidRemoteException, TransportException, IOException, GitAPIException {
	String urlHeader = "https://github.com/";
	String urlFooter = ".git";
	String outFilePath = "";
	File dir = new File(inPath);
	File[] files = dir.listFiles();
	for (int i = from; i < to; i++) {
		// System.out.println("Processing file number " + i );
		if (!files[i].getName().endsWith(".json")) {
			continue;
		}
		String content = FileIO.readFileContents(files[i]);
		Gson parser = new Gson();
		JsonArray repos = parser.fromJson(content, JsonElement.class).getAsJsonArray();
		for (int j = 0; j < repos.size(); j++) {
			JsonObject repo = repos.get(j).getAsJsonObject();
			String name = repo.get("full_name").getAsString();
			boolean forked = repo.get("fork").getAsBoolean();
			if (forked)
				continue;
			outFilePath = outPath + "/" + name;
			//File file = new File(outFilePath);
			if (names.contains(name)){
				names.remove(name);
				continue;
			}
			String[] args = { urlHeader + name + urlFooter, outFilePath };
			RepositoryCloner.clone(args);
			FileIO.writeFileContents(recovory, name + "/n" , true);
		}
	}
}
 
Example #11
Source File: GitUtils.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private static void pull(final Git git, ProgressMonitor monitor)
		throws GitAPIException, WrongRepositoryStateException,
		InvalidConfigurationException, InvalidRemoteException, CanceledException, RefNotFoundException,
		RefNotAdvertisedException, NoHeadException, TransportException {

	git.pull().setTransportConfigCallback(TRANSPORT_CALLBACK).setProgressMonitor(monitor).call();
}
 
Example #12
Source File: GitUtils.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private static void pull(final Git git, IProgressMonitor monitor)
		throws GitAPIException, WrongRepositoryStateException,
		InvalidConfigurationException, InvalidRemoteException, CanceledException, RefNotFoundException,
		RefNotAdvertisedException, NoHeadException, TransportException {

	@SuppressWarnings("restriction")
	ProgressMonitor gitMonitor = (null == monitor) ? createMonitor()
			: new org.eclipse.egit.core.EclipseGitProgressTransformer(monitor);
	pull(git, gitMonitor);
}
 
Example #13
Source File: JGitUtil.java    From mcg-helper with Apache License 2.0 5 votes vote down vote up
public static boolean pull(String projectPath, String branch, String user, String pwd) throws IOException, WrongRepositoryStateException, InvalidConfigurationException, InvalidRemoteException, CanceledException, RefNotFoundException, RefNotAdvertisedException, NoHeadException, TransportException, GitAPIException {

		try (Git git = Git.open(new File(projectPath)) ) {
			UsernamePasswordCredentialsProvider provider = new UsernamePasswordCredentialsProvider(user, pwd);
			git.pull().setRemoteBranchName(branch)
					.setCredentialsProvider(provider)
					.setProgressMonitor(new PullProgressMonitor())
					.call();
		}
		
		return true;
	}
 
Example #14
Source File: CreatureLab.java    From BowlerStudio with GNU General Public License v3.0 4 votes vote down vote up
public void setGitCadEngine(String gitsId, String file, DHParameterKinematics dh)
		throws InvalidRemoteException, TransportException, GitAPIException, IOException {
	baseManager.setGitCadEngine(gitsId, file, dh);
}
 
Example #15
Source File: GitControl.java    From juneau with Apache License 2.0 4 votes vote down vote up
public void pullFromRepo()
		throws IOException, WrongRepositoryStateException, InvalidConfigurationException, DetachedHeadException,
		InvalidRemoteException, CanceledException, RefNotFoundException, NoHeadException, GitAPIException {
	git.pull().call();
}
 
Example #16
Source File: CreatureLab.java    From BowlerStudio with GNU General Public License v3.0 4 votes vote down vote up
public void setGitCadEngine(String gitsId, String file, MobileBase device)
		throws InvalidRemoteException, TransportException, GitAPIException, IOException {
	baseManager.setGitCadEngine(gitsId, file, device);
}
 
Example #17
Source File: MobleBaseMenueFactory.java    From BowlerStudio with GNU General Public License v3.0 4 votes vote down vote up
private static void openCadTab(CreatureLab creatureLab, String gitsId, String file)
		throws InvalidRemoteException, TransportException, GitAPIException, IOException {
	File code = ScriptingEngine.fileFromGit(gitsId, file);
	ScriptingFileWidget wid = BowlerStudio.createFileTab(code);

}
 
Example #18
Source File: GitPullTests.java    From nano-framework with Apache License 2.0 4 votes vote down vote up
@Test
public void pullTest() throws InvalidRemoteException, TransportException, GitAPIException, IOException {
    GitPull.create().quickPull();
}
 
Example #19
Source File: GitUtils.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private static void pull(final Git git) throws GitAPIException, WrongRepositoryStateException,
		InvalidConfigurationException, InvalidRemoteException, CanceledException, RefNotFoundException,
		RefNotAdvertisedException, NoHeadException, TransportException {

	pull(git, (ProgressMonitor) null);
}
 
Example #20
Source File: JGitEnvironmentRepositoryTests.java    From spring-cloud-config with Apache License 2.0 4 votes vote down vote up
@Override
public Git call() throws GitAPIException, InvalidRemoteException {
	return this.mockGit;
}
 
Example #21
Source File: GitWorkflowRepositoryTest.java    From copper-engine with Apache License 2.0 4 votes vote down vote up
@Test(expected = InvalidRemoteException.class)
public void changeURITest() throws Exception {
    wfRepo.setOriginURI(wfRepo.getOriginUri() + "ERROR_TEST");
    defaultBranchTest();
}