From a2ad875fd755ee93654c07e3649ace72bc4a4727 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Tue, 6 Mar 2018 14:50:54 +0100 Subject: [PATCH] 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 --- jenkins_jobs/modules/scm.py | 8 +++++++- tests/scm/fixtures/git-cloneoptions01.xml | 1 + tests/scm/fixtures/git-cloneoptions01.yaml | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 519550ced..87429f8d9 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -172,6 +172,8 @@ def git(registry, xml_parent, data): * **depth** (`int`) - Set shallow clone depth (default 1) * **do-not-fetch-tags** (`bool`) - Perform a clone without tags (default false) + * **honor-refspec** (`bool`) - Perform initial clone using the refspec + defined for the repository (default false) * **sparse-checkout** (`dict`) * **paths** (`list`) - List of paths to sparse checkout. (optional) * **submodule** (`dict`) @@ -443,7 +445,8 @@ def git_extensions(xml_parent, data): clone_options = ( "shallow-clone", "timeout", - "do-not-fetch-tags" + "do-not-fetch-tags", + "honor-refspec", ) if any(key in data for key in clone_options): ext_name = impl_prefix + 'CloneOption' @@ -465,6 +468,9 @@ def git_extensions(xml_parent, data): data.get('do-not-fetch-tags', False)).lower() if 'timeout' in data: 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: ext_name = impl_prefix + 'SparseCheckoutPaths' ext = XML.SubElement(xml_parent, ext_name) diff --git a/tests/scm/fixtures/git-cloneoptions01.xml b/tests/scm/fixtures/git-cloneoptions01.xml index 722f773a7..f4e0c78b2 100644 --- a/tests/scm/fixtures/git-cloneoptions01.xml +++ b/tests/scm/fixtures/git-cloneoptions01.xml @@ -28,6 +28,7 @@ false 1 true + true diff --git a/tests/scm/fixtures/git-cloneoptions01.yaml b/tests/scm/fixtures/git-cloneoptions01.yaml index 5a6a8f3d5..5aced6c56 100644 --- a/tests/scm/fixtures/git-cloneoptions01.yaml +++ b/tests/scm/fixtures/git-cloneoptions01.yaml @@ -4,3 +4,4 @@ scm: branches: - master do-not-fetch-tags: true + honor-refspec: true