Added support for Git shallow clone parameter

Change-Id: Ia0251f25ff22fff10fe53ba6bf54f0e9072210fd
This commit is contained in:
Felipe Reyes 2013-10-01 18:33:06 -03:00 committed by Antoine Musso
parent 894c72efcf
commit f9cdbfd4d3
9 changed files with 166 additions and 0 deletions

View File

@ -66,6 +66,7 @@ def git(self, xml_parent, data):
:arg str basedir: location relative to the workspace root to clone to :arg str basedir: location relative to the workspace root to clone to
(default: workspace) (default: workspace)
:arg bool skip-tag: Skip tagging :arg bool skip-tag: Skip tagging
:arg bool shallow-clone: Perform shallow clone
:arg bool prune: Prune remote branches :arg bool prune: Prune remote branches
:arg bool clean: Clean after checkout :arg bool clean: Clean after checkout
:arg bool fastpoll: Use fast remote polling :arg bool fastpoll: Use fast remote polling
@ -131,6 +132,7 @@ def git(self, xml_parent, data):
("git-config-email", 'gitConfigEmail', ''), ("git-config-email", 'gitConfigEmail', ''),
('skip-tag', 'skipTag', False), ('skip-tag', 'skipTag', False),
('scm-name', 'scmName', ''), ('scm-name', 'scmName', ''),
("shallow-clone", "useShallowClone", False),
] ]
choosing_strategies = { choosing_strategies = {

0
tests/scm/__init__.py Normal file
View File

View File

@ -0,0 +1,37 @@
<?xml version="1.0" ?>
<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://github.com/openstack-infra/jenkins-job-builder.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<excludedUsers/>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>true</clean>
<wipeOutWorkspace>true</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir/>
<reference/>
<gitConfigName/>
<gitConfigEmail/>
<skipTag>false</skipTag>
<scmName/>
<useShallowClone>true</useShallowClone>
</scm>
</project>

View File

@ -0,0 +1,8 @@
# vim: sw=4 ts=4 et
scm:
- git:
url: https://github.com/openstack-infra/jenkins-job-builder.git
branches:
- master
clean: true
shallow-clone: true

View File

@ -0,0 +1,37 @@
<?xml version="1.0" ?>
<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://github.com/openstack-infra/jenkins-job-builder.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<excludedUsers/>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>true</clean>
<wipeOutWorkspace>true</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir/>
<reference/>
<gitConfigName/>
<gitConfigEmail/>
<skipTag>false</skipTag>
<scmName/>
<useShallowClone>false</useShallowClone>
</scm>
</project>

View File

@ -0,0 +1,8 @@
# vim: sw=4 ts=4 et
scm:
- git:
url: https://github.com/openstack-infra/jenkins-job-builder.git
branches:
- master
clean: true
shallow-clone: false

View File

@ -0,0 +1,37 @@
<?xml version="1.0" ?>
<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://github.com/openstack-infra/jenkins-job-builder.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<excludedUsers/>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>true</clean>
<wipeOutWorkspace>true</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir/>
<reference/>
<gitConfigName/>
<gitConfigEmail/>
<skipTag>false</skipTag>
<scmName/>
<useShallowClone>false</useShallowClone>
</scm>
</project>

View File

@ -0,0 +1,7 @@
# vim: sw=4 ts=4 et
scm:
- git:
url: https://github.com/openstack-infra/jenkins-job-builder.git
branches:
- master
clean: true

30
tests/scm/test_scm.py Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python
#
# Joint copyright:
# - Copyright 2012,2013 Wikimedia Foundation
# - Copyright 2012,2013 Antoine "hashar" Musso
# - Copyright 2013 Arnaud Fabre
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
from testscenarios.testcase import TestWithScenarios
from testtools import TestCase
from jenkins_jobs.modules import scm
from tests.base import get_scenarios, BaseTestCase
class TestCaseModuleScm(TestWithScenarios, TestCase, BaseTestCase):
fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures')
scenarios = get_scenarios(fixtures_path)
klass = scm.SCM