diff options
author | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-29 00:58:31 (GMT) |
---|---|---|
committer | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-29 00:58:31 (GMT) |
commit | 45668b15dc58fa524b4f0018669d5420c3857051 (patch) | |
tree | f543d361c8a3d78a8891d075900d6382f858d748 | |
parent | eb5a527d79b2b1cadc23298a15e6cb88eb845af1 (diff) |
Rework module updating
-rw-r--r-- | devbot/build.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/devbot/build.py b/devbot/build.py index 7b2e9b4..9c616aa 100644 --- a/devbot/build.py +++ b/devbot/build.py @@ -9,6 +9,7 @@ from devbot import command from devbot import config from devbot import environ from devbot import state +from devbot import utils def build_one(module_name): environ.setup() @@ -85,6 +86,11 @@ def _unlink_libtool_files(): os.path.walk(config.lib_dir, func, None) +def _is_detached_head(): + return subprocess.call(["git", "symbolic-ref", "-q", "HEAD"], + stdout=utils.devnull, + stderr=subprocess.STDOUT) != 0 + def _pull_git_module(module): module_dir = module.get_source_dir() @@ -92,14 +98,21 @@ def _pull_git_module(module): os.chdir(module_dir) command.run(["git", "remote", "set-url", "origin", module.repo]) - command.run(["git", "remote", "update", "origin"], retry=10) + + if _is_detached_head(): + command.run(["git", "remote", "update", "origin"], retry=10) + command.run(["git", "checkout", module.branch]) + else: + command.run(["git", "checkout", module.branch]) + command.run(["git", "pull"], retry=10) else: os.chdir(config.get_source_dir()) + command.run(["git", "clone", "--progress", module.repo, module.name], retry=10) - os.chdir(module_dir) - command.run(["git", "checkout", module.branch]) + os.chdir(module_dir) + command.run(["git", "checkout", module.branch]) def _pull_module(module): print "\n=== Pulling %s ===\n" % module.name |