Skip to content

Commit

Permalink
Changed file in Stash may also end with reported file, not only the o…
Browse files Browse the repository at this point in the history
…pposite

* Findbugs reports Java-files as package path, this makes sure those files are matched to changed files in Stash
  • Loading branch information
tomasbjerre committed May 25, 2015
1 parent 20fd43b commit 56010ce
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Changelog of Violation Comments to Stash Plugin

## 1.3
* hanged file in Stash may also end with reported file, not only the opposite. Findbugs reports Java-files as package path, this makes sure those files are matched to changed files in Stash.

## 1.2
* Can, optionally, add comments to individual commits. And/Or to pull requests.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static void commentStash(Map<String, List<Violation>> violationsPerFile,
private static List<Violation> getViolationsForFile(Map<String, List<Violation>> violationsPerFile,
String changedFileInStash, BuildListener listener) {
for (String reportedFile : violationsPerFile.keySet()) {
if (reportedFile.endsWith(changedFileInStash)) {
if (reportedFile.endsWith(changedFileInStash) || changedFileInStash.endsWith(reportedFile)) {
JvctsLogger.doLog(listener, FINE, "Changed file and reported file matches. Stash: \"" + changedFileInStash
+ "\" Reported: \"" + reportedFile + "\"");
return violationsPerFile.get(reportedFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class StashClientFaker {
public static final String COMMENTS_1_DELETE = "http://stash.server/rest/api/1.0/projects/stashProject/repos/stashRepo/pull-requests/1/comments/13780?version=0 DELETE";
public static final String COMMENTS_CHECKSTYLEFILE_GET = "http://stash.server/rest/api/1.0/projects/stashProject/repos/stashRepo/pull-requests/1/comments?path=module/src/main/java/se/bjurr/code/CheckstyleFile.java&limit=999999 GET";
public static final String COMMENTS_CHECKSTYLEFILE_REL_GET = "http://stash.server/rest/api/1.0/projects/stashProject/repos/stashRepo/pull-requests/1/comments?path=module/src/main/java/se/bjurr/code/CheckstyleFileRel.java&limit=999999 GET";
public static final String COMMENTS_FINDBUGS_GET = "http://stash.server/rest/api/1.0/projects/stashProject/repos/stashRepo/pull-requests/1/comments?path=analyzer/Code.java&limit=999999 GET";
public static final String COMMENTS_FINDBUGS_GET = "http://stash.server/rest/api/1.0/projects/stashProject/repos/stashRepo/pull-requests/1/comments?path=module/se/bjurr/analyzer/Code.java&limit=999999 GET";
public static final String CHANGES_GET = "http://stash.server/rest/api/1.0/projects/stashProject/repos/stashRepo/pull-requests/1/changes?limit=999999 GET";
private static Map<String, String> fakeResponses;
private static List<String> requestsSentToStash;
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/findbugs_code.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
http://stash.server/rest/api/1.0/projects/stashProject/repos/stashRepo/pull-requests/1/comments POST { "text": "findbugs L8 High (0) EQ_ALWAYS_FALSE", "anchor": { "line": "8", "lineType": "ADDED", "fileType": "TO", "path": "analyzer/Code.java" }}
http://stash.server/rest/api/1.0/projects/stashProject/repos/stashRepo/pull-requests/1/comments POST { "text": "findbugs L8 High (0) EQ_ALWAYS_FALSE", "anchor": { "line": "8", "lineType": "ADDED", "fileType": "TO", "path": "module/se/bjurr/analyzer/Code.java" }}
2 changes: 1 addition & 1 deletion src/test/resources/pullrequestchanges_1_GET.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
{
"path": {
"toString": "analyzer/Code.java"
"toString": "module/se/bjurr/analyzer/Code.java"
}
}
]
Expand Down

0 comments on commit 56010ce

Please sign in to comment.