diff --git a/src/main/java/hudson/plugins/scm_sync_configuration/ScmSyncConfigurationPlugin.java b/src/main/java/hudson/plugins/scm_sync_configuration/ScmSyncConfigurationPlugin.java index 95b9ed11..b6c845a5 100644 --- a/src/main/java/hudson/plugins/scm_sync_configuration/ScmSyncConfigurationPlugin.java +++ b/src/main/java/hudson/plugins/scm_sync_configuration/ScmSyncConfigurationPlugin.java @@ -95,6 +95,7 @@ public static interface AtomicTransactionFactory { // when commit occurs private String commitMessagePattern = "[message]"; private List filesModifiedByLastReload; + private boolean includeUserConfig = true; private List manualSynchronizationIncludes; public ScmSyncConfigurationPlugin(){ @@ -145,6 +146,7 @@ public void loadData(ScmSyncConfigurationPOJO pojo){ this.displayStatus = pojo.isDisplayStatus(); this.commitMessagePattern = pojo.getCommitMessagePattern(); this.manualSynchronizationIncludes = pojo.getManualSynchronizationIncludes(); + this.includeUserConfig = pojo.isIncludeUserConfig(); } public void init() { @@ -173,6 +175,7 @@ public void configure(StaplerRequest req, JSONObject formData) this.noUserCommitMessage = formData.getBoolean("noUserCommitMessage"); this.displayStatus = formData.getBoolean("displayStatus"); this.commitMessagePattern = req.getParameter("commitMessagePattern"); + this.includeUserConfig = formData.getBoolean("includeUserConfig"); String oldScmRepositoryUrl = this.scmRepositoryUrl; String scmType = req.getParameter("scm"); @@ -355,6 +358,10 @@ public boolean isDisplayStatus() { return displayStatus; } + public boolean isIncludeUserConfig() { + return includeUserConfig; + } + public String getCommitMessagePattern() { return commitMessagePattern; } diff --git a/src/main/java/hudson/plugins/scm_sync_configuration/strategies/impl/UserConfigScmSyncStrategy.java b/src/main/java/hudson/plugins/scm_sync_configuration/strategies/impl/UserConfigScmSyncStrategy.java index 586deee9..112ac60f 100644 --- a/src/main/java/hudson/plugins/scm_sync_configuration/strategies/impl/UserConfigScmSyncStrategy.java +++ b/src/main/java/hudson/plugins/scm_sync_configuration/strategies/impl/UserConfigScmSyncStrategy.java @@ -5,6 +5,7 @@ import hudson.model.Job; import hudson.model.Saveable; import hudson.model.User; +import hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin; import hudson.plugins.scm_sync_configuration.model.MessageWeight; import hudson.plugins.scm_sync_configuration.model.WeightedMessage; import hudson.plugins.scm_sync_configuration.strategies.AbstractScmSyncStrategy; @@ -12,6 +13,7 @@ import hudson.plugins.scm_sync_configuration.strategies.model.ConfigurationEntityMatcher; import hudson.plugins.scm_sync_configuration.strategies.model.PageMatcher; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -32,6 +34,24 @@ public UserConfigScmSyncStrategy(){ super(CONFIG_ENTITY_MANAGER, PAGE_MATCHERS); } + @Override + public boolean isSaveableApplicable(Saveable saveable, File file) { + if(!ScmSyncConfigurationPlugin.getInstance().isIncludeUserConfig()){ + return false; + } else { + return super.isSaveableApplicable(saveable, file); + } + } + + @Override + public boolean isCurrentUrlApplicable(String url) { + if(!ScmSyncConfigurationPlugin.getInstance().isIncludeUserConfig()){ + return false; + } else { + return super.isCurrentUrlApplicable(url); + } + } + public CommitMessageFactory getCommitMessageFactory(){ return new CommitMessageFactory(){ public WeightedMessage getMessageWhenSaveableUpdated(Saveable s, XmlFile file) { diff --git a/src/main/java/hudson/plugins/scm_sync_configuration/xstream/ScmSyncConfigurationXStreamConverter.java b/src/main/java/hudson/plugins/scm_sync_configuration/xstream/ScmSyncConfigurationXStreamConverter.java index ef2aa16e..dda65fd6 100644 --- a/src/main/java/hudson/plugins/scm_sync_configuration/xstream/ScmSyncConfigurationXStreamConverter.java +++ b/src/main/java/hudson/plugins/scm_sync_configuration/xstream/ScmSyncConfigurationXStreamConverter.java @@ -84,6 +84,10 @@ public void marshal(Object source, HierarchicalStreamWriter writer, writer.endNode(); } + writer.startNode(AbstractMigrator.SCM_INCLUDE_USERCONFIG); + writer.setValue(Boolean.toString(plugin.isIncludeUserConfig())); + writer.endNode(); + if(plugin.getManualSynchronizationIncludes() != null){ writer.startNode(AbstractMigrator.SCM_MANUAL_INCLUDES); for(String include : plugin.getManualSynchronizationIncludes()){ diff --git a/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/AbstractMigrator.java b/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/AbstractMigrator.java index 408473c3..9e9e3419 100644 --- a/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/AbstractMigrator.java +++ b/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/AbstractMigrator.java @@ -17,6 +17,7 @@ public abstract class AbstractMigrator manualIncludes = null; while(reader.hasMoreChildren()){ @@ -56,6 +58,8 @@ public TTO readScmSyncConfigurationPOJO( scmContent = reader.getValue(); } else if(SCM_COMMIT_MESSAGE_PATTERN.equals(reader.getNodeName())){ commitMessagePattern = reader.getValue(); + } else if(SCM_INCLUDE_USERCONFIG.equals(reader.getNodeName())){ + includeUserConfig = Boolean.parseBoolean(reader.getValue()); } else if(SCM_MANUAL_INCLUDES.equals(reader.getNodeName())){ manualIncludes = new ArrayList(); while(reader.hasMoreChildren()){ @@ -71,14 +75,15 @@ public TTO readScmSyncConfigurationPOJO( } reader.moveUp(); } - + pojo.setScm(createSCMFrom(scmClassAttribute, scmContent)); pojo.setScmRepositoryUrl(scmRepositoryUrl); pojo.setNoUserCommitMessage(noUserCommitMessage); pojo.setDisplayStatus(displayStatus); pojo.setCommitMessagePattern(commitMessagePattern); pojo.setManualSynchronizationIncludes(manualIncludes); - + pojo.setIncludeUserConfig(includeUserConfig); + return pojo; } diff --git a/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/DefaultSSCPOJO.java b/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/DefaultSSCPOJO.java index f592157c..3b44bc11 100644 --- a/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/DefaultSSCPOJO.java +++ b/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/DefaultSSCPOJO.java @@ -11,6 +11,7 @@ public class DefaultSSCPOJO implements ScmSyncConfigurationPOJO { private boolean noUserCommitMessage; private boolean displayStatus; private String commitMessagePattern; + private boolean includeUserConfig; private List manualSynchronizationIncludes; public String getScmRepositoryUrl() { @@ -46,7 +47,15 @@ public void setCommitMessagePattern(String commitMessagePattern) { this.commitMessagePattern = commitMessagePattern; } - public void setManualSynchronizationIncludes(List _manualSynchronizationIncludes){ + public boolean isIncludeUserConfig() { + return includeUserConfig; + } + + public void setIncludeUserConfig(boolean includeUserConfig) { + this.includeUserConfig = includeUserConfig; + } + + public void setManualSynchronizationIncludes(List _manualSynchronizationIncludes){ this.manualSynchronizationIncludes = _manualSynchronizationIncludes; } diff --git a/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/ScmSyncConfigurationPOJO.java b/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/ScmSyncConfigurationPOJO.java index eea89608..babfbd1c 100644 --- a/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/ScmSyncConfigurationPOJO.java +++ b/src/main/java/hudson/plugins/scm_sync_configuration/xstream/migration/ScmSyncConfigurationPOJO.java @@ -21,4 +21,6 @@ public interface ScmSyncConfigurationPOJO { public void setCommitMessagePattern(String commitMessagePattern); public List getManualSynchronizationIncludes(); public void setManualSynchronizationIncludes(List manualSynchronizationIncludes); + public boolean isIncludeUserConfig(); + public void setIncludeUserConfig(boolean includeUserConfig); } diff --git a/src/main/resources/hudson/plugins/scm_sync_configuration/ScmSyncConfigurationPlugin/config.jelly b/src/main/resources/hudson/plugins/scm_sync_configuration/ScmSyncConfigurationPlugin/config.jelly index 043a21a3..1ac1d45d 100644 --- a/src/main/resources/hudson/plugins/scm_sync_configuration/ScmSyncConfigurationPlugin/config.jelly +++ b/src/main/resources/hudson/plugins/scm_sync_configuration/ScmSyncConfigurationPlugin/config.jelly @@ -34,6 +34,16 @@ + + + + + + + + + +