Skip to content

Commit

Permalink
Jenkins-4688 - Setting disable changelog to be build specific rather
Browse files Browse the repository at this point in the history
than global and adding a field into the config to allow user to change
it
  • Loading branch information
mc1arke committed Jan 2, 2012
1 parent 94a850e commit ce115fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
29 changes: 11 additions & 18 deletions src/main/java/hudson/scm/CVSSCM.java
Expand Up @@ -121,6 +121,8 @@ public class CVSSCM extends SCM implements Serializable {
private final CvsRepository[] repositories;

private final boolean canUseUpdate;

private final boolean skipChangeLog;

// start legacy fields
@Deprecated
Expand Down Expand Up @@ -148,14 +150,15 @@ public CVSSCM(final String cvsRoot, final String allModules, final String branch
final boolean canUseUpdate, final boolean useHeadIfNotFound, final boolean legacy,
final boolean isTag, final String excludedRegions) {
this(convertLegacyConfigToRepositoryStructure(cvsRoot, allModules, branch, isTag, excludedRegions,
useHeadIfNotFound), canUseUpdate, legacy, null);
useHeadIfNotFound), canUseUpdate, legacy, null, Boolean.getBoolean(CVSSCM.class.getName() + ".skipChangeLog"));
}

@DataBoundConstructor
public CVSSCM(final List<CvsRepository> repositories, final boolean canUseUpdate, final boolean legacy,
final CVSRepositoryBrowser browser) {
final CVSRepositoryBrowser browser, final boolean skipChangeLog) {
this.repositories = repositories.toArray(new CvsRepository[repositories.size()]);
this.canUseUpdate = canUseUpdate;
this.skipChangeLog = skipChangeLog;
flatten = !legacy && this.repositories.length == 1 && this.repositories[0].getModules().length == 1;
repositoryBrowser = browser;
}
Expand Down Expand Up @@ -612,6 +615,11 @@ public ChangeLogParser createChangeLogParser() {
public boolean getCanUseUpdate() {
return canUseUpdate;
}

@Exported
public boolean isSkipChangeLog() {
return skipChangeLog;
}

@Exported
public boolean isFlatten() {
Expand Down Expand Up @@ -765,7 +773,7 @@ public Boolean invoke(final File workspace, final VirtualChannel channel) throws
// build change log
final Build<?, ?> lastCompleteBuild = (Build<?, ?>) build.getPreviousBuiltBuild();

if (lastCompleteBuild != null && !getDescriptor().isSkipChangeLog()) {
if (lastCompleteBuild != null && !isSkipChangeLog()) {
final List<CVSChangeLog> changes = new ArrayList<CVSChangeLog>();
for (CvsRepository location : repositories) {
changes.addAll(calculateChangeLog(lastCompleteBuild.getTime(), build.getTime(), location, launcher,
Expand Down Expand Up @@ -908,8 +916,6 @@ private class RepositoryBrowser {
*/
private int compressionLevel = 3;

private boolean skipChangeLog;

public DescriptorImpl() {
super(CVSRepositoryBrowser.class);
load();
Expand All @@ -936,31 +942,18 @@ public void setCompressionLevel(final int compressionLevel) {
this.compressionLevel = compressionLevel;
}

public boolean isSkipChangeLog() {
return skipChangeLog;
}

public void setSkipChangeLog(final boolean shouldSkipChangeLog) {
skipChangeLog = shouldSkipChangeLog;
}

@Override
public void load() {
super.load();
// used to move to the new data structure
if (noCompression) {
compressionLevel = 0;
}

if (Boolean.getBoolean(CVSSCM.class.getName() + ".skipChangeLog")) {
skipChangeLog = true;
}
}

@Override
public boolean configure(final StaplerRequest req, final JSONObject o) {
String compressionLevel = fixEmptyAndTrim(o.getString("cvsCompression"));
skipChangeLog = Boolean.parseBoolean(o.getString("skipChangeLog"));

try {
this.compressionLevel = Integer.parseInt(compressionLevel);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/hudson/scm/CVSSCM/config.jelly
Expand Up @@ -123,6 +123,9 @@ THE SOFTWARE.
<f:entry title="${%Use Update}">
<f:checkbox name="canUseUpdate" checked="${instance.canUseUpdate}" />
</f:entry>
<f:entry title="${%Skip Changelog}">
<f:checkbox name="skipChangeLog" checked="${instance.skipChangeLog}" />
</f:entry>
<f:entry title="${%Legacy Mode}">
<f:checkbox name="legacy" checked="${instance.legacy}" title="${%legacyModeDescription}" />
</f:entry>
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/hudson/scm/CVSSCMTest.java
Expand Up @@ -70,11 +70,9 @@ public void testGlobalConfigRoundtrip() throws Exception {
CVSSCM.DescriptorImpl d = hudson
.getDescriptorByType(CVSSCM.DescriptorImpl.class);
d.setCompressionLevel(1);
d.setSkipChangeLog(true);

submit(createWebClient().goTo("configure").getFormByName("config"));
assertEquals(1, d.getCompressionLevel());
assertEquals(true, d.isSkipChangeLog());
}

private void roundtrip(final FreeStyleProject p) throws Exception {
Expand Down

0 comments on commit ce115fb

Please sign in to comment.