Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do you get the author date and commit date from a JGit RevCommit

Tags:

git

jgit

RevCommit has a getCommitTime() method but it returns an int and it does not have an author time. How can I get the author and commit date from a RevCommit?

like image 506
Coder Avatar asked Sep 26 '12 19:09

Coder


People also ask

How do I change the commit date in Git?

You can use the git show command with the --pretty=fuller flag to check if the commit author date and commit date are different. If the author and commit date are different, you can manually change the commit date in the URL to see the commit details.

How do I get the commit date of a specific commit?

To get the commit date, we can use the log command, with the same arguments as before, but with the addition of -1: The only difference is the -1 parameter, which tells this command to return date information for only 1 commit. Using -2 here would return 2 commits, and so-on.

How do I change the author information used for future commits?

To change the author information that is used for all future commits in the current repository, you can update the git config settings so that they only apply here: To update the author information your computer uses on a global level (e.g. for all repositories), add the --global flag:

How do you view the revision history in Git?

How do you view the revision history in Git? Let’s say you want to view all commits to the Git repository. The git log command returns all of the commits that have been made to the repository. This command lists the latest commits in chronological order, with the latest commit first. The syntax of the git log command is given below −


1 Answers

Like so:

RevCommit commit = ...;

PersonIdent authorIdent = commit.getAuthorIdent();
Date authorDate = authorIdent.getWhen();
TimeZone authorTimeZone = authorIdent.getTimeZone();

PersonIdent committerIdent = commit.getCommitterIdent();
...

Also see API documentation.

like image 54
robinst Avatar answered Oct 23 '22 00:10

robinst