org.eclipse.jgit.lib.TextProgressMonitor Java Examples

The following examples show how to use org.eclipse.jgit.lib.TextProgressMonitor. 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: Repository.java    From AndroidProjectCreator with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Function to clone the repository
 *
 * @throws IOException if something goes wrong, this exception is thrown
 */
public void cloneRepository() throws IOException {
    try {
        Git.cloneRepository()
                .setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
                .setURI(url)
                .setDirectory(directory)
                .setBranchesToClone(singleton(branch))
                .setBranch(branch)
                .call();

    } catch (GitAPIException ex) {
        //Because the GitAPIException is abstract and cannot be instantiated, another (similar) exception is used
        throw new IOException("[+]There was an error cloing " + name + ". Verify your internet connection and the permissions of the folder!");
    }
}
 
Example #2
Source File: UpdaterGenerator.java    From neembuu-uploader with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Clone GIT repository from sourceforge.
 *
 * @param gitDirectory The directory of Git.
 */
private void gitClone(File gitDirectory) {
    try {
        git = Git.cloneRepository()
                .setDirectory(gitDirectory)
                .setURI("http://git.code.sf.net/p/neembuuuploader/gitcode")
                .setProgressMonitor(new TextProgressMonitor()).call();

        for (Ref f : git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call()) {
            git.checkout().setName(f.getName()).call();
            System.out.println("checked out branch " + f.getName()
                    + ". HEAD: " + git.getRepository().getRef("HEAD"));
        }
        // try to checkout branches by specifying abbreviated names
        git.checkout().setName("master").call();
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example #3
Source File: UpdaterGenerator.java    From neembuu-uploader with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Clone GIT repository from sourceforge.
 *
 * @param gitDirectory The directory of Git.
 */
private void gitClone(File gitDirectory) {
    try {
        git = Git.cloneRepository()
                .setDirectory(gitDirectory)
                .setURI(env.gitURI())
                //.setURI("http://git.code.sf.net/p/neembuuuploader/gitcode")
                .setProgressMonitor(new TextProgressMonitor()).call();

        for (Ref f : git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call()) {
            git.checkout().setName(f.getName()).call();
            System.out.println("checked out branch " + f.getName()
                    + ". HEAD: " + git.getRepository().getRef("HEAD"));
        }
        // try to checkout branches by specifying abbreviated names
        git.checkout().setName("master").call();
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example #4
Source File: ExtensionPointAction.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
private void doClone() throws GitAPIException, IOException {
    CloneCommand cloneCommand = Git.cloneRepository();

    cloneCommand.setURI(REPOSITORY_URL);

    File repositoryDir = new File(directory, name);
    cloneCommand.setDirectory(repositoryDir);
    cloneCommand.setProgressMonitor(new TextProgressMonitor());

    cloneCommand.call();
    System.out.println("Project directory for project created at " + repositoryDir);

    FileUtils.deleteDirectory(new File(repositoryDir, ".git"));
}
 
Example #5
Source File: GHRule.java    From github-integration-plugin with MIT License 5 votes vote down vote up
public void pushAll() throws GitAPIException {
    git.push()
            .setPushAll()
            .setProgressMonitor(new TextProgressMonitor())
            .setCredentialsProvider(new UsernamePasswordCredentialsProvider(GH_TOKEN, ""))
            .call();
}
 
Example #6
Source File: GHRule.java    From github-integration-plugin with MIT License 5 votes vote down vote up
public void commitFileToBranch(String branch, String fileName, String content, String commitMessage)
        throws IOException, GitAPIException {
    final String beforeBranch = git.getRepository().getBranch();
    final List<Ref> refList = git.branchList().call();
    boolean exist = false;
    for (Ref ref : refList) {
        if (ref.getName().endsWith(branch)) {
            exist = true;
            break;
        }
    }
    if (!exist) {
        git.branchCreate().setName(branch).call();
    }

    git.checkout().setName(branch).call();

    writeStringToFile(new File(gitRootDir, fileName), content);
    git.add().addFilepattern(".").call();
    git.commit().setAll(true).setMessage(commitMessage).call();
    git.push()
            .setPushAll()
            .setProgressMonitor(new TextProgressMonitor())
            .setCredentialsProvider(new UsernamePasswordCredentialsProvider(GH_TOKEN, ""))
            .call();
    git.checkout().setName(beforeBranch).call();

    await().pollInterval(3, SECONDS)
            .timeout(120, SECONDS)
            .until(ghBranchAppeared(getGhRepo(), branch));
}
 
Example #7
Source File: GitUtils.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private static TextProgressMonitor createMonitor() {
	return new TextProgressMonitor(new OutputStreamWriter(System.out));
}