public Git call(final GitOperationsStep gitOperationsStep, Git git, CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder) throws IllegalArgumentException, IOException, NoFilepatternException, GitAPIException { CheckoutCommand cc = git.checkout().setAllPaths(this.allPaths) .setForce(this.force); if (!Const.isEmpty(this.path)) { cc = cc.addPath(gitOperationsStep.environmentSubstitute(this.path)); } if (!Const.isEmpty(this.name)) { cc = cc.setName(gitOperationsStep.environmentSubstitute(this.name)); } if (!Const.isEmpty(this.startPoint)) { cc = cc.setStartPoint(gitOperationsStep .environmentSubstitute(this.startPoint)); } cc.call(); return git; }
public static void updateProjectRef(ObjectId treeId, ObjectInserter objectInserter, Repository repository, CurrentUser currentUser) throws IOException, NoFilepatternException, GitAPIException { // Create a branch Ref gerritCiRef = repository.getRef("refs/meta/gerrit-ci"); CommitBuilder commitBuilder = new CommitBuilder(); commitBuilder.setTreeId(treeId); logger.info("treeId: " + treeId); if (gerritCiRef != null) { ObjectId prevCommit = gerritCiRef.getObjectId(); logger.info("prevCommit: " + prevCommit); commitBuilder.setParentId(prevCommit); } // build commit logger.info("Adding git tree : " + treeId); commitBuilder.setMessage("Modify project build rules."); final IdentifiedUser iUser = (IdentifiedUser) currentUser; PersonIdent user = new PersonIdent(currentUser.getUserName(), iUser.getEmailAddresses().iterator().next()); commitBuilder.setAuthor(user); commitBuilder.setCommitter(user); ObjectId commitId = objectInserter.insert(commitBuilder); objectInserter.flush(); logger.info(" Making new commit: " + commitId); RefUpdate newRef = repository.updateRef("refs/meta/gerrit-ci"); newRef.setNewObjectId(commitId); newRef.update(); repository.close(); }
public Git call(final GitOperationsStep gitOperationsStep, Git git, CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder) throws IllegalArgumentException, IOException, NoFilepatternException, GitAPIException { AddCommand ac = git.add(); if (!Const.isEmpty(this.filepattern)) { ac = ac.addFilepattern(gitOperationsStep .environmentSubstitute(this.filepattern)); } ac.setUpdate(update).call(); return git; }
public List<String[]> call(final GitInfoStep gitInfoStep, Git git, CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder) throws IllegalArgumentException, IOException, NoFilepatternException, GitAPIException { final List<String[]> resp = new ArrayList<String[]>(); final String[] branch = new String[] {git.getRepository().getBranch()}; resp.add(branch); return resp; }
@Test public void testStableIsDirty() throws NoFilepatternException, IOException, GitAPIException { tag("0.1.0"); dirtyRepo(); Assert.assertEquals( "0.1.0+dirty", versionFactory.createVersion(repo, null).toString()); }
Git call(final GitOperationsStep gitOperationsStep, Git git, CredentialsProvider cp, String gitRepoUrl, File gitRepoFolderPath) throws IllegalArgumentException, IOException, NoFilepatternException, GitAPIException;
public List<String[]> call(final GitInfoStep gitInfoStep, Git git, CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder) throws IllegalArgumentException, IOException, NoFilepatternException, GitAPIException { final List<String[]> tags = new ArrayList<String[]>(); final List<Ref> refTags = git.tagList().call(); for (Ref refTag : refTags) { final String[] tag = new String[] {null, null, null, null, null, null, null, null, null, null}; tag[0] = refTag.getObjectId().getName(); // Id tag[1] = refTag.getName(); // Name final RevObject object = new RevWalk(git.getRepository()) .parseAny(refTag.getObjectId()); if (object instanceof RevCommit) { tag[2] = ((RevCommit) object).getFullMessage(); // Commit // message tag[3] = ((RevCommit) object).getShortMessage(); // Commit // message tag[4] = dt.format(((RevCommit) object).getAuthorIdent() .getWhen()); // Author Date tag[5] = ((RevCommit) object).getAuthorIdent().getName(); // Author // name tag[6] = ((RevCommit) object).getAuthorIdent() .getEmailAddress(); // Author email tag[7] = dt.format(((RevCommit) object).getCommitterIdent() .getWhen()); // Committer Date tag[8] = ((RevCommit) object).getCommitterIdent().getName(); // Committer // name tag[9] = ((RevCommit) object).getCommitterIdent() .getEmailAddress(); // Committer email } tags.add(tag); } return tags; }
private void addFile(String path, String content) throws IOException, NoFilepatternException, GitAPIException{ File absoluteFile = new File(temporaryFolder.getRoot(), path); FileUtils.write(absoluteFile, content); git.add().addFilepattern(path).call(); }
private void deleteFile(String path) throws IOException, NoFilepatternException, GitAPIException{ git.rm().addFilepattern(path).call(); }
private void dirtyRepo() throws IOException, NoFilepatternException, GitAPIException { new File(repo.getDirectory().getParent(), "hello.txt").createNewFile(); git.add().addFilepattern("hello.txt").call(); }