Skip to content

Commit ea1acb1

Browse files
committed
[FIXED JENKINS-19649] viewmask config fix
fixed condition for using the view mask for changelog fixed issue where view mask for changelog option could be enabled when loading config added test for optional configuration sections
1 parent 4663c3c commit ea1acb1

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/main/java/hudson/plugins/perforce/PerforceSCM.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public PerforceSCM(
331331
MaskViewConfig useViewMask
332332
) {
333333

334-
this.configVersion = 1L;
334+
this.configVersion = 2L;
335335

336336
this.p4User = p4User;
337337
this.setP4Passwd(p4Passwd);
@@ -651,6 +651,8 @@ public Object readResolve() {
651651

652652
if (configVersion == 1L) {
653653
this.useViewMaskForChangeLog = this.useViewMaskForSyncing;
654+
655+
configVersion = 2L;
654656
}
655657

656658
return this;
@@ -1054,7 +1056,7 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
10541056
}
10551057

10561058
List<Integer> changeNumbersTo;
1057-
if (useViewMaskForChangeLog) {
1059+
if (useViewMaskForChangeLog && useViewMask) {
10581060
changeNumbersTo = depot.getChanges().getChangeNumbersInRange(p4workspace, lastChangeToDisplay, newestChange, viewMask, showIntegChanges);
10591061
} else {
10601062
changeNumbersTo = depot.getChanges().getChangeNumbersInRange(p4workspace, lastChangeToDisplay, newestChange, showIntegChanges);

src/test/java/hudson/plugins/perforce/PerforceSCMTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import hudson.model.Hudson;
66
import hudson.plugins.perforce.PerforceToolInstallation.DescriptorImpl;
77
import hudson.plugins.perforce.browsers.P4Web;
8+
import hudson.plugins.perforce.config.CleanTypeConfig;
89
import hudson.plugins.perforce.config.MaskViewConfig;
910
import hudson.plugins.perforce.config.WorkspaceCleanupConfig;
1011
import hudson.tools.ToolProperty;
@@ -23,8 +24,11 @@
2324
public class PerforceSCMTest extends HudsonTestCase {
2425
/// Preserves original behavior of the tests
2526
public static final DepotType EMPTY_DEPOT = null;
27+
public static final DepotType TEST_DEPOT = new DepotType(DepotType.USE_PROJECTPATH_MARKER, null, null, "//...");
2628
public static final MaskViewConfig EMPTY_MASKVIEW = null;
29+
public static final MaskViewConfig TEST_MASKVIEW = new MaskViewConfig("//...", true, false, false);
2730
public static final WorkspaceCleanupConfig EMPTY_WORKSPACE_CLEANUP = null;
31+
public static final WorkspaceCleanupConfig TEST_WORKSPACE_CLEANUP = new WorkspaceCleanupConfig(new CleanTypeConfig("quick", true), true);
2832

2933
/**
3034
* Makes sure that the configuration survives the round-trip.
@@ -35,7 +39,7 @@ public void testConfigRoundtrip() throws Exception {
3539
PerforceSCM scm = new PerforceSCM(
3640
"user", "pass", "client", "port", "", "exe", "sysRoot",
3741
"sysDrive", "label", "counter", "upstreamProject", "shared", "charset", "charset2", "user", false, true, true, true, true, true, false,
38-
false, true, false, false, false, "${basename}", 0, -1, browser, "exclude_user", "exclude_file", true, EMPTY_DEPOT, EMPTY_WORKSPACE_CLEANUP, EMPTY_MASKVIEW);
42+
false, true, false, false, false, "${basename}", 0, -1, browser, "exclude_user", "exclude_file", true, TEST_DEPOT, TEST_WORKSPACE_CLEANUP, TEST_MASKVIEW);
3943
scm.setProjectPath("path");
4044
project.setScm(scm);
4145

0 commit comments

Comments
 (0)