- Support header color customizations (issue 209)\r
- Support username substitution in web.otherUrls (issue 213)\r
- Option to force client-side basic authentication instead of form-based authentication if web.authenticateViewPages=true (issue 222)\r
+ - Set author as tooltip of last change column in the repositories panel (issue-238)\r
- Setting to automatically create an user account based on an authenticated user principal from the servlet container (issue-246)\r
- Added WindowsUserService to authenticate users against Windows accounts (issue-250)\r
- Global and per-repository setting to exclude authors from metrics (issue-251)\r
import com.gitblit.utils.FederationUtils;
import com.gitblit.utils.HttpUtils;
import com.gitblit.utils.JGitUtils;
+import com.gitblit.utils.JGitUtils.LastChange;
import com.gitblit.utils.JsonUtils;
import com.gitblit.utils.MetricUtils;
import com.gitblit.utils.ObjectCache;
model.hasCommits = JGitUtils.hasCommits(r);
}
- model.lastChange = JGitUtils.getLastChange(r);
+ LastChange lc = JGitUtils.getLastChange(r);
+ model.lastChange = lc.when;
+ model.lastChangeAuthor = lc.who;
if (!model.skipSizeCalculation) {
ByteFormat byteFormat = new ByteFormat();
model.size = byteFormat.format(calculateSize(model));
model.name = repositoryName;
}
model.hasCommits = JGitUtils.hasCommits(r);
- model.lastChange = JGitUtils.getLastChange(r);
+ LastChange lc = JGitUtils.getLastChange(r);
+ model.lastChange = lc.when;
+ model.lastChangeAuthor = lc.who;
model.projectPath = StringUtils.getFirstPathElement(repositoryName);
StoredConfig config = r.getConfig();
public String description;\r
public List<String> owners;\r
public Date lastChange;\r
+ public String lastChangeAuthor;\r
public boolean hasCommits;\r
public boolean showRemoteBranches;\r
public boolean useTickets;\r
}\r
return false;\r
}\r
+ \r
+ /**\r
+ * Encapsulates the result of cloning or pulling from a repository.\r
+ */\r
+ public static class LastChange {\r
+ public Date when;\r
+ public String who;\r
+ \r
+ LastChange() {\r
+ when = new Date(0); \r
+ }\r
+ \r
+ LastChange(long lastModified) {\r
+ this.when = new Date(lastModified);\r
+ }\r
+ }\r
\r
/**\r
- * Returns the date of the most recent commit on a branch. If the repository\r
- * does not exist Date(0) is returned. If it does exist but is empty, the\r
- * last modified date of the repository folder is returned.\r
+ * Returns the date and author of the most recent commit on a branch. If the\r
+ * repository does not exist Date(0) is returned. If it does exist but is\r
+ * empty, the last modified date of the repository folder is returned.\r
* \r
* @param repository\r
- * @return\r
+ * @return a LastChange object\r
*/\r
- public static Date getLastChange(Repository repository) {\r
+ public static LastChange getLastChange(Repository repository) {\r
if (!hasCommits(repository)) {\r
// null repository\r
if (repository == null) {\r
- return new Date(0);\r
+ return new LastChange();\r
}\r
// fresh repository\r
- return new Date(repository.getDirectory().lastModified());\r
+ return new LastChange(repository.getDirectory().lastModified());\r
}\r
\r
List<RefModel> branchModels = getLocalBranches(repository, true, -1);\r
if (branchModels.size() > 0) {\r
// find most recent branch update\r
- Date lastChange = new Date(0);\r
+ LastChange lastChange = new LastChange(); \r
for (RefModel branchModel : branchModels) {\r
- if (branchModel.getDate().after(lastChange)) {\r
- lastChange = branchModel.getDate();\r
+ if (branchModel.getDate().after(lastChange.when)) {\r
+ lastChange.when = branchModel.getDate();\r
+ lastChange.who = branchModel.getAuthorIdent().getName();\r
}\r
}\r
return lastChange;\r
}\r
\r
// default to the repository folder modification date\r
- return new Date(repository.getDirectory().lastModified());\r
+ return new LastChange(repository.getDirectory().lastModified());\r
}\r
\r
/**\r
add(ownersView);\r
\r
add(WicketUtils.createTimestampLabel("repositoryLastChange",\r
- JGitUtils.getLastChange(r), getTimeZone(), getTimeUtils()));\r
+ JGitUtils.getLastChange(r).when, getTimeZone(), getTimeUtils()));\r
add(new Label("repositorySize", model.size));\r
\r
if (metricsTotal == null) {\r
add(ownersView);\r
\r
add(WicketUtils.createTimestampLabel("repositoryLastChange",\r
- JGitUtils.getLastChange(r), getTimeZone(), getTimeUtils()));\r
+ JGitUtils.getLastChange(r).when, getTimeZone(), getTimeUtils()));\r
add(new Label("repositorySize", getRepositoryModel().size));\r
if (metricsTotal == null) {\r
add(new Label("branchStats", ""));\r
Label lastChangeLabel = new Label("repositoryLastChange", lastChange);\r
row.add(lastChangeLabel);\r
WicketUtils.setCssClass(lastChangeLabel, getTimeUtils().timeAgoCss(entry.lastChange));\r
+ if (!StringUtils.isEmpty(entry.lastChangeAuthor)) {\r
+ WicketUtils.setHtmlTooltip(lastChangeLabel, getString("gb.author") + ": " + entry.lastChangeAuthor);\r
+ }\r
\r
boolean showOwner = user != null && entry.isOwner(user.username);\r
boolean myPersonalRepository = showOwner && entry.isUsersPersonalRepository(user.username);\r
\r
@Test\r
public void testLastCommit() throws Exception {\r
- assertEquals(new Date(0), JGitUtils.getLastChange(null));\r
+ assertEquals(new Date(0), JGitUtils.getLastChange(null).when);\r
\r
Repository repository = GitBlitSuite.getHelloworldRepository();\r
assertTrue(JGitUtils.getCommit(repository, null) != null);\r
- Date date = JGitUtils.getLastChange(repository);\r
+ Date date = JGitUtils.getLastChange(repository).when;\r
repository.close();\r
assertNotNull("Could not get last repository change date!", date);\r
}\r
assertNull(JGitUtils.getFirstCommit(repository, null));\r
assertEquals(folder.lastModified(), JGitUtils.getFirstChange(repository, null)\r
.getTime());\r
- assertEquals(folder.lastModified(), JGitUtils.getLastChange(repository).getTime());\r
+ assertEquals(folder.lastModified(), JGitUtils.getLastChange(repository).when.getTime());\r
assertNull(JGitUtils.getCommit(repository, null));\r
repository.close();\r
RepositoryCache.close(repository);\r