The Unified and Autonomous Development Platform
Able to exclude paths in revision compare page
robin shenf5f7d383a2b0
diff --git a/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.html b/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.htmlindex aeb24f1979..ceacdfe3f7 100644--- a/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.html+++ b/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.html@@ -14,7 +14,7 @@<td class="path-filter"><form wicket:id="pathFilter"><div class="input-group">- <input wicket:id="input" class="form-control" spellcheck="false" autocomplete="false" placeholder="Search by path pattern" type="text"></input>+ <input wicket:id="input" class="form-control" spellcheck="false" autocomplete="off" placeholder="Search by path pattern" type="text"></input><span class="input-group-btn"><button wicket:id="submit" title="Filter" class="btn btn-default" type="submit"><i class="fa fa-search"></i></button></span>diff --git a/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java b/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.javaindex ebfbf44a05..fddaa1adaa 100644--- a/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java+++ b/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java@@ -191,35 +191,50 @@ public class RevisionDiffPanel extends Panel {markedPaths.add(mark.getPath());}- List<BlobChange> filterChanges = new ArrayList<>();- for (BlobChange change: allChanges) {- if (StringUtils.isNotBlank(pathFilterModel.getObject())) {- String matchWith = pathFilterModel.getObject().toLowerCase().trim();- matchWith = StringUtils.stripStart(matchWith, "/");- matchWith = StringUtils.stripEnd(matchWith, "/");- String oldPath = change.getOldBlobIdent().path;- if (oldPath == null)- oldPath = "";- else- oldPath = oldPath.toLowerCase();- String newPath = change.getNewBlobIdent().path;- if (newPath == null)- newPath = "";- else- newPath = newPath.toLowerCase();- if (matchWith.equals(oldPath) || matchWith.equals(newPath)) {- filterChanges.add(change);- } else if (oldPath.startsWith(matchWith + "/") || newPath.startsWith(matchWith + "/")) {- filterChanges.add(change);- } else if (WildcardUtils.matchString(matchWith, oldPath)- || WildcardUtils.matchString(matchWith, newPath)){- filterChanges.add(change);- }- } else {- filterChanges.add(change);- }- }-+ List<BlobChange> filterChanges;+ String matchWith = pathFilterModel.getObject();+ if (StringUtils.isNotBlank(matchWith)) {+ matchWith = matchWith.toLowerCase().trim();+ boolean exclude = false;+ if (matchWith.startsWith("-")) {+ matchWith = matchWith.substring(1).trim();+ exclude = true;+ }+ matchWith = StringUtils.stripStart(matchWith, "/");+ matchWith = StringUtils.stripEnd(matchWith, "/");++ List<BlobChange> matchChanges = new ArrayList<>();+ for (BlobChange change: allChanges) {+ String oldPath = change.getOldBlobIdent().path;+ if (oldPath == null)+ oldPath = "";+ else+ oldPath = oldPath.toLowerCase();+ String newPath = change.getNewBlobIdent().path;+ if (newPath == null)+ newPath = "";+ else+ newPath = newPath.toLowerCase();+ if (matchWith.equals(oldPath) || matchWith.equals(newPath)) {+ matchChanges.add(change);+ } else if (oldPath.startsWith(matchWith + "/") || newPath.startsWith(matchWith + "/")) {+ matchChanges.add(change);+ } else if (WildcardUtils.matchString(matchWith, oldPath)+ || WildcardUtils.matchString(matchWith, newPath)){+ matchChanges.add(change);+ }+ }++ if (exclude) {+ filterChanges = new ArrayList<>(allChanges);+ filterChanges.removeAll(matchChanges);+ } else {+ filterChanges = matchChanges;+ }+ } else {+ filterChanges = new ArrayList<>(allChanges);+ }+// for some unknown reason, some paths in the diff entries is DELETE/ADD// pair instead MODIFICATION, here we normalize those as a single// MODIFICATION entry@@ -544,14 +559,25 @@ public class RevisionDiffPanel extends Panel {@Overrideprotected List<InputCompletion> getSuggestions(InputStatus inputStatus) {List<InputCompletion> completions = new ArrayList<>();- for (InputSuggestion suggestion: SuggestionUtils.suggestPath(listOfInvolvedPaths,- inputStatus.getContentBeforeCaret().trim())) {+ String matchWith = inputStatus.getContentBeforeCaret().trim();+ boolean exclude = false;+ if (matchWith.startsWith("-")) {+ matchWith = matchWith.substring(1).trim();+ exclude = true;+ }++ for (InputSuggestion suggestion: SuggestionUtils.suggestPath(listOfInvolvedPaths, matchWith)) {int caret = suggestion.getCaret();if (caret == -1)caret = suggestion.getContent().length();- InputCompletion completion = new InputCompletion(0, inputStatus.getContent().length(),- suggestion.getContent(), caret, suggestion.getLabel(),- null, suggestion.getMatchRange());+ InputCompletion completion;+ if (exclude) {+ completion = new InputCompletion(0, inputStatus.getContent().length(),+ "-"+suggestion.getContent(), caret+1, null, null, suggestion.getMatchRange());+ } else {+ completion = new InputCompletion(0, inputStatus.getContent().length(), suggestion.getContent(),+ caret, null, null, suggestion.getMatchRange());+ }completions.add(completion);}return completions;@@ -559,7 +585,7 @@ public class RevisionDiffPanel extends Panel {@Overrideprotected List<String> getHints(InputStatus inputStatus) {- return Lists.newArrayList("Use * to match any part of the path");+ return Lists.newArrayList("Use '*' to match any part of the path", "Prefix path with '-' to exclude");}@Overridediff --git a/web/src/main/java/com/gitplex/server/web/page/depot/commit/QueryAssistBehavior.java b/web/src/main/java/com/gitplex/server/web/page/depot/commit/CommitQueryBehavior.javasimilarity index 95%rename from web/src/main/java/com/gitplex/server/web/page/depot/commit/QueryAssistBehavior.javarename to web/src/main/java/com/gitplex/server/web/page/depot/commit/CommitQueryBehavior.javaindex 10e5b907f9..c4a2e82bbc 100644--- a/web/src/main/java/com/gitplex/server/web/page/depot/commit/QueryAssistBehavior.java+++ b/web/src/main/java/com/gitplex/server/web/page/depot/commit/CommitQueryBehavior.java@@ -26,7 +26,7 @@ import com.gitplex.server.web.behavior.inputassist.ANTLRAssistBehavior;import com.gitplex.server.web.util.SuggestionUtils;@SuppressWarnings("serial")-public class QueryAssistBehavior extends ANTLRAssistBehavior {+public class CommitQueryBehavior extends ANTLRAssistBehavior {private final IModel<Depot> depotModel;@@ -39,7 +39,7 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {"yesterday midnight", "3 days ago", "last week", "last Monday","4 weeks ago", "1 month 2 days ago", "1 year ago"};- public QueryAssistBehavior(IModel<Depot> depotModel) {+ public CommitQueryBehavior(IModel<Depot> depotModel) {super(CommitQueryParser.class, "query");this.depotModel = depotModel;}@@ -104,8 +104,10 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {suggestions.add(new InputSuggestion(fenced, -1, true, getFencingDescription(),matchRange));}- suggestions.add(new InputSuggestion(WebConstants.DATETIME_FORMATTER.print(System.currentTimeMillis())));- suggestions.add(new InputSuggestion(WebConstants.DATE_FORMATTER.print(System.currentTimeMillis())));+ suggestions.add(new InputSuggestion(+ WebConstants.DATETIME_FORMATTER.print(System.currentTimeMillis())));+ suggestions.add(new InputSuggestion(+ WebConstants.DATE_FORMATTER.print(System.currentTimeMillis())));for (String dateExample: DATE_EXAMPLES) {suggestions.add(new InputSuggestion(dateExample));}diff --git a/web/src/main/java/com/gitplex/server/web/page/depot/commit/DepotCommitsPage.java b/web/src/main/java/com/gitplex/server/web/page/depot/commit/DepotCommitsPage.javaindex 82ea762267..7cd982bdd7 100644--- a/web/src/main/java/com/gitplex/server/web/page/depot/commit/DepotCommitsPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/depot/commit/DepotCommitsPage.java@@ -278,7 +278,7 @@ public class DepotCommitsPage extends DepotPage {};- queryForm.add(queryInput.add(new QueryAssistBehavior(depotModel)));+ queryForm.add(queryInput.add(new CommitQueryBehavior(depotModel)));queryForm.add(new AjaxButton("submit") {});queryForm.setOutputMarkupId(true);