diff options
author | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-30 09:43:34 (GMT) |
---|---|---|
committer | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-30 09:43:34 (GMT) |
commit | 37e8f0d9caa2cc3f212ec3d926d53acd47c3fee1 (patch) | |
tree | e8c9072cde04ca01fb2dab8eb0ca2864aa3b3710 /devbot/git.py | |
parent | 7aab4dbe7607a89db57e10ccd0958956be4ae8ba (diff) |
Cleanup retrying
Diffstat (limited to 'devbot/git.py')
-rw-r--r-- | devbot/git.py | 17 |
1 files changed, 11 insertions, 6 deletions
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: |