\r
#### fixes \r
\r
+- Fixed (harmless) nullpointer on pushing to an empty repository (issue 69)\r
- Fixed possible nullpointer from the servlet container on startup (issue 67)\r
- Fixed UTF-8 encoding bug on diff page (issue 66)\r
- Fixed timezone bug on the activity page (issue 54)\r
RepositoryModel model = new RepositoryModel();\r
model.name = repositoryName;\r
model.hasCommits = JGitUtils.hasCommits(r);\r
- model.lastChange = JGitUtils.getLastChange(r, null);\r
+ model.lastChange = JGitUtils.getLastChange(r);\r
model.isBare = r.isBare();\r
StoredConfig config = JGitUtils.readConfig(r);\r
if (config != null) {\r
* last modified date of the repository folder is returned.\r
* \r
* @param repository\r
- * @param branch\r
- * if unspecified, all branches are checked.\r
* @return\r
*/\r
- public static Date getLastChange(Repository repository, String branch) {\r
+ public static Date getLastChange(Repository repository) {\r
if (!hasCommits(repository)) {\r
// null repository\r
if (repository == null) {\r
// fresh repository\r
return new Date(repository.getDirectory().lastModified());\r
}\r
- if (StringUtils.isEmpty(branch)) {\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
- for (RefModel branchModel : branchModels) {\r
- if (branchModel.getDate().after(lastChange)) {\r
- lastChange = branchModel.getDate();\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
+ for (RefModel branchModel : branchModels) {\r
+ if (branchModel.getDate().after(lastChange)) {\r
+ lastChange = branchModel.getDate();\r
}\r
- return lastChange;\r
- } else {\r
- // try to find head\r
- branch = Constants.HEAD;\r
}\r
+ return lastChange;\r
}\r
-\r
- // lookup specified branch\r
- RevCommit commit = getCommit(repository, branch);\r
- return getCommitDate(commit);\r
+ \r
+ // default to the repository folder modification date\r
+ return new Date(repository.getDirectory().lastModified());\r
}\r
\r
/**\r
} else {\r
branchObject = repository.resolve(objectId);\r
}\r
+ if (branchObject == null) {\r
+ return list;\r
+ }\r
\r
RevWalk rw = new RevWalk(repository);\r
rw.markStart(rw.parseCommit(branchObject));\r
add(new Label("repositoryOwner", getRepositoryModel().owner));\r
\r
add(WicketUtils.createTimestampLabel("repositoryLastChange",\r
- JGitUtils.getLastChange(r, null), getTimeZone()));\r
+ JGitUtils.getLastChange(r), getTimeZone()));\r
if (metricsTotal == null) {\r
add(new Label("branchStats", ""));\r
} else {\r
\r
@Test\r
public void testLastCommit() throws Exception {\r
- assertEquals(new Date(0), JGitUtils.getLastChange(null, null));\r
+ assertEquals(new Date(0), JGitUtils.getLastChange(null));\r
\r
Repository repository = GitBlitSuite.getHelloworldRepository();\r
assertTrue(JGitUtils.getCommit(repository, null) != null);\r
- Date date = JGitUtils.getLastChange(repository, null);\r
+ Date date = JGitUtils.getLastChange(repository);\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, null).getTime());\r
+ assertEquals(folder.lastModified(), JGitUtils.getLastChange(repository).getTime());\r
assertNull(JGitUtils.getCommit(repository, null));\r
repository.close();\r
assertTrue(GitBlit.self().deleteRepository(repositoryName));\r