Skip to content

Commit

Permalink
GitPoller: Allow custom refspec fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Amber Yust committed Jan 14, 2011
1 parent 8906f88 commit cad0f3f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
17 changes: 14 additions & 3 deletions master/buildbot/changes/gitpoller.py
Expand Up @@ -34,7 +34,7 @@ def __init__(self, repourl, branch='master',
workdir=None, pollInterval=10*60,
gitbin='git', usetimestamps=True,
category=None, project=None,
pollinterval=-2):
pollinterval=-2, fetch_refspec=None):
# for backward compatibility; the parameter used to be spelled with 'i'
if pollinterval != -2:
pollInterval = pollinterval
Expand All @@ -43,6 +43,7 @@ def __init__(self, repourl, branch='master',
self.repourl = repourl
self.branch = branch
self.pollInterval = pollInterval
self.fetch_refspec = fetch_refspec
self.lastChange = time.time()
self.lastPoll = time.time()
self.gitbin = gitbin
Expand Down Expand Up @@ -106,8 +107,13 @@ def git_remote_add(_):
d.addCallback(git_remote_add)

def git_fetch_origin(_):
d = utils.getProcessOutputAndValue(self.gitbin,
['fetch', 'origin'],
args = ['fetch', 'origin']
if self.fetch_refspec:
if type(self.fetch_refspec) in (list,set):
args.extend(self.fetch_refspec)
else:
args.append(self.fetch_respec)
d = utils.getProcessOutputAndValue(self.gitbin, args,
path=self.workdir, env=dict(PATH=os.environ['PATH']))
d.addCallback(self._convert_nonzero_to_failure)
d.addErrback(self._stop_on_failure)
Expand Down Expand Up @@ -216,6 +222,11 @@ def _get_changes(self):

# get a deferred object that performs the fetch
args = ['fetch', 'origin']
if self.fetch_refspec:
if type(self.fetch_refspec) in (list,set):
args.extend(self.fetch_refspec)
else:
args.append(self.fetch_respec)
# This command always produces data on stderr, but we actually do not care
# about the stderr or stdout from this command. We set errortoo=True to
# avoid an errback from the deferred. The callback which will be added to this
Expand Down
8 changes: 8 additions & 0 deletions master/docs/cfg-changesources.texinfo
Expand Up @@ -1245,6 +1245,14 @@ interval in seconds between polls, default is 10 minutes.
@item gitbin
path to the git binary, defaults to just @code{'git'}

@item fetch_refspec
One or more refspecs to use when fetching updates for the repository. By default,
the @code{GitPoller} will simply fetch all refs. If your repository is large
enough that this would be unwise (or active enough on irrelevant branches that
it'd be a waste of time to fetch them all), you may wish to specify only a certain
refs to be updated. (A single refspec may be passed as a string, or multiple refspecs
may be passed as a list or set of strings.)

@item category
Set the category to be used for the changes produced by the @code{GitPoller}.
This will then be set in any changes generated by the @code{GitPoller}, and can
Expand Down

0 comments on commit cad0f3f

Please sign in to comment.