Example usage for org.eclipse.jgit.api Git close

List of usage examples for org.eclipse.jgit.api Git close

Introduction

In this page you can find the example usage for org.eclipse.jgit.api Git close.

Prototype

@Override
public void close() 

Source Link

Document

Free resources associated with this instance.

Usage

From source file:org.eclipse.emf.compare.diagram.papyrus.tests.egit.fixture.GitTestRepository.java

License:Open Source License

/**
 * Adds the given resources to the index
 * // w w  w .  ja va  2s . c  om
 * @param resources
 *            Resources to add to the index.
 */
public void removeFromIndex(IResource... resources)
        throws CoreException, IOException, NoFilepatternException, GitAPIException {
    Git git = new Git(repository);
    try {
        for (IResource resource : resources) {
            String repoPath = getRepoRelativePath(resource.getLocation().toString());
            git.rm().addFilepattern(repoPath).call();
        }
    } finally {
        git.close();
    }
}

From source file:org.eclipse.emf.compare.diagram.papyrus.tests.egit.fixture.GitTestRepository.java

License:Open Source License

/**
 * Commits the current index.// w  w w  . ja  va 2 s  .c om
 * 
 * @param message
 *            commit message
 * @return commit object
 */
public RevCommit commit(String message) throws Exception {
    Git git = new Git(repository);
    try {
        CommitCommand commitCommand = git.commit();
        commitCommand.setAuthor("J. Git", "j.git@egit.org");
        commitCommand.setCommitter(commitCommand.getAuthor());
        commitCommand.setMessage(message);
        return commitCommand.call();
    } finally {
        git.close();
    }
}

From source file:org.eclipse.emf.compare.diagram.papyrus.tests.egit.fixture.GitTestRepository.java

License:Open Source License

/**
 * Returns the status of this repository's files as would "git status".
 * //  w w  w  . j av  a2  s  . c om
 * @return
 * @throws Exception
 */
public Status status() throws Exception {
    Git git = new Git(repository);
    try {
        return git.status().call();
    } finally {
        git.close();
    }
}

From source file:org.eclipse.emf.compare.diagram.papyrus.tests.egit.fixture.GitTestRepository.java

License:Open Source License

/**
 * Adds file to version control/*from w w w .  j  av  a  2s .  c om*/
 *
 * @param file
 * @throws IOException
 * @throws GitAPIException
 * @throws NoFilepatternException
 */
public void track(File file) throws IOException, NoFilepatternException, GitAPIException {
    String repoPath = getRepoRelativePath(new Path(file.getPath()).toString());
    Git git = new Git(repository);
    try {
        git.add().addFilepattern(repoPath).call();
    } finally {
        git.close();
    }
}

From source file:org.eclipse.emf.compare.ide.ui.tests.egit.fixture.GitTestRepository.java

License:Open Source License

public RevCommit addAllAndCommit(String commitMessage) throws Exception {
    Git git = new Git(repository);
    try {/*from   www .j  a  v  a  2  s  . co  m*/
        git.add().addFilepattern(".").call();
        return commit(commitMessage);
    } finally {
        git.close();
    }
}

From source file:org.eclipse.emf.compare.ide.ui.tests.git.framework.internal.GitTestSupport.java

License:Open Source License

public Status getStatus() throws Exception {
    Git git = new Git(repository);
    try {/*from   ww  w  .  jav a  2 s . co m*/
        return git.status().call();
    } finally {
        git.close();
    }
}

From source file:org.eclipse.emf.compare.ide.ui.tests.merge.DirCacheResourceVariantTreeProviderTest.java

License:Open Source License

private void addToIndex(Repository repository, IFile file)
        throws CoreException, IOException, NoFilepatternException, GitAPIException {
    String filePath = file.getProject().getName() + "/" + file.getProjectRelativePath(); //$NON-NLS-1$
    Git git = new Git(repository);
    try {//from  w  w w.ja  va2s  . c  o m
        git.add().addFilepattern(filePath).call();
    } finally {
        git.close();
    }
}

From source file:org.eclipse.emf.compare.ide.ui.tests.merge.StrategyRecursiveModelTest.java

License:Open Source License

@Override
@Before// w  w w .java2  s  .  co  m
public void setUp() throws Exception {
    super.setUp();

    iProject = project.getProject();
    repo = RepositoryMapping.getMapping(iProject).getRepository();

    // make initial commit
    Git git = new Git(repo);
    try {
        git.commit().setAuthor("JUnit", "junit@jgit.org").setMessage("Initial commit").call(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    } finally {
        git.close();
    }

    // Select strategy recursive as preferred strategy
    InstanceScope.INSTANCE.getNode(Activator.getPluginId()).put(GitCorePreferences.core_preferredMergeStrategy,
            "model recursive"); //$NON-NLS-1$
}

From source file:org.eclipse.emf.compare.ide.ui.tests.merge.StrategyRecursiveModelWithDeepProjectTest.java

License:Open Source License

@Override
@Before//from w w w  .  ja  v  a  2s .c  o  m
public void setUp() throws Exception {
    super.setUp();
    repository.disconnect(iProject);

    project = new TestProject("a/b/deepProject");
    iProject = project.getProject();
    repository.connect(iProject);
    repo = RepositoryMapping.getMapping(iProject).getRepository();

    // make initial commit
    Git git = new Git(repo);
    try {
        git.commit().setAuthor("JUnit", "junit@jgit.org").setMessage("Initial commit").call();
    } finally {
        git.close();
    }
}

From source file:org.eclipse.emf.compare.ide.ui.tests.merge.VariantsTestCase.java

License:Open Source License

@Before
@Override//from   w w  w. j a  v a2  s  . c o  m
public void setUp() throws Exception {
    super.setUp();

    iProject = project.getProject();
    repo = RepositoryMapping.getMapping(iProject).getRepository();

    // make initial commit
    Git git = new Git(repo);
    try {
        git.commit().setAuthor("JUnit", "junit@jgit.org").setMessage("Initial commit").call();
    } finally {
        git.close();
    }
}