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
This commit is contained in:
Ladislav Thon 2018-03-06 14:50:54 +01:00 committed by Sergii Kipot
parent c59b5a5258
commit a2ad875fd7
3 changed files with 9 additions and 1 deletions

View File

@ -172,6 +172,8 @@ def git(registry, xml_parent, data):
* **depth** (`int`) - Set shallow clone depth (default 1) * **depth** (`int`) - Set shallow clone depth (default 1)
* **do-not-fetch-tags** (`bool`) - Perform a clone without tags * **do-not-fetch-tags** (`bool`) - Perform a clone without tags
(default false) (default false)
* **honor-refspec** (`bool`) - Perform initial clone using the refspec
defined for the repository (default false)
* **sparse-checkout** (`dict`) * **sparse-checkout** (`dict`)
* **paths** (`list`) - List of paths to sparse checkout. (optional) * **paths** (`list`) - List of paths to sparse checkout. (optional)
* **submodule** (`dict`) * **submodule** (`dict`)
@ -443,7 +445,8 @@ def git_extensions(xml_parent, data):
clone_options = ( clone_options = (
"shallow-clone", "shallow-clone",
"timeout", "timeout",
"do-not-fetch-tags" "do-not-fetch-tags",
"honor-refspec",
) )
if any(key in data for key in clone_options): if any(key in data for key in clone_options):
ext_name = impl_prefix + 'CloneOption' ext_name = impl_prefix + 'CloneOption'
@ -465,6 +468,9 @@ def git_extensions(xml_parent, data):
data.get('do-not-fetch-tags', False)).lower() data.get('do-not-fetch-tags', False)).lower()
if 'timeout' in data: if 'timeout' in data:
XML.SubElement(ext, 'timeout').text = str(data['timeout']) XML.SubElement(ext, 'timeout').text = str(data['timeout'])
if 'honor-refspec' in data:
XML.SubElement(ext, 'honorRefspec').text = str(
data.get('honor-refspec', False)).lower()
if not trait and 'sparse-checkout' in data: if not trait and 'sparse-checkout' in data:
ext_name = impl_prefix + 'SparseCheckoutPaths' ext_name = impl_prefix + 'SparseCheckoutPaths'
ext = XML.SubElement(xml_parent, ext_name) ext = XML.SubElement(xml_parent, ext_name)

View File

@ -28,6 +28,7 @@
<shallow>false</shallow> <shallow>false</shallow>
<depth>1</depth> <depth>1</depth>
<noTags>true</noTags> <noTags>true</noTags>
<honorRefspec>true</honorRefspec>
</hudson.plugins.git.extensions.impl.CloneOption> </hudson.plugins.git.extensions.impl.CloneOption>
<hudson.plugins.git.extensions.impl.WipeWorkspace/> <hudson.plugins.git.extensions.impl.WipeWorkspace/>
</extensions> </extensions>

View File

@ -4,3 +4,4 @@ scm:
branches: branches:
- master - master
do-not-fetch-tags: true do-not-fetch-tags: true
honor-refspec: true