Set reference repo under clone options
When we have cloneOptions in the generated with options like tags and reference filled outside of cloneOptions, The reference is not filled in the job configuration and this option will not work as expected. reference should alwasy be listed inside CloneOptions. Change-Id: I519d3c42f1b32ab27243b0f5c592e3d41e3230bb Signed-off-by: Vishal Bhoj <vishal.bhoj@linaro.org>
This commit is contained in:
@@ -447,6 +447,7 @@ def git_extensions(xml_parent, data):
|
|||||||
"timeout",
|
"timeout",
|
||||||
"do-not-fetch-tags",
|
"do-not-fetch-tags",
|
||||||
"honor-refspec",
|
"honor-refspec",
|
||||||
|
"reference-repo",
|
||||||
)
|
)
|
||||||
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'
|
||||||
@@ -471,6 +472,8 @@ def git_extensions(xml_parent, data):
|
|||||||
if 'honor-refspec' in data:
|
if 'honor-refspec' in data:
|
||||||
XML.SubElement(ext, 'honorRefspec').text = str(
|
XML.SubElement(ext, 'honorRefspec').text = str(
|
||||||
data.get('honor-refspec', False)).lower()
|
data.get('honor-refspec', False)).lower()
|
||||||
|
if 'reference-repo' in data:
|
||||||
|
XML.SubElement(ext, 'reference').text = str(data['reference-repo'])
|
||||||
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)
|
||||||
|
|||||||
35
tests/scm/fixtures/git-extensions-reference-repo.xml
Normal file
35
tests/scm/fixtures/git-extensions-reference-repo.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<scm class="hudson.plugins.git.GitSCM">
|
||||||
|
<configVersion>2</configVersion>
|
||||||
|
<userRemoteConfigs>
|
||||||
|
<hudson.plugins.git.UserRemoteConfig>
|
||||||
|
<name>origin</name>
|
||||||
|
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
|
||||||
|
<url>https://example.com/project.git</url>
|
||||||
|
</hudson.plugins.git.UserRemoteConfig>
|
||||||
|
</userRemoteConfigs>
|
||||||
|
<branches>
|
||||||
|
<hudson.plugins.git.BranchSpec>
|
||||||
|
<name>**</name>
|
||||||
|
</hudson.plugins.git.BranchSpec>
|
||||||
|
</branches>
|
||||||
|
<disableSubmodules>false</disableSubmodules>
|
||||||
|
<recursiveSubmodules>false</recursiveSubmodules>
|
||||||
|
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||||
|
<remotePoll>false</remotePoll>
|
||||||
|
<gitTool>Default</gitTool>
|
||||||
|
<submoduleCfg class="list"/>
|
||||||
|
<reference>/path/to/reference/repo.git</reference>
|
||||||
|
<gitConfigName/>
|
||||||
|
<gitConfigEmail/>
|
||||||
|
<extensions>
|
||||||
|
<hudson.plugins.git.extensions.impl.CloneOption>
|
||||||
|
<shallow>false</shallow>
|
||||||
|
<depth>1</depth>
|
||||||
|
<reference>/path/to/reference/repo.git</reference>
|
||||||
|
</hudson.plugins.git.extensions.impl.CloneOption>
|
||||||
|
<hudson.plugins.git.extensions.impl.WipeWorkspace/>
|
||||||
|
</extensions>
|
||||||
|
</scm>
|
||||||
|
</project>
|
||||||
4
tests/scm/fixtures/git-extensions-reference-repo.yaml
Normal file
4
tests/scm/fixtures/git-extensions-reference-repo.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
scm:
|
||||||
|
- git:
|
||||||
|
url: https://example.com/project.git
|
||||||
|
reference-repo: /path/to/reference/repo.git
|
||||||
Reference in New Issue
Block a user