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