From 37e8f0d9caa2cc3f212ec3d926d53acd47c3fee1 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Fri, 30 Nov 2012 09:43:34 +0000 Subject: Cleanup retrying --- (limited to 'devbot/git.py') diff --git a/devbot/git.py b/devbot/git.py index e39993a..f1a7acc 100644 --- a/devbot/git.py +++ b/devbot/git.py @@ -3,7 +3,11 @@ import os from devbot import command class Module: - def __init__(self, path, name, remote, branch="master", tag=None): + def __init__(self, path=None, name=None, remote=None, + branch="master", tag=None, retry=10): + if path is None or name is None or remote is None: + raise RuntimeError("path, name and remote are required") + self.remote = remote self.local = os.path.join(path, name) self.tag = tag @@ -11,13 +15,13 @@ class Module: self._path = path self._name = name self._branch = branch + self._retry = 10 def _clone(self): os.chdir(self._path) - command.run(["git", "clone", "--progress", - self.remote, self._name], - retry=10) + command.run(["git", "clone", "--progress", self.remote, self._name], + retry=self._retry) os.chdir(self.local) @@ -30,12 +34,13 @@ class Module: os.chdir(self.local) - command.run(["git", "fetch"]) + command.run(["git", "fetch"], retry=self._retry) if self.tag: command.run(["git", "checkout", self.tag]) else: - command.run(["git", "merge", "--ff-only", "origin", self._branch]) + command.run(["git", "merge", "--ff-only", "origin", self._branch], + retry=self._retry) def clean(self): try: -- cgit v0.9.1