Skip to content

Commit 7539e18

Browse files
committed
Handling Windows-style file paths and using password field in confg GUI #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.
1 parent ca00f22 commit 7539e18

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Changelog of Violation Comments to Stash Plugin
44

5+
# 1.6
6+
* Replacing back-slashes (Windows style file paths) from reports with forward-slashes. So that they match file paths reported in Stash Rest API.
7+
* Using password field for password in configuration GUI
8+
59
# 1.5
610
* Less logging in build log
711

src/main/java/org/jenkinsci/plugins/jvcts/perform/FullBuildModelWrapper.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import org.jenkinsci.plugins.jvcts.config.ParserConfig;
2626
import org.jenkinsci.plugins.jvcts.config.ViolationsToStashConfig;
2727

28+
import com.google.common.annotations.VisibleForTesting;
29+
2830
public class FullBuildModelWrapper {
2931

3032
private final Map<String, FullBuildModel> models = newHashMap();
@@ -60,7 +62,7 @@ public Map<String, List<Violation>> getViolationsPerFile() {
6062
String typeDescriptorName = parserConfig.getParserTypeDescriptorName();
6163
if (models.containsKey(typeDescriptorName)) {
6264
for (String fileModel : models.get(typeDescriptorName).getFileModelMap().keySet()) {
63-
String sourceFile = determineSourcePath(fileModel, parserConfig);
65+
String sourceFile = usingForwardSlashes(determineSourcePath(fileModel, parserConfig));
6466
if (sourceFile == null) {
6567
doLog(listener, SEVERE, "Could not determine source file from: " + fileModel);
6668
continue;
@@ -81,6 +83,11 @@ public Map<String, List<Violation>> getViolationsPerFile() {
8183
return violationsPerFile;
8284
}
8385

86+
@VisibleForTesting
87+
static String usingForwardSlashes(String unknownSlashed) {
88+
return unknownSlashed.replaceAll("\\\\", "/");
89+
}
90+
8491
private String determineSourcePath(String fileModel, ParserConfig parserConfig) {
8592
doLog(FINE, "Determining source path for " + fileModel);
8693
FullBuildModel model = models.get(parserConfig.getParserTypeDescriptorName());

src/main/resources/org/jenkinsci/plugins/jvcts/ViolationsToStashRecorder/config.jelly

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</f:entry>
3232

3333
<f:entry title="Password">
34-
<f:textbox name="stashPassword" value="${config.stashPassword}" />
34+
<f:password name="stashPassword" value="${config.stashPassword}" />
3535
</f:entry>
3636

3737
<f:entry title="Base URL">
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.jenkinsci.plugins.jvcts.perform;
2+
3+
import static org.jenkinsci.plugins.jvcts.perform.FullBuildModelWrapper.usingForwardSlashes;
4+
import static org.junit.Assert.assertEquals;
5+
6+
import org.junit.Test;
7+
8+
public class FullBuildModelWrapperTest {
9+
@Test
10+
public void testThatSlashesAreReplacedCorrectly() {
11+
assertEquals("c:/some/path/file.txt", usingForwardSlashes("c:\\some\\path\\file.txt"));
12+
}
13+
}

0 commit comments

Comments
 (0)