Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » JGit JavaDoc and get log only certain range
JGit JavaDoc and get log only certain range [message #654550] Wed, 16 February 2011 09:38 Go to next message
Peter  is currently offline Peter Friend
Messages: 5
Registered: February 2011
Junior Member
Hi all,
I'm making integrate git scm with my Java application. I decided use a JGit library for this, but I didn't find a JavaDoc for JGit. Where can I find the JavaDoc?
and other questions. How can I make query log in within a certain range. as look like this.
git log --since="Tue Feb 15 13:05:13 2011 +0300"

At the moment I know how get all log from git, but I need get log only certain range.
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.LogCommand;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.eclipse.jgit.revwalk.RevCommit;

import java.io.File;

public class JGitTest {
    public static void main(String[] arg) throws Exception {
        RepositoryBuilder builder = new RepositoryBuilder();
        File repos = new File("/home/pitbull/projects/GitPr");
        Repository repository = builder.findGitDir(repos).build();
        Git git = new Git(repository);
        LogCommand log = git.log();
        for (RevCommit commit : log.call()) {
            System.out.println(commit.getAuthorIdent().getName());
            System.out.println(commit.getAuthorIdent().getWhen());
            System.out.println(commit.getFullMessage());
        }
    }
}

Please I need help.
Thanks.
Re: JGit JavaDoc and get log only certain range [message #654744 is a reply to message #654550] Wed, 16 February 2011 22:15 Go to previous messageGo to next message
Chris Aniszczyk is currently offline Chris AniszczykFriend
Messages: 674
Registered: July 2009
Senior Member
Have you tried LogCommand.addRange(...) ?

/**
* Adds the range {@code since..until}
*
* @param since
* @param until
* @return {@code this}
* @throws MissingObjectException
* the commit supplied is not available from the object
* database. This usually indicates the supplied commit is
* invalid, but the reference was constructed during an earlier
* invocation to {@link RevWalk#lookupCommit(AnyObjectId)}.
* @throws IncorrectObjectTypeException
* the object was not parsed yet and it was discovered during
* parsing that it is not actually a commit. This usually
* indicates the caller supplied a non-commit SHA-1 to
* {@link RevWalk#lookupCommit(AnyObjectId)}.
* @throws JGitInternalException
* a low-level exception of JGit has occurred. The original
* exception can be retrieved by calling
* {@link Exception#getCause()}. Expect only
* {@code IOException's} to be wrapped. Subclasses of
* {@link IOException} (e.g. {@link MissingObjectException}) are
* typically not wrapped here but thrown as original exception
*/
public LogCommand addRange(AnyObjectId since, AnyObjectId until)
throws MissingObjectException, IncorrectObjectTypeException,
JGitInternalException {
return not(since).add(until);
}
Re: JGit JavaDoc and get log only certain range [message #654794 is a reply to message #654550] Thu, 17 February 2011 08:02 Go to previous messageGo to next message
Peter  is currently offline Peter Friend
Messages: 5
Registered: February 2011
Junior Member
Yes I know about this method. but I don't know how can I create new AnyObjectId. Can you show a short example How can I make this?
By the way Where did find a source JGit?
Re: JGit JavaDoc and get log only certain range [message #654813 is a reply to message #654550] Thu, 17 February 2011 09:41 Go to previous messageGo to next message
Manuel Doninger is currently offline Manuel DoningerFriend
Messages: 119
Registered: October 2010
Senior Member
The sourcecode of JGit can be found here: http://egit.eclipse.org/jgit.git
Re: JGit JavaDoc and get log only certain range [message #654875 is a reply to message #654813] Thu, 17 February 2011 13:45 Go to previous messageGo to next message
Peter  is currently offline Peter Friend
Messages: 5
Registered: February 2011
Junior Member
it is cool, Thanks.
Re: JGit JavaDoc and get log only certain range [message #658217 is a reply to message #654875] Mon, 07 March 2011 12:55 Go to previous messageGo to next message
Peter  is currently offline Peter Friend
Messages: 5
Registered: February 2011
Junior Member
Sorry guys. I could not found any solution my problem. I need some help. What Are objects use in addRange. How can I create these are objects?
Re: JGit JavaDoc and get log only certain range [message #658260 is a reply to message #658217] Mon, 07 March 2011 15:35 Go to previous messageGo to next message
Stefan Lay is currently offline Stefan LayFriend
Messages: 342
Registered: July 2009
Senior Member
If you have instances RevCommit you can directy pass them to addRange.

"Peter" <parsentev@yandex.ru> wrote in message
news:il2k7f$q5j$1@news.eclipse.org...
> Sorry guys. I could not found any solution my problem. I need some help.
> What Are objects use in addRange. How can I create these are objects?
Re: JGit JavaDoc and get log only certain range [message #658381 is a reply to message #658260] Tue, 08 March 2011 09:59 Go to previous message
Peter  is currently offline Peter Friend
Messages: 5
Registered: February 2011
Junior Member
Not. I haven't. I need create a new instance from time, which implement AnyObjectId class. But I can't find how I can do it.
Previous Topic:Create Patch (standard format) from History view creates patch relative to a project
Next Topic:'Auto-fetch' for Synchronize View
Goto Forum:
  


Current Time: Tue Apr 23 16:00:52 GMT 2024

Powered by FUDForum. Page generated in 0.03600 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top