summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLadislav Thon <lthon@redhat.com>2018-03-06 14:50:54 +0100
committerSergii Kipot <kipot.sergey@gmail.com>2019-01-31 17:08:34 +0000
commita2ad875fd755ee93654c07e3649ace72bc4a4727 (patch)
treed2ed11b364138b1569ccb577742ac40a8fb24973
parentc59b5a5258c875d814b1ada82fd7bbaf7de97a26 (diff)
add the "honorRefspec" option to the Git SCM
Taken from github pull request https://github.com/openstack-infra/jenkins-job-builder/pull/64/files Change-Id: Ib051a46daa4a3e2d6add74cc9c1c3c1eb766672a
Notes
Notes (review): Code-Review+1: Daniel Watkins <daniel.watkins@canonical.com> Code-Review+2: Sorin Sbarnea <ssbarnea@redhat.com> Workflow+1: Sorin Sbarnea <ssbarnea@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Sat, 02 Mar 2019 11:59:23 +0000 Reviewed-on: https://review.openstack.org/634003 Project: openstack-infra/jenkins-job-builder Branch: refs/heads/master
-rw-r--r--jenkins_jobs/modules/scm.py8
-rw-r--r--tests/scm/fixtures/git-cloneoptions01.xml1
-rw-r--r--tests/scm/fixtures/git-cloneoptions01.yaml1
3 files changed, 9 insertions, 1 deletions
diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py
index 519550c..87429f8 100644
--- a/jenkins_jobs/modules/scm.py
+++ b/jenkins_jobs/modules/scm.py
@@ -172,6 +172,8 @@ def git(registry, xml_parent, data):
172 * **depth** (`int`) - Set shallow clone depth (default 1) 172 * **depth** (`int`) - Set shallow clone depth (default 1)
173 * **do-not-fetch-tags** (`bool`) - Perform a clone without tags 173 * **do-not-fetch-tags** (`bool`) - Perform a clone without tags
174 (default false) 174 (default false)
175 * **honor-refspec** (`bool`) - Perform initial clone using the refspec
176 defined for the repository (default false)
175 * **sparse-checkout** (`dict`) 177 * **sparse-checkout** (`dict`)
176 * **paths** (`list`) - List of paths to sparse checkout. (optional) 178 * **paths** (`list`) - List of paths to sparse checkout. (optional)
177 * **submodule** (`dict`) 179 * **submodule** (`dict`)
@@ -443,7 +445,8 @@ def git_extensions(xml_parent, data):
443 clone_options = ( 445 clone_options = (
444 "shallow-clone", 446 "shallow-clone",
445 "timeout", 447 "timeout",
446 "do-not-fetch-tags" 448 "do-not-fetch-tags",
449 "honor-refspec",
447 ) 450 )
448 if any(key in data for key in clone_options): 451 if any(key in data for key in clone_options):
449 ext_name = impl_prefix + 'CloneOption' 452 ext_name = impl_prefix + 'CloneOption'
@@ -465,6 +468,9 @@ def git_extensions(xml_parent, data):
465 data.get('do-not-fetch-tags', False)).lower() 468 data.get('do-not-fetch-tags', False)).lower()
466 if 'timeout' in data: 469 if 'timeout' in data:
467 XML.SubElement(ext, 'timeout').text = str(data['timeout']) 470 XML.SubElement(ext, 'timeout').text = str(data['timeout'])
471 if 'honor-refspec' in data:
472 XML.SubElement(ext, 'honorRefspec').text = str(
473 data.get('honor-refspec', False)).lower()
468 if not trait and 'sparse-checkout' in data: 474 if not trait and 'sparse-checkout' in data:
469 ext_name = impl_prefix + 'SparseCheckoutPaths' 475 ext_name = impl_prefix + 'SparseCheckoutPaths'
470 ext = XML.SubElement(xml_parent, ext_name) 476 ext = XML.SubElement(xml_parent, ext_name)
diff --git a/tests/scm/fixtures/git-cloneoptions01.xml b/tests/scm/fixtures/git-cloneoptions01.xml
index 722f773..f4e0c78 100644
--- a/tests/scm/fixtures/git-cloneoptions01.xml
+++ b/tests/scm/fixtures/git-cloneoptions01.xml
@@ -28,6 +28,7 @@
28 <shallow>false</shallow> 28 <shallow>false</shallow>
29 <depth>1</depth> 29 <depth>1</depth>
30 <noTags>true</noTags> 30 <noTags>true</noTags>
31 <honorRefspec>true</honorRefspec>
31 </hudson.plugins.git.extensions.impl.CloneOption> 32 </hudson.plugins.git.extensions.impl.CloneOption>
32 <hudson.plugins.git.extensions.impl.WipeWorkspace/> 33 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
33 </extensions> 34 </extensions>
diff --git a/tests/scm/fixtures/git-cloneoptions01.yaml b/tests/scm/fixtures/git-cloneoptions01.yaml
index 5a6a8f3..5aced6c 100644
--- a/tests/scm/fixtures/git-cloneoptions01.yaml
+++ b/tests/scm/fixtures/git-cloneoptions01.yaml
@@ -4,3 +4,4 @@ scm:
4 branches: 4 branches:
5 - master 5 - master
6 do-not-fetch-tags: true 6 do-not-fetch-tags: true
7 honor-refspec: true