From fbe265fa787e4be9cb63c6bae2ef30b9400d9afc Mon Sep 17 00:00:00 2001 From: Simon Harrer <simon.harrer@gmail.com> Date: Thu, 18 Jul 2013 10:11:04 -0400 Subject: [PATCH] Fixes findbugs warning - dereferencing null in exception case --- src/main/java/com/gitblit/GitBlit.java | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java index ca21717..35ef770 100644 --- a/src/main/java/com/gitblit/GitBlit.java +++ b/src/main/java/com/gitblit/GitBlit.java @@ -84,6 +84,7 @@ import com.gitblit.Constants.AccessPermission; import com.gitblit.Constants.AccessRestrictionType; +import com.gitblit.Constants.AccountType; import com.gitblit.Constants.AuthenticationType; import com.gitblit.Constants.AuthorizationControl; import com.gitblit.Constants.FederationRequest; @@ -121,6 +122,7 @@ 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; @@ -694,12 +696,12 @@ public boolean supportsCredentialChanges(UserModel user) { if (user == null) { return false; - } else if (!Constants.EXTERNAL_ACCOUNT.equals(user.password)) { - // credentials likely maintained by Gitblit - return userService.supportsCredentialChanges(); + } else if (AccountType.LOCAL.equals(user.accountType)) { + // local account, we can change credentials + return true; } else { - // credentials are externally maintained - return false; + // external account, ask user service + return userService.supportsCredentialChanges(); } } @@ -1669,7 +1671,9 @@ 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)); @@ -1973,7 +1977,9 @@ 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(); @@ -2047,6 +2053,9 @@ File repoFolder = new File(getRepositoriesFolder(), originRepo); if (repoFolder.exists()) { model.originRepository = originRepo.toLowerCase(); + + // persist the fork origin + updateConfiguration(r, model); } } } catch (URISyntaxException e) { -- Gitblit v1.9.1