List of usage examples for org.eclipse.jgit.api Git commit
public CommitCommand commit()
From source file:org.obiba.opal.core.cfg.OpalViewPersistenceStrategy.java
License:Open Source License
private void doCommitPush(Git git, String message) throws GitAPIException { git.commit().setAuthor(getAuthorName(), "opal@obiba.org").setCommitter("opal", "opal@obiba.org") .setMessage(message).call(); git.push().setPushAll().setRemote("origin").call(); }
From source file:org.ocpsoft.redoculous.tests.asciidoc.AsciidocIncludeTest.java
License:Apache License
@Before public void before() throws IOException, GitAPIException { repository = File.createTempFile("redoc", "ulous-test"); repository.delete();/*from w w w . j a va2 s. c om*/ repository.mkdirs(); File document = new File(repository, "document.asciidoc"); document.createNewFile(); File master = new File(repository, "master.asciidoc"); master.createNewFile(); Files.write(document, getClass().getClassLoader().getResourceAsStream("asciidoc/toc.asciidoc")); Files.write(master, "Somethingn, then...\n" + "include::document.asciidoc[]\n" + ASDF123); Git repo = Git.init().setDirectory(repository).call(); repo.add().addFilepattern("document.asciidoc").call(); repo.add().addFilepattern("master.asciidoc").call(); repo.commit().setMessage("Initial commit.").call(); }
From source file:org.ocpsoft.redoculous.tests.git.InitializeRepositoryTest.java
License:Apache License
@Before public void before() throws IOException, GitAPIException { repository = File.createTempFile("redoc", "ulous-test"); repository.delete();//from www. ja v a2s . c o m repository.mkdirs(); File document = new File(repository, "document.asciidoc"); document.createNewFile(); Files.write(document, getClass().getClassLoader().getResourceAsStream("asciidoc/toc.asciidoc")); Git repo = Git.init().setDirectory(repository).call(); repo.add().addFilepattern("document.asciidoc").call(); repo.commit().setMessage("Initial commit.").call(); }
From source file:org.ocpsoft.redoculous.tests.markdown.MarkdownRenderTest.java
License:Apache License
@Before public void before() throws IOException, GitAPIException { repository = File.createTempFile("redoc", "ulous-test"); repository.delete();//from www . j a va 2 s. c o m repository.mkdirs(); File document = new File(repository, "document.markdown"); document.createNewFile(); Files.write(document, getClass().getClassLoader().getResourceAsStream("markdown/document.markdown")); Git repo = Git.init().setDirectory(repository).call(); repo.add().addFilepattern("document.markdown").call(); repo.commit().setMessage("Initial commit.").call(); }
From source file:org.ocsoft.olivia.models.project.GitManager.java
License:Mozilla Public License
public void commit(String message) throws GitAPIException { Git git = getGitInstance(); CommitCommand commit = git.commit(); commit.setMessage(message).call();/*from w w w . j a v a2 s .c o m*/ }
From source file:org.oneandone.gitter.integration.JGitCommitData.java
License:Apache License
/** Performs a git commit. */ public void commit(Git git) { try {/*from w w w . ja v a 2 s. co m*/ PersonIdent ident = new PersonIdent(user, email, date, TimeZone.getTimeZone("UTC")); git.commit().setAuthor(ident).setMessage(message).call(); } catch (GitAPIException ex) { throw new RuntimeException(ex); } }
From source file:org.openengsb.connector.git.internal.GitServiceImpl.java
License:Apache License
@Override public CommitRef add(String comment, File... file) { if (file.length == 0) { LOGGER.debug("No files to add in list"); return null; }/*from ww w .java2s. co m*/ if (repository == null) { prepareWorkspace(); try { initRepository(); } catch (IOException e) { if (repository != null) { repository.close(); } throw new ScmException(e); } } Git git = new Git(repository); AddCommand add = git.add(); try { for (File toCommit : file) { if (!toCommit.exists()) { throw new ScmException("File " + toCommit + " is not a valid file to commit."); } String filepattern = getRelativePath(toCommit.getAbsolutePath()); LOGGER.debug("Adding file {} in working directory to repository", filepattern); add.addFilepattern(filepattern); } add.call(); LOGGER.debug("Committing added files with comment '{}'", comment); return new GitCommitRef(git.commit().setMessage(comment).call()); } catch (Exception e) { throw new ScmException(e); } }
From source file:org.openengsb.connector.git.internal.GitServiceImpl.java
License:Apache License
@Override public CommitRef remove(String comment, File... file) { if (file.length == 0) { LOGGER.debug("No files to add in list"); return null; }//from www .j a v a 2 s .co m if (repository == null) { prepareWorkspace(); try { initRepository(); } catch (IOException e) { if (repository != null) { repository.close(); repository = null; } throw new ScmException(e); } } Git git = new Git(repository); RmCommand rm = git.rm(); try { for (File toCommit : file) { if (!toCommit.exists()) { throw new ScmException("File " + toCommit + " is not a valid file to commit."); } String filepattern = getRelativePath(toCommit.getAbsolutePath()); LOGGER.debug("Removing file {} in working directory from repository", filepattern); rm.addFilepattern(filepattern); } rm.call(); LOGGER.debug("Committing removed files with comment '{}'", comment); return new GitCommitRef(git.commit().setMessage(comment).call()); } catch (Exception e) { throw new ScmException(e); } }
From source file:org.openengsb.connector.git.internal.GitServiceImplTest.java
License:Apache License
@Test public void exportRepository_shouldReturnZipFileWithRepoEntries() throws Exception { localRepository = RepositoryFixture.createRepository(localDirectory); String dir = "testDirectory"; String file = "myTestFile"; File parent = new File(localDirectory, dir); parent.mkdirs();/* w w w.j a v a2 s. c o m*/ File child = new File(parent, file); FileWriter fw = new FileWriter(child); fw.write(file + "\n"); fw.close(); String pattern = dir + "/" + file; Git git = new Git(localRepository); git.add().addFilepattern(pattern).call(); git.commit().setMessage("My msg").call(); ZipFile zipFile = new ZipFile(service.export()); assertThat(zipFile.getEntry("testfile").getName(), is("testfile")); assertThat(zipFile.getEntry(dir + "/").getName(), is(dir + "/")); assertThat(zipFile.getEntry(dir + File.separator + file).getName(), is(dir + File.separator + file)); }
From source file:org.openengsb.connector.git.internal.GitServiceImplTest.java
License:Apache License
public void exportRepositoryByRef_shouldReturnZipFileWithRepoEntries() throws Exception { localRepository = RepositoryFixture.createRepository(localDirectory); String dir = "testDirectory"; String file = "myTestFile"; File parent = new File(localDirectory, dir); parent.mkdirs();// w w w . jav a 2 s . c o m File child = new File(parent, file); FileWriter fw = new FileWriter(child); fw.write(file + "\n"); fw.close(); String pattern = dir + "/" + file; Git git = new Git(localRepository); git.add().addFilepattern(pattern).call(); git.commit().setMessage("My msg").call(); AnyObjectId headId = localRepository.resolve(Constants.HEAD); RevWalk rw = new RevWalk(localRepository); RevCommit head = rw.parseCommit(headId); rw.release(); ZipFile zipFile = new ZipFile(service.export(new GitCommitRef(head))); assertThat(zipFile.getEntry("testfile").getName(), is("testfile")); assertThat(zipFile.getEntry(dir + "/").getName(), is(dir + "/")); assertThat(zipFile.getEntry(dir + "\\" + file).getName(), is(dir + "\\" + file)); }