From 37e8f0d9caa2cc3f212ec3d926d53acd47c3fee1 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Fri, 30 Nov 2012 09:43:34 +0000 Subject: Cleanup retrying --- diff --git a/devbot/config.py b/devbot/config.py index 8430ccd..ed65c3a 100644 --- a/devbot/config.py +++ b/devbot/config.py @@ -56,8 +56,9 @@ class Module: return utils.get_commit_id(self.get_source_dir()) def get_git_module(self): - return git.Module(get_source_dir(), self.name, self.repo, - self.branch, self.tag) + return git.Module(path=get_source_dir(), name=self.name, + remote=self.repo, branch=self.branch, tag=self.tag, + retry=10) def _ensure_dir(dir): if not os.path.exists(dir): 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: diff --git a/tests/devbot/test_git.py b/tests/devbot/test_git.py index f5aca8e..21d81e8 100644 --- a/tests/devbot/test_git.py +++ b/tests/devbot/test_git.py @@ -51,7 +51,8 @@ class TestGit(unittest.TestCase): path = tempfile.mkdtemp() name = "test" - return git.Module(path, name, remote, branch, tag) + return git.Module(path=path, name=name, remote=remote, branch=branch, + tag=tag) def _setup_module(self): remote = self._create_repo() -- cgit v0.9.1