List of usage examples for org.eclipse.jgit.api Git log
public LogCommand log()
From source file:org.enterprisedomain.classmaker.impl.StateImpl.java
License:Apache License
@Override public String initialize(boolean commit) { if (!eIsSet(ClassMakerPackage.STATE__MODEL_NAME)) super.initialize(commit); if (eIsSet(ClassMakerPackage.STATE__PROJECT) && getProject().eIsSet(ClassMakerPackage.Literals.PROJECT__PROJECT_NAME) && ResourceUtils.isProjectExists(getProjectName())) { URI modelURI = getModelURI(); loadResource(modelURI, !eIsSet(ClassMakerPackage.STATE__RESOURCE), true); saveResource();/*from ww w .j ava 2s . c o m*/ setPhase(Stage.MODELED); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); if (commit) try { String[] segments = modelURI.deresolve(URI.createFileURI(root.getRawLocation().toString())) .segments(); String[] path = new String[segments.length - 2]; System.arraycopy(segments, 2, path, 0, segments.length - 2); add(URI.createHierarchicalURI(path, null, null).toString()); String result = commit(); return result; } catch (Exception e) { ClassMakerPlugin.getInstance().getLog().log(ClassMakerPlugin.createErrorStatus(e)); return null; } else { @SuppressWarnings("unchecked") SCMOperator<Git> operator = (SCMOperator<Git>) getProject().getWorkspace().getSCMRegistry() .get(getProjectName()); try { Git git = operator.getRepositorySCM(); Ref branch = git.getRepository().findRef(getRevision().getVersion().toString()); LogCommand log = git.log(); log.add(branch.getObjectId()); Iterable<RevCommit> commits = log.call(); for (RevCommit c : commits) { if (operator.decodeTimestamp(c.getShortMessage()) == getTimestamp()) { String id = c.getId().toString(); getCommitIds().add(id); setCommitId(id); } } } catch (Exception e) { } finally { try { operator.ungetRepositorySCM(); } catch (Exception e) { ClassMakerPlugin.getInstance().getLog().log(ClassMakerPlugin.createErrorStatus(e)); } } getProject().checkout(getRevision().getVersion(), getTimestamp(), getCommitId()); } } return getCommitId(); // $NON-NLS-1$ }
From source file:org.exist.git.xquery.Log.java
License:Open Source License
@Override public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { try {//from w w w . j a va 2 s . co m String localPath = args[0].getStringValue(); if (!(localPath.endsWith("/"))) localPath += File.separator; // Repository localRepo = new FileRepository(localPath + ".git"); // Git git = new Git(localRepo); Git git = Git.open(new Resource(localPath), FS); MemTreeBuilder builder = context.getDocumentBuilder(); AttributesImpl attribs = new AttributesImpl(); attribs.addAttribute(NAMESPACE_URI, "local-path", PREFIX + ":local-path", "CDATA", localPath); int nodeNr = builder.startElement(LOG_ELEMENT, attribs); for (RevCommit commit : git.log().call()) { // commit.getParentCount(); // commit.getParents(); attribs = new AttributesImpl(); attribs.addAttribute(NAMESPACE_URI, "id", PREFIX + ":id", "CDATA", commit.name()); attribs.addAttribute(NAMESPACE_URI, "time", PREFIX + ":time", "CDATA", String.valueOf(commit.getCommitTime() * 1000L)); builder.startElement(COMMIT_ELEMENT, attribs); PersonIdent authorIdent = commit.getAuthorIdent(); builder.startElement(AUTHOR_ELEMENT, null); builder.startElement(AUTHOR_NAME_ELEMENT, null); builder.characters(authorIdent.getName()); builder.endElement(); builder.startElement(AUTHOR_EMAIL_ELEMENT, null); builder.characters(authorIdent.getEmailAddress()); builder.endElement(); builder.endElement(); builder.startElement(MESSAGE_ELEMENT, null); builder.characters(commit.getFullMessage()); builder.endElement(); builder.endElement(); } builder.endElement(); return builder.getDocument().getNode(nodeNr); } catch (Throwable e) { throw new XPathException(this, Module.EXGIT001, e); } }
From source file:org.gitcontrib.dataset.GitRepository.java
License:Apache License
public void navigate(GitCommitWalker logWalker) throws Exception { Repository repository = open();//from www . j a v a 2 s. com try { Git git = new Git(repository); Iterable<RevCommit> commits = git.log().call(); for (RevCommit commit : commits) { logWalker.commitEntry(commit); } } finally { repository.close(); } }
From source file:org.impressivecode.depress.scm.git.GitOnlineLogParser.java
License:Open Source License
private List<GitCommit> processRepo(final String path, final GitParserOptions gitParserOptions) throws IOException, NoHeadException, GitAPIException { Git git = initializeGit(path); List<GitCommit> analyzedCommits = new ArrayList<GitCommit>(); LogCommand log = git.log(); if (gitParserOptions.hasBranch()) { List<Ref> branches = git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call(); Ref branch = null;/* ww w .j a va2 s .c om*/ for (Ref b : branches) { if (b.getName().equals("refs/heads/" + gitParserOptions.getBranch()) || b.getName().equals("refs/remotes/" + gitParserOptions.getBranch())) { branch = b; break; } } if (branch == null) { throw new IOException("Specified branch was not found in git repository"); } log.add(branch.getObjectId()); } Iterable<RevCommit> loglines = log.call(); Iterator<RevCommit> logIterator = loglines.iterator(); while (logIterator.hasNext()) { RevCommit commit = logIterator.next(); GitcommitProcessor proc = new GitcommitProcessor(gitParserOptions, git.getRepository()); proc.setRevCommit(commit); proc.processCommitData(); analyzedCommits.add(proc.getResult()); } return analyzedCommits; }
From source file:org.jboss.as.controller.persistence.AbstractGitPersistenceResourceTestCase.java
License:Apache License
private List<String> listCommits(Git git, String branchName) throws IOException, GitAPIException { List<String> commits = new ArrayList<>(); for (RevCommit commit : git.log().add(git.getRepository().resolve(branchName)).call()) { commits.add(commit.getFullMessage()); }// w ww . j a v a 2s .c om return commits; }
From source file:org.jboss.forge.addon.git.GitUtilsImpl.java
License:Open Source License
@Override public List<String> getLogForCurrentBranch(final Git repo) throws GitAPIException { List<String> results = new ArrayList<>(); Iterable<RevCommit> commits = repo.log().call(); for (RevCommit commit : commits) results.add(commit.getFullMessage()); return results; }
From source file:org.jboss.forge.git.GitUtils.java
License:Open Source License
public static List<String> getLogForCurrentBranch(final Git repo) throws GitAPIException { List<String> results = new ArrayList<String>(); Iterable<RevCommit> commits = repo.log().call(); for (RevCommit commit : commits) results.add(commit.getFullMessage()); return results; }
From source file:org.jboss.forge.git.GitUtils.java
License:Open Source License
public static Iterable<RevCommit> getLogForBranch(final Git repo, String branchName) throws GitAPIException, IOException { String oldBranch = repo.getRepository().getBranch(); repo.checkout().setName(branchName).call(); Iterable<RevCommit> commits = repo.log().call(); repo.checkout().setName(oldBranch).call(); return commits; }
From source file:org.kie.workbench.common.migration.MigrationToolTest.java
License:Apache License
private List<String> getDrlCommitMessages(final Git repo, final String drlLocation) throws GitAPIException { final Iterable<RevCommit> projectCommits = repo.log().addPath(drlLocation).call(); final List<String> commitMessages = new ArrayList<>(); for (RevCommit c : projectCommits) { commitMessages.add(c.getFullMessage()); }/*w w w . jav a 2s . c o m*/ return commitMessages; }
From source file:org.modeshape.connector.git.GitFunction.java
License:Apache License
/** * Add the first page of commits in the history names of the tags as children of the current node. * //from www. j ava2s.c om * @param git the Git object; may not be null * @param spec the call specification; may not be null * @param writer the document writer for the current node; may not be null * @param pageSize the number of commits to include, and the number of commits that will be in the next page (if there are * more commits) * @throws GitAPIException if there is a problem accessing the Git repository */ protected void addCommitsAsChildren(Git git, CallSpecification spec, DocumentWriter writer, int pageSize) throws GitAPIException { // Add commits in the log ... LogCommand command = git.log(); command.setSkip(0); command.setMaxCount(pageSize); // Add the first set of commits ... int actual = 0; String commitId = null; for (RevCommit commit : command.call()) { commitId = commit.getName(); writer.addChild(spec.childId(commitId), commitId); ++actual; } if (actual == pageSize) { // We wrote the maximum number of commits, so there's (probably) another page ... writer.addPage(spec.getId(), commitId, pageSize, PageWriter.UNKNOWN_TOTAL_SIZE); } }