diff options
author | James Moger <james.moger@gitblit.com> | 2013-07-03 11:11:48 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-07-03 11:11:48 -0400 |
commit | 5c5b7a8659851abc6ce1654414ceeef2e7f9c803 (patch) | |
tree | c5c0650883dc81a1e8faaef2919f764d1316be9d /src/main/java/com/gitblit/utils/JGitUtils.java | |
parent | d9d4677aa4f4774dddd57a6a9aef28931c8f3f5e (diff) | |
download | gitblit-5c5b7a8659851abc6ce1654414ceeef2e7f9c803.tar.gz gitblit-5c5b7a8659851abc6ce1654414ceeef2e7f9c803.zip |
Set author as tooltip of "last change" on repositories page (issue-238)
Diffstat (limited to 'src/main/java/com/gitblit/utils/JGitUtils.java')
-rw-r--r-- | src/main/java/com/gitblit/utils/JGitUtils.java | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java index 9dabebe6..8676d748 100644 --- a/src/main/java/com/gitblit/utils/JGitUtils.java +++ b/src/main/java/com/gitblit/utils/JGitUtils.java @@ -439,39 +439,56 @@ public class JGitUtils { }
return false;
}
+
+ /**
+ * Encapsulates the result of cloning or pulling from a repository.
+ */
+ public static class LastChange {
+ public Date when;
+ public String who;
+
+ LastChange() {
+ when = new Date(0);
+ }
+
+ LastChange(long lastModified) {
+ this.when = new Date(lastModified);
+ }
+ }
/**
- * Returns the date of the most recent commit on a branch. If the repository
- * does not exist Date(0) is returned. If it does exist but is empty, the
- * last modified date of the repository folder is returned.
+ * Returns the date and author of the most recent commit on a branch. If the
+ * repository does not exist Date(0) is returned. If it does exist but is
+ * empty, the last modified date of the repository folder is returned.
*
* @param repository
- * @return
+ * @return a LastChange object
*/
- public static Date getLastChange(Repository repository) {
+ public static LastChange getLastChange(Repository repository) {
if (!hasCommits(repository)) {
// null repository
if (repository == null) {
- return new Date(0);
+ return new LastChange();
}
// fresh repository
- return new Date(repository.getDirectory().lastModified());
+ return new LastChange(repository.getDirectory().lastModified());
}
List<RefModel> branchModels = getLocalBranches(repository, true, -1);
if (branchModels.size() > 0) {
// find most recent branch update
- Date lastChange = new Date(0);
+ LastChange lastChange = new LastChange();
for (RefModel branchModel : branchModels) {
- if (branchModel.getDate().after(lastChange)) {
- lastChange = branchModel.getDate();
+ if (branchModel.getDate().after(lastChange.when)) {
+ lastChange.when = branchModel.getDate();
+ lastChange.who = branchModel.getAuthorIdent().getName();
}
}
return lastChange;
}
// default to the repository folder modification date
- return new Date(repository.getDirectory().lastModified());
+ return new LastChange(repository.getDirectory().lastModified());
}
/**
|