Skip to content

Commit

Permalink
Handling Windows-style file paths and using password field in confg GUI
Browse files Browse the repository at this point in the history
#9 #10

* Replacing back-slashes (Windows style file paths) from reports with forward-slashes. So that they match file paths reported in Stash Rest API.
  • Loading branch information
tomasbjerre committed May 31, 2015
1 parent ca00f22 commit 7539e18
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Changelog of Violation Comments to Stash Plugin

# 1.6
* Replacing back-slashes (Windows style file paths) from reports with forward-slashes. So that they match file paths reported in Stash Rest API.
* Using password field for password in configuration GUI

# 1.5
* Less logging in build log

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.jenkinsci.plugins.jvcts.config.ParserConfig;
import org.jenkinsci.plugins.jvcts.config.ViolationsToStashConfig;

import com.google.common.annotations.VisibleForTesting;

public class FullBuildModelWrapper {

private final Map<String, FullBuildModel> models = newHashMap();
Expand Down Expand Up @@ -60,7 +62,7 @@ public Map<String, List<Violation>> getViolationsPerFile() {
String typeDescriptorName = parserConfig.getParserTypeDescriptorName();
if (models.containsKey(typeDescriptorName)) {
for (String fileModel : models.get(typeDescriptorName).getFileModelMap().keySet()) {
String sourceFile = determineSourcePath(fileModel, parserConfig);
String sourceFile = usingForwardSlashes(determineSourcePath(fileModel, parserConfig));
if (sourceFile == null) {
doLog(listener, SEVERE, "Could not determine source file from: " + fileModel);
continue;
Expand All @@ -81,6 +83,11 @@ public Map<String, List<Violation>> getViolationsPerFile() {
return violationsPerFile;
}

@VisibleForTesting
static String usingForwardSlashes(String unknownSlashed) {
return unknownSlashed.replaceAll("\\\\", "/");
}

private String determineSourcePath(String fileModel, ParserConfig parserConfig) {
doLog(FINE, "Determining source path for " + fileModel);
FullBuildModel model = models.get(parserConfig.getParserTypeDescriptorName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</f:entry>

<f:entry title="Password">
<f:textbox name="stashPassword" value="${config.stashPassword}" />
<f:password name="stashPassword" value="${config.stashPassword}" />
</f:entry>

<f:entry title="Base URL">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jenkinsci.plugins.jvcts.perform;

import static org.jenkinsci.plugins.jvcts.perform.FullBuildModelWrapper.usingForwardSlashes;
import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class FullBuildModelWrapperTest {
@Test
public void testThatSlashesAreReplacedCorrectly() {
assertEquals("c:/some/path/file.txt", usingForwardSlashes("c:\\some\\path\\file.txt"));
}
}

0 comments on commit 7539e18

Please sign in to comment.