diff options
author | James Moger <james.moger@gitblit.com> | 2014-10-31 09:08:37 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-10-31 09:08:37 -0400 |
commit | 4a2fb11479c9b53ffe4e2e1cca82205ca122753b (patch) | |
tree | 7d1ebc10b7554f2b9c3aa00493d99988ee7ac4cb /src/main | |
parent | 1501a6774ebcb427c50e740f2c4b36f4b8967782 (diff) | |
download | gitblit-4a2fb11479c9b53ffe4e2e1cca82205ca122753b.tar.gz gitblit-4a2fb11479c9b53ffe4e2e1cca82205ca122753b.zip |
Gracefully handle missing integration branch in ticket page
Diffstat (limited to 'src/main')
4 files changed, 25 insertions, 9 deletions
diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java index da51ea98..68c62ead 100644 --- a/src/main/java/com/gitblit/utils/JGitUtils.java +++ b/src/main/java/com/gitblit/utils/JGitUtils.java @@ -2270,7 +2270,7 @@ public class JGitUtils { } public static enum MergeStatus { - NOT_MERGEABLE, FAILED, ALREADY_MERGED, MERGEABLE, MERGED; + MISSING_INTEGRATION_BRANCH, MISSING_SRC_BRANCH, NOT_MERGEABLE, FAILED, ALREADY_MERGED, MERGEABLE, MERGED; } /** @@ -2285,9 +2285,17 @@ public class JGitUtils { public static MergeStatus canMerge(Repository repository, String src, String toBranch) { RevWalk revWalk = null; try { - revWalk = new RevWalk(repository); - RevCommit branchTip = revWalk.lookupCommit(repository.resolve(toBranch)); - RevCommit srcTip = revWalk.lookupCommit(repository.resolve(src)); + revWalk = new RevWalk(repository);
+ ObjectId branchId = repository.resolve(toBranch);
+ if (branchId == null) {
+ return MergeStatus.MISSING_INTEGRATION_BRANCH;
+ }
+ ObjectId srcId = repository.resolve(src);
+ if (srcId == null) {
+ return MergeStatus.MISSING_SRC_BRANCH;
+ }
+ RevCommit branchTip = revWalk.lookupCommit(branchId); + RevCommit srcTip = revWalk.lookupCommit(srcId); if (revWalk.isMergedInto(srcTip, branchTip)) { // already merged return MergeStatus.ALREADY_MERGED; @@ -2300,6 +2308,8 @@ public class JGitUtils { if (canMerge) { return MergeStatus.MERGEABLE; } + } catch (NullPointerException e) {
+ LOGGER.error("Failed to determine canMerge", e);
} catch (IOException e) { LOGGER.error("Failed to determine canMerge", e); } finally {
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties index 5326042a..ce7b5229 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties @@ -749,3 +749,4 @@ gb.sortHighestPriority = highest priority gb.sortLowestPriority = lowest priority gb.sortHighestSeverity = highest severity gb.sortLowestSeverity = lowest severity +gb.missingIntegrationBranchMore = The target integration branch does not exist in the repository!
\ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.html b/src/main/java/com/gitblit/wicket/pages/TicketPage.html index f3c6b2a8..5ae005eb 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.html +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.html @@ -557,7 +557,6 @@ pt push</pre> </div>
</wicket:fragment>
-
<!-- VETOED PATCHSET FRAGMENT -->
<wicket:fragment wicket:id="vetoedFragment">
<div class="alert alert-error submit-info" style="padding:4px;">
diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.java b/src/main/java/com/gitblit/wicket/pages/TicketPage.java index b140bfca..4890874a 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.java @@ -519,10 +519,10 @@ public class TicketPage extends RepositoryPage { * TICKET METADATA
*/
add(new Label("ticketType", ticket.type.toString()));
-
+
add(new Label("priority", ticket.priority.toString()));
add(new Label("severity", ticket.severity.toString()));
-
+
if (StringUtils.isEmpty(ticket.topic)) {
add(new Label("ticketTopic").setVisible(false));
} else {
@@ -531,8 +531,8 @@ public class TicketPage extends RepositoryPage { String safeTopic = app().xssFilter().relaxed(topic);
add(new Label("ticketTopic", safeTopic).setEscapeModelStrings(false));
}
-
-
+
+
/*
@@ -1431,6 +1431,12 @@ public class TicketPage extends RepositoryPage { Fragment mergePanel = new Fragment("mergePanel", "alreadyMergedFragment", this);
mergePanel.add(new Label("mergeTitle", MessageFormat.format(getString("gb.patchsetAlreadyMerged"), ticket.mergeTo)));
return mergePanel;
+ } else if (MergeStatus.MISSING_INTEGRATION_BRANCH == mergeStatus) {
+ // target/integration branch is missing
+ Fragment mergePanel = new Fragment("mergePanel", "notMergeableFragment", this);
+ mergePanel.add(new Label("mergeTitle", MessageFormat.format(getString("gb.patchsetNotMergeable"), ticket.mergeTo)));
+ mergePanel.add(new Label("mergeMore", MessageFormat.format(getString("gb.missingIntegrationBranchMore"), ticket.mergeTo)));
+ return mergePanel;
} else {
// patchset can not be cleanly merged
Fragment mergePanel = new Fragment("mergePanel", "notMergeableFragment", this);
|