Example usage for org.eclipse.jgit.storage.file FileRepositoryBuilder FileRepositoryBuilder

List of usage examples for org.eclipse.jgit.storage.file FileRepositoryBuilder FileRepositoryBuilder

Introduction

In this page you can find the example usage for org.eclipse.jgit.storage.file FileRepositoryBuilder FileRepositoryBuilder.

Prototype

FileRepositoryBuilder

Source Link

Usage

From source file:eu.trentorise.opendata.josman.test.GitTest.java

@Test
public void testWalkRepo() throws IOException {
    File repoFile = createJosmanSampleRepo();

    FileRepositoryBuilder builder = new FileRepositoryBuilder();
    Repository repo = builder.setGitDir(repoFile).readEnvironment() // scan environment GIT_* variables
            .findGitDir() // scan up the file system tree
            .build();/*from   w  w w  .j a  v a2s  . c  o  m*/

    //printFile(repo, tree, "*a.*");
    printDirectory(repo, "master", "src");

    // there is also FileMode.SYMLINK for symbolic links, but this is not handled here yet
    repo.close();
}

From source file:fi.otavanopisto.changelogger.Changelogger.java

private static void prependLine(String line, String message) throws IOException, GitAPIException {
    FileRepositoryBuilder frBuilder = new FileRepositoryBuilder();
    Repository repository = frBuilder.setGitDir(new File("./.git")).readEnvironment().build();
    Git git = new Git(repository);

    git.reset().setMode(ResetCommand.ResetType.HARD).call();
    git.clean().call();//from w  w  w  . j a va  2  s . c om
    git.fetch().call();
    git.pull().call();

    File file = new File(CHANGELOG_FILE);
    List<String> lines = FileUtils.readLines(file, Charsets.UTF_8);
    lines.add(0, line);
    FileUtils.writeLines(file, lines);

    git.commit().setMessage(message).setAuthor("Changelogger", "changelogger@otavanopisto.fi").call();

    git.push().call();
}

From source file:fi.otavanopisto.santra.Santra.java

License:Open Source License

private void reload(String botName) throws IOException, GitAPIException {
    log.info("Starting bot reload");
    FileRepositoryBuilder builder = new FileRepositoryBuilder();
    Repository repository = builder.setGitDir(new File(arguments.getBasePath() + "/.git")).readEnvironment()
            .build();//w  ww  . j  a  v  a2  s .  co  m
    log.info("Starting repository update");
    Git git = new Git(repository);
    git.reset().setMode(ResetCommand.ResetType.HARD).call();
    log.info("Reset complete");
    git.clean().call();
    log.info("Clean compete");
    git.fetch().call();
    log.info("Fetch complete");
    git.pull().call();
    log.info("Repository update finished");

    initBot(botName);
    log.info("Bot reloaded");
}

From source file:fr.brouillard.oss.jgitver.GitVersionCalculator.java

License:Apache License

private Repository openRepository() throws IOException {
    FileRepositoryBuilder builder = new FileRepositoryBuilder();
    return builder.findGitDir(gitRepositoryLocation).build();
}

From source file:fr.brouillard.oss.jgitver.strategy.configurable.defaults.Scenario10WithDefaultsTest.java

License:Apache License

/**
 * Prepare common variables to access the git repository.
 * //from  w w  w  .j a  v a 2  s .  com
 * @throws IOException if a disk error occurred
 */
@Before
public void init() throws IOException {
    repository = new FileRepositoryBuilder().setGitDir(scenario.getRepositoryLocation()).build();
    git = new Git(repository);
    versionCalculator = GitVersionCalculator.location(scenario.getRepositoryLocation());

    // reset the head to master
    unchecked(() -> git.checkout().setName("master").call());
}

From source file:fr.brouillard.oss.jgitver.strategy.configurable.inc.Scenario1AutoIncTest.java

License:Apache License

/**
 * Prepare common variables to access the git repository.
 * @throws IOException if a disk error occurred
 *//*from   w  w  w  . j  a v  a 2 s  . c  o  m*/
@Before
public void init() throws IOException {
    repository = new FileRepositoryBuilder().setGitDir(scenario.getRepositoryLocation()).build();
    git = new Git(repository);
    versionCalculator = GitVersionCalculator.location(scenario.getRepositoryLocation())
            .setAutoIncrementPatch(true);

    // reset the head to master
    unchecked(() -> git.checkout().setName("master").call());
}

From source file:fr.brouillard.oss.jgitver.strategy.configurable.others.Scenario5WithMasterAndIntBranchesNonQualifiedTest.java

License:Apache License

/**
 * Prepare common variables to access the git repository.
 * //from   w  w  w.j a v a2s  .c  o m
 * @throws IOException if a disk error occurred
 */
@Before
public void init() throws IOException {
    repository = new FileRepositoryBuilder().setGitDir(scenario.getRepositoryLocation()).build();
    git = new Git(repository);
    versionCalculator = GitVersionCalculator.location(scenario.getRepositoryLocation())
            .setNonQualifierBranches("master,int");

    // reset the head to master
    unchecked(() -> git.checkout().setName("master").call());
}

From source file:fr.brouillard.oss.jgitver.strategy.configurable.others.Scenario8WithLongFormatTest.java

License:Apache License

/**
 * Prepare common variables to access the git repository.
 * //  ww w .j a  v  a 2s  . com
 * @throws IOException if a disk error occurred
 */
@Before
public void init() throws IOException {
    repository = new FileRepositoryBuilder().setGitDir(scenario.getRepositoryLocation()).build();
    git = new Git(repository);
    versionCalculator = GitVersionCalculator.location(scenario.getRepositoryLocation());
    versionCalculator.setUseGitCommitId(true);
    versionCalculator.setUseLongFormat(true);
    versionCalculator.setGitCommitIdLength(8);
    versionCalculator.setUseDistance(true);

    // reset the head to master
    unchecked(() -> git.checkout().setName("master").call());
}

From source file:fr.brouillard.oss.jgitver.strategy.configurable.others.Scenario8WithoutGPrefixCommitTest.java

License:Apache License

/**
 * Prepare common variables to access the git repository.
 *
 * @throws IOException if a disk error occurred
 *///  w w w.  j a  v  a 2  s  .  c o  m
@Before
public void init() throws IOException {
    repository = new FileRepositoryBuilder().setGitDir(scenario.getRepositoryLocation()).build();
    git = new Git(repository);
    versionCalculator = GitVersionCalculator.location(scenario.getRepositoryLocation());
    versionCalculator.setMavenLike(false);
    versionCalculator.setAutoIncrementPatch(true);
    versionCalculator.setUseGitCommitId(true);
    versionCalculator.setUseLongFormat(false); // without using the new format
    versionCalculator.setGitCommitIdLength(8);
    versionCalculator.setUseDistance(false);

    // reset the head to master
    unchecked(() -> git.checkout().setName("master").call());
}

From source file:fr.brouillard.oss.jgitver.strategy.maven.defaults.Scenario10WithDefaultsTest.java

License:Apache License

/**
 * Prepare common variables to access the git repository.
 * /*from   w ww  .  j a  v a  2  s.  c o m*/
 * @throws IOException if a disk error occurred
 */
@Before
public void init() throws IOException {
    repository = new FileRepositoryBuilder().setGitDir(scenario.getRepositoryLocation()).build();
    git = new Git(repository);
    versionCalculator = GitVersionCalculator.location(scenario.getRepositoryLocation()).setMavenLike(true);

    // reset the head to master
    unchecked(() -> git.checkout().setName("master").call());
}