Tabnine Logo
org.eclipse.jgit.api
Code IndexAdd Tabnine to your IDE (free)

How to use org.eclipse.jgit.api

Best Java code snippets using org.eclipse.jgit.api (Showing top 20 results out of 1,737)

origin: gocd/gocd

public boolean isRepositoryCorrupted() {
  boolean result = false;
  try {
    git.status().call();
  } catch (Exception e) {
    result = true;
  }
  return result;
}
origin: gocd/gocd

public Properties getStatistics() throws GitAPIException {
  // not inside a doLocked/synchronized block because we don't want to block the server status service.
  return git.gc().getStatistics();
}
origin: gocd/gocd

Iterable<RevCommit> revisions() throws GitAPIException {
  LogCommand command = git.log();
  return command.call();
}
origin: apache/incubator-gobblin

private void addNode(File nodeDir, File nodeFile, String fileContents) throws IOException, GitAPIException {
 createNewFile(nodeDir, nodeFile, fileContents);
 // add, commit, push node
 this.gitForPush.add().addFilepattern(formNodeFilePath(nodeDir.getName(), nodeFile.getName())).call();
 this.gitForPush.commit().setMessage("Node commit").call();
 this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call();
}
origin: gocd/gocd

  public void run() throws Exception {
    addCommand.addFilepattern(CRUISE_CONFIG_XML).call();
    git.commit().setAuthor(rev.getUsername(), STUDIOS_PRODUCT).setMessage(rev.getComment()).call();
  }
});
origin: gocd/gocd

@Test
public void shouldSwitchToMasterAndDeleteTempBranches() throws Exception, GitAPIException {
  configRepo.checkin(goConfigRevision("v1", "md5-1"));
  configRepo.createBranch(ConfigRepository.BRANCH_AT_HEAD, configRepo.getCurrentRevCommit());
  configRepo.createBranch(ConfigRepository.BRANCH_AT_REVISION, configRepo.getCurrentRevCommit());
  configRepo.git().checkout().setName(ConfigRepository.BRANCH_AT_REVISION).call();
  assertThat(configRepo.git().getRepository().getBranch(), is(ConfigRepository.BRANCH_AT_REVISION));
  assertThat(configRepo.git().branchList().call().size(), is(3));
  configRepo.cleanAndResetToMaster();
  assertThat(configRepo.git().getRepository().getBranch(), is("master"));
  assertThat(configRepo.git().branchList().call().size(), is(1));
}
origin: gocd/gocd

private void checkout(String branchName) throws GitAPIException {
  try {
    git.checkout().setName(branchName).call();
  } catch (GitAPIException e) {
    LOGGER.error("[CONFIG_MERGE] Checkout to branch {} failed", branchName, e);
    throw e;
  }
}
origin: gocd/gocd

  public Long commitCountOnMaster() throws GitAPIException, IncorrectObjectTypeException, MissingObjectException {
    // not inside a doLocked/synchronized block because we don't want to block the server status service.
    // we do a `git branch` because we switch branches as part of normal git operations,
    // and we don't care about number of commits on those branches.
    List<Ref> branches = git.branchList().call();
    for (Ref branch : branches) {
      if (branch.getName().equals("refs/heads/master")) {
        Iterable<RevCommit> commits = git.log().add(branch.getObjectId()).call();
        long count = 0;
        for (RevCommit commit : commits) {
          count++;
        }
        return count;
      }
    }
    return Long.valueOf(-1);
  }
}
origin: jphp-group/jphp

@Signature
public void __construct(File directory, boolean create) throws IOException, GitAPIException {
  try {
    __wrappedObject = Git.open(directory, FS.DETECTED);
  } catch (RepositoryNotFoundException e) {
    if (create) {
      Git.init().setBare(false).setDirectory(directory).call();
      __wrappedObject = Git.open(directory, FS.DETECTED);
    }
  }
}
origin: spring-cloud/spring-cloud-config

