From 59df9bd4d22715b03d1b765321021a59ebc9366b Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Thu, 29 Nov 2012 22:26:08 +0000 Subject: Git clean not out-of-source modules instead of removing --- (limited to 'devbot') diff --git a/devbot/build.py b/devbot/build.py index e958078..8740927 100644 --- a/devbot/build.py +++ b/devbot/build.py @@ -8,7 +8,6 @@ import time from devbot import command from devbot import config from devbot import environ -from devbot import git from devbot import state from devbot import utils @@ -78,7 +77,8 @@ def clean(): for module in config.load_modules(): if not module.out_of_source: - _rmtree(module.get_source_dir()) + if module.get_git_module().clean(): + print "Cleaned %s git repository." % module.name def _unlink_libtool_files(): def func(arg, dirname, fnames): @@ -91,9 +91,7 @@ def _pull_module(module): print "\n=== Pulling %s ===\n" % module.name try: - git_module = git.Module(config.get_source_dir(), module.name, - module.repo, module.tag) - git_module.update() + module.get_git_module().update() except subprocess.CalledProcessError: return False diff --git a/devbot/config.py b/devbot/config.py index 0f76644..cece353 100644 --- a/devbot/config.py +++ b/devbot/config.py @@ -7,6 +7,7 @@ import tempfile from devbot import distro from devbot import utils from devbot import plugins +from devbot import git devbot_dir = None config_dir = None @@ -54,6 +55,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.tag) + def _ensure_dir(dir): if not os.path.exists(dir): os.mkdir(dir) diff --git a/devbot/git.py b/devbot/git.py index 55fd9f5..8db61d2 100644 --- a/devbot/git.py +++ b/devbot/git.py @@ -36,3 +36,13 @@ class Module: command.run(["git", "checkout", self.tag]) else: command.run(["git", "merge", "origin", self._branch]) + + def clean(self): + try: + os.chdir(self.local) + except OSError: + return False + + command.run(["git", "clean", "-fdx"]) + + return True -- cgit v0.9.1