Skip to content

Commit

Permalink
Fix for the bug #2222. Git source checkout steps support reference re…
Browse files Browse the repository at this point in the history
…positories
  • Loading branch information
srinupiits committed May 6, 2013
1 parent 39fe2d6 commit 1d00cb3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
17 changes: 11 additions & 6 deletions master/buildbot/steps/source/git.py
Expand Up @@ -57,12 +57,11 @@ def isTrueOrIsExactlyZero(v):
class Git(Source):
""" Class for Git with all the smarts """
name='git'
renderables = [ "repourl"]
renderables = [ "repourl", "reference"]

def __init__(self, repourl=None, branch='HEAD', mode='incremental',
method=None, submodules=False, shallow=False, progress=False,
retryFetch=False, clobberOnFailure=False, getDescription=False,
config=None, **kwargs):
def __init__(self, repourl=None, branch='HEAD', mode='incremental', method=None,
reference=None, submodules=False, shallow=False, progress=False, retryFetch=False,
clobberOnFailure=False, getDescription=False, config=None, **kwargs):
"""
@type repourl: string
@param repourl: the URL which points at the git repository
Expand All @@ -83,10 +82,14 @@ def __init__(self, repourl=None, branch='HEAD', mode='incremental',
@param method: Full builds can be done is different ways. This parameter
specifies which method to use.
@type reference: string
@param reference: If available use a reference repo.
Uses `--reference` in git command. Refer `git clone --help`
@type progress: boolean
@param progress: Pass the --progress option when fetching. This
can solve long fetches getting killed due to
lack of output, but requires Git 1.7.2+.
@type shallow: boolean
@param shallow: Use a shallow or clone, if possible
Expand All @@ -106,6 +109,7 @@ def __init__(self, repourl=None, branch='HEAD', mode='incremental',
self.method = method
self.prog = progress
self.repourl = repourl
self.reference = reference
self.retryFetch = retryFetch
self.submodules = submodules
self.shallow = shallow
Expand Down Expand Up @@ -381,9 +385,10 @@ def _fullClone(self, shallowClone=False):
args += ['--branch', self.branch]
if shallowClone:
args += ['--depth', '1']
if self.reference:
args += ['--reference', self.reference]
command = ['clone'] + args + [self.repourl, '.']

#Fix references
if self.prog:
command.append('--progress')

Expand Down
25 changes: 25 additions & 0 deletions master/buildbot/test/unit/test_steps_source_git.py
Expand Up @@ -290,6 +290,31 @@ def test_mode_full_clean_no_existing_repo(self):
self.expectOutcome(result=SUCCESS, status_text=["update"])
return self.runStep()

def test_mode_full_clean_no_existing_repo_with_reference(self):
self.setupStep(
git.Git(repourl='http://github.com/buildbot/buildbot.git',
mode='full', method='clean', reference='path/to/reference/repo'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['git', '--version'])
+ 0,

Expect('stat', dict(file='wkdir/.git',
logEnviron=True))
+ 1,
ExpectShell(workdir='wkdir',
command=['git', 'clone', '--reference', 'path/to/reference/repo',
'http://github.com/buildbot/buildbot.git', '.'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'rev-parse', 'HEAD'])
+ ExpectShell.log('stdio',
stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
+ 0,
)
self.expectOutcome(result=SUCCESS, status_text=["update"])
return self.runStep()

def test_mode_full_clean_no_existing_repo_branch(self):
self.setupStep(
git.Git(repourl='http://github.com/buildbot/buildbot.git',
Expand Down
5 changes: 5 additions & 0 deletions master/docs/manual/cfg-buildsteps.rst
Expand Up @@ -348,6 +348,11 @@ The Git step takes the following arguments:
(optional): instructs git to attempt shallow clones (``--depth 1``).
This option can be used only in full builds with clobber method.

``reference``
(optional): use the specified string as a path to a reference
repository on the local machine. Git will try to grab objects from
this path first instead of the main repository, if they exist.

``progress``
(optional): passes the (``--progress``) flag to (:command:`git
fetch`). This solves issues of long fetches being killed due to
Expand Down
2 changes: 2 additions & 0 deletions master/docs/relnotes/index.rst
Expand Up @@ -18,6 +18,8 @@ Features

* Builder configurations can now include a ``description``, which will appear in the web UI to help humans figure out what the builder does.

* Git source checkout step now supports reference repositories.

Deprecations, Removals, and Non-Compatible Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 1d00cb3

Please sign in to comment.