The Unified and Autonomous Development Platform
Fix the issue that branches page throws exception when switching base branches.
robin shinefcc07fa003ee
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/branches/RepoBranchesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/branches/RepoBranchesPage.javaindex 0d0dc7c8db..a171e5ae46 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/branches/RepoBranchesPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/branches/RepoBranchesPage.java@@ -218,12 +218,12 @@ public class RepoBranchesPage extends RepositoryPage {@Overridepublic String getObject() {- return new RepoAndBranch(getRepository(), getBaseBranch()).getId();+ return getBaseBranch();}@Overridepublic void setObject(String object) {- baseBranch = new RepoAndBranch(object).getBranch();+ baseBranch = object;}}, new BranchChoiceProvider(repoModel), false).add(new AjaxFormComponentUpdatingBehavior("change") {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.javaindex 3ab72c4d77..e656dbac70 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java@@ -182,12 +182,29 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {throw new RestartResponseException(NoCommitsPage.class, paramsOf(getRepository()));trait.repoId = getRepository().getId();- blobIdent.revision = GitUtils.normalizePath(params.get(PARAM_REVISION).toString());- if (blobIdent.revision == null)- blobIdent.revision = getRepository().getDefaultBranch();- trait.revision = blobIdent.revision;+ commentId = params.get(PARAM_COMMENT).toOptionalLong();+ blobIdent.revision = params.get(PARAM_REVISION).toString();blobIdent.path = GitUtils.normalizePath(params.get(PARAM_PATH).toString());++ Comment comment = commentModel.getObject();+ if (comment != null) {+ if (blobIdent.revision != null || blobIdent.path != null)+ throw new IllegalArgumentException("Revision or path should not be specified if comment is specified");+ blobIdent = comment.getBlobIdent();+ } else {+ requestId = params.get(PARAM_REQUEST).toOptionalLong();++ blobIdent.revision = GitUtils.normalizePath(params.get(PARAM_REVISION).toString());+ if (blobIdent.revision == null)+ blobIdent.revision = getRepository().getDefaultBranch();++ if (requestId != null && !GitUtils.isHash(blobIdent.revision))+ throw new IllegalArgumentException("Pull request can only be associated with a hash revision");+ }++ trait.revision = blobIdent.revision;+if (blobIdent.path != null) {try ( FileRepository jgitRepo = getRepository().openAsJGitRepo();RevWalk revWalk = new RevWalk(jgitRepo)) {@@ -212,12 +229,6 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {if (highlightStr != null)highlight = new Highlight(highlightStr);- commentId = params.get(PARAM_COMMENT).toOptionalLong();- requestId = params.get(PARAM_REQUEST).toOptionalLong();-- if ((requestId != null || commentId != null) && !GitUtils.isHash(blobIdent.revision))- throw new IllegalArgumentException("Pull request can only be associated with a hash revision");-queryHits = WebSession.get().getMetaData(SEARCH_RESULT_KEY);if (queryHits != null) {WebSession.get().setMetaData(SEARCH_RESULT_KEY, null);