Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support of using trackingSubmodules in the DSL for git submodules. #645

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class ScmContext extends AbstractExtensibleContext {
configVersion '2'
disableSubmodules 'false'
recursiveSubmodules gitContext.recursiveSubmodules
trackingSubmodules gitContext.trackingSubmodules
doGenerateSubmoduleConfigurations 'false'
authorOrCommitter 'false'
clean gitContext.clean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class GitContext extends AbstractContext {
boolean pruneBranches = false
boolean ignoreNotifyCommit = false
boolean recursiveSubmodules = false
boolean trackingSubmodules = false
String localBranch
String relativeTargetDir
String reference = ''
Expand Down Expand Up @@ -169,6 +170,14 @@ class GitContext extends AbstractContext {
this.recursiveSubmodules = recursive
}

/**
* Update tracking submodules to tip of branch. Defaults to {@code false}
* @since 1.40
*/
void trackingSubmodules(boolean tracking = true) {
this.trackingSubmodules = tracking
}

/**
* Prunes obsolete local branches. Defaults to {@code false}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class DslSampleSpec extends Specification {
<configVersion>2</configVersion>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<trackingSubmodules>false</trackingSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
Expand Down Expand Up @@ -300,6 +301,7 @@ mavenJob('PROJ-maven-with-template') {
<configVersion>2</configVersion>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<trackingSubmodules>false</trackingSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
Expand Down Expand Up @@ -353,6 +355,7 @@ mavenJob('PROJ-maven-with-template') {
<configVersion>2</configVersion>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<trackingSubmodules>false</trackingSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,43 @@ class ScmContextSpec extends Specification {
1 * mockJobManagement.logPluginDeprecationWarning('git', '2.2.6')
}

def 'call git scm with trackingSubmodules with default true'() {
when:
context.git {
remote {
url('https://github.com/jenkinsci/job-dsl-plugin.git')
}
trackingSubmodules()
}

then:
with(context.scmNodes[0]) {
trackingSubmodules[0].value() == true
}
1 * mockJobManagement.requirePlugin('git')
1 * mockJobManagement.logPluginDeprecationWarning('git', '2.2.6')
}

def 'call git scm with trackingSubmodules with param'(boolean value) {
when:
context.git {
remote {
url('https://github.com/jenkinsci/job-dsl-plugin.git')
}
trackingSubmodules(value)
}

then:
with(context.scmNodes[0]) {
trackingSubmodules[0].value() == value
}
1 * mockJobManagement.requirePlugin('git')
1 * mockJobManagement.logPluginDeprecationWarning('git', '2.2.6')

where:
value << [true, false]
}

def 'call git scm with recursiveSubmodules with param'(boolean value) {
when:
context.git {
Expand Down