X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=module-tools.py;h=246aab3fff30bde1021f71c55b88d79e1abd9bd7;hb=a53ac10298a865fdb9ac5f486fe218b2204d4f8e;hp=76d0fd9c1f5f6fb209752a9de4827bbd458dfaa5;hpb=c1a6fdcb3d05efb1b5eae6d7c1ef837e7d57a8f3;p=build.git diff --git a/module-tools.py b/module-tools.py index 76d0fd9c..246aab3f 100755 --- a/module-tools.py +++ b/module-tools.py @@ -125,16 +125,19 @@ class Command: class SvnRepository: + type = "svn" + def __init__(self, path, options): self.path = path self.options = options @classmethod - def checkout(remote, path): - Command("svn co %s %s" % (remote, path), self.options).run_fatal() + def checkout(cls, remote, path, options): + Command("svn co %s %s" % (remote, path), options).run_fatal() + return SvnRepository(path, options) @classmethod - def remote_exists(remote): + def remote_exists(cls, remote): return os.system("svn list %s &> /dev/null" % remote) == 0 def update(self): @@ -148,7 +151,7 @@ class SvnRepository: def is_clean(self): command="svn status %s" % self.path - return len(Command(command,self.options).output_of(True)) > 0 + return len(Command(command,self.options).output_of(True)) == 0 def is_valid(self): return os.path.exists(os.path.join(self.path, ".svn")) @@ -156,16 +159,19 @@ class SvnRepository: class GitRepository: + type = "git" + def __init__(self, path, options): self.path = path self.options = options @classmethod - def checkout(remote, path, depth=1): - Command("git clone --depth %d %s %s" % (depth, remote, path), self.options).run_fatal() + def checkout(cls, remote, path, options, depth=1): + Command("git clone --depth %d %s %s" % (depth, remote, path), options).run_fatal() + return GitRepository(path, options) @classmethod - def remote_exists(remote): + def remote_exists(cls, remote): return os.system("git --no-pager ls-remote %s &> /dev/null" % remote) == 0 def __run_in_repo(self, fun, *args):