private void trackBranch(Git git, CheckoutCommand checkout, String label) {
  checkout.setCreateBranch(true).setName(label)
      .setUpstreamMode(SetupUpstreamMode.TRACK)
      .setStartPoint("origin/" + label);
}
origin: gocd/gocd

void createBranch(String branchName, RevCommit revCommit) throws GitAPIException {
  try {
    git.branchCreate().setName(branchName).setStartPoint(revCommit).call();
  } catch (GitAPIException e) {
    LOGGER.error("[CONFIG_MERGE] Failed to create branch {} at revision {}", branchName, revCommit.getId(), e);
    throw e;
  }
}
origin: gocd/gocd

  private List<Ref> getAllBranches() throws GitAPIException {
    return configRepo.git().branchList().setListMode(ListBranchCommand.ListMode.ALL).call();
  }
}
origin: gocd/gocd

void deleteBranch(String branchName) throws GitAPIException {
  try {
    git.branchDelete().setBranchNames(branchName).setForce(true).call();
  } catch (GitAPIException e) {
    LOGGER.error("[CONFIG_MERGE] Failed to delete branch {}", branchName, e);
    throw e;
  }
}
origin: spring-cloud/spring-cloud-config

  public CloneCommand getCloneCommandByCloneRepository() {
    CloneCommand command = Git.cloneRepository();
    return command;
  }
}
origin: jphp-group/jphp

@Signature
public void rm(String filePattern, boolean cached) throws GitAPIException {
  getWrappedObject()
      .rm()
      .addFilepattern(filePattern)
      .setCached(cached)
      .call();
}
origin: jphp-group/jphp

@Signature
public List<String> branchDelete(String[] names, boolean force) throws GitAPIException {
  DeleteBranchCommand command = getWrappedObject().branchDelete();
  command.setBranchNames(names);
  return command.call();
}
origin: spring-cloud/spring-cloud-config

public Git getGitByOpen(File file) throws IOException {
  Git git = Git.open(file);
  return git;
}
origin: apache/incubator-gobblin

private void addEdge(File edgeDir, File edgeFile, String fileContents) throws IOException, GitAPIException {
 createNewFile(edgeDir, edgeFile, fileContents);
 // add, commit, push edge
 this.gitForPush.add().addFilepattern(formEdgeFilePath(edgeDir.getParentFile().getName(), edgeDir.getName(), edgeFile.getName())).call();
 this.gitForPush.commit().setMessage("Edge commit").call();
 this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call();
}
origin: spring-cloud/spring-cloud-config

private Ref checkout(Git git, String label) throws GitAPIException {
  CheckoutCommand checkout = git.checkout();
  if (shouldTrack(git, label)) {
    trackBranch(git, checkout, label);
  }
  else {
    // works for tags and local branches
    checkout.setName(label);
  }
  return checkout.call();
}
origin: gocd/gocd

private String getLatestConfigAt(String branchName) throws GitAPIException, IOException {
  configRepo.git().checkout().setName(branchName).call();
  String content = configRepo.getCurrentRevision().getContent();
  configRepo.git().checkout().setName("master").call();
  return content;
}
org.eclipse.jgit.api

Most used classes

  • Git
    Offers a "GitPorcelain"-like API to interact with a git repository. The GitPorcelain commands are de
  • CloneCommand
    Clone a repository into a new working directory
  • CommitCommand
    A class used to execute a Commit command. It has setters for all supported options and arguments of
  • AddCommand
    A class used to execute a Add command. It has setters for all supported options and arguments of thi
  • CheckoutCommand
    Checkout a branch to the working tree. Examples (git is a Git instance): Check out an existing bra
  • LogCommand,
  • FetchCommand,
  • StatusCommand,
  • Status,
  • InitCommand,
  • PullCommand,
  • ListBranchCommand,
  • ResetCommand,
  • CreateBranchCommand,
  • RmCommand,
  • GitAPIException,
  • DeleteBranchCommand,
  • TagCommand,
  • DiffCommand
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now