List of usage examples for org.eclipse.jgit.api Git open
public static Git open(File dir) throws IOException
From source file:com.barchart.jenkins.cascade.PluginScmGit.java
License:BSD License
/** * See {@link Git#fetch()}/* www . j ava2 s . c om*/ */ public static FetchResult doFetch(final File workspace, final String remote, final RefSpec spec) { try { final Git git = Git.open(workspace); return git.fetch().setRemote(remote).setRefSpecs(spec).call(); } catch (final Throwable e) { throw new RuntimeException(e); } }
From source file:com.barchart.jenkins.cascade.PluginScmGit.java
License:BSD License
/** * See {@link Git#merge()}/*from w w w.jav a 2 s . c o m*/ */ public static MergeResult doMerge(final File workspace, final ObjectId commit) { try { final Git git = Git.open(workspace); return git.merge().include(commit).call(); } catch (final Throwable e) { throw new RuntimeException(e); } }
From source file:com.barchart.jenkins.cascade.PluginScmGit.java
License:BSD License
/** * See {@link Git#pull()}/* w w w . ja v a2 s. c om*/ */ public static PullResult doPull(final File workspace) { try { final Git git = Git.open(workspace); return git.pull().call(); } catch (final Throwable e) { throw new RuntimeException(e); } }
From source file:com.barchart.jenkins.cascade.PluginScmGit.java
License:BSD License
/** * See {@link Git#push()}// w w w . ja v a 2 s. c om */ public static Iterable<PushResult> doPush(final File workspace, final String remote, final RefSpec spec) { try { final Git git = Git.open(workspace); return git.push().setRemote(remote).setRefSpecs(spec).call(); } catch (final Throwable e) { throw new RuntimeException(e); } }
From source file:com.barchart.jenkins.cascade.PluginScmGit.java
License:BSD License
/** * Verify if workspace has git repository. *///w ww.j a v a 2 s .c o m public static boolean doRepoTest(final File workspace) { try { final Git git = Git.open(workspace); return true; } catch (final RepositoryNotFoundException e) { return false; } catch (final Throwable e) { throw new RuntimeException(e); } }
From source file:com.barchart.jenkins.cascade.PluginScmGit.java
License:BSD License
/** * Reset repository state.//w w w. j a va2s . com */ public static Ref doReset(final File workspace) { try { final Git git = Git.open(workspace); return git.reset().setMode(ResetType.HARD).call(); } catch (final Throwable e) { throw new RuntimeException(e); } }
From source file:com.barchart.jenkins.cascade.PluginScmGit.java
License:BSD License
/** * See {@link Git#status()}/* w ww. j av a 2s .c o m*/ */ public static Status doStatus(final File workspace) { try { final Git git = Git.open(workspace); return git.status().call(); } catch (final Throwable e) { throw new RuntimeException(e); } }
From source file:com.barchart.jenkins.cascade.PluginScmGit.java
License:BSD License
/** * Find reference in repository./* w w w. ja va2 s. c o m*/ */ public static Ref findRef(final File workspace, final String name) { try { final Git git = Git.open(workspace); return git.getRepository().getRef(name); } catch (final Throwable e) { throw new RuntimeException(e); } }
From source file:com.bb.extensions.plugin.unittests.internal.git.GitWrapper.java
License:Open Source License
/** * Opens an existing git repository located in the file system at the given * path (e.g. C:/MyGitRepo).//from ww w .j a v a 2s .com * * @param path * @return The GitWrapper object to interact with the opened git repository. */ public static GitWrapper openRepository(String path) { GitWrapper gitWrapper = new GitWrapper(); File repoDir = new File(path + "/.git"); if (repoDir.exists()) { try { gitWrapper.git = Git.open(repoDir); return gitWrapper; } catch (NoWorkTreeException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return null; }
From source file:com.binarybirchtree.contributionart.Repository.java
License:Open Source License
public Repository(Path directory, String name, String email) throws IOException, GitException { this.directory = directory; this.name = name; this.email = email; try {/*from w w w . ja v a 2 s .com*/ Git.init().setDirectory(directory.toFile()).setBare(false).call(); git = Git.open(directory.toFile()); LOGGER.info(String.format("Initialized Git repository at '%s'.", directory)); } catch (GitAPIException error) { throw new GitException(error.toString()); } }