Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2013-01-10 17:49:03 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2013-01-10 17:49:03 (GMT)
commit7d17eef31b434af9e4b275d9d18a2c0c261e6e07 (patch)
treeb3468a7468b06213e7dfe21fddbca18c4b08a6a8 /devbot
parent05767660ffd552fd0c231e8a265f8feb6c6e35b7 (diff)
Don't fetch unnecessarily
Diffstat (limited to 'devbot')
-rw-r--r--devbot/git.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/devbot/git.py b/devbot/git.py
index adfeb33..c5bdd44 100644
--- a/devbot/git.py
+++ b/devbot/git.py
@@ -53,12 +53,19 @@ class Module:
os.chdir(self.local)
+ if revision is None:
+ if self.tag and self._head_has_tag(self.tag):
+ return
+
+ revision = self.tag
+
+ if revision == self._get_commit_id():
+ return
+
command.run(["git", "fetch"], retry=self._retry)
if revision:
command.run(["git", "checkout", revision])
- elif self.tag:
- command.run(["git", "checkout", self.tag])
else:
command.run(["git", "merge", "--ff-only",
"origin/%s" % self._branch])
@@ -77,10 +84,6 @@ class Module:
return subprocess.check_output(["git", "describe"]).strip()
@_chdir
- def get_commit_id(self):
- return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
-
- @_chdir
def get_annotation(self, tag):
# FIXME this is fragile, there must be a better way
@@ -111,6 +114,13 @@ class Module:
return True
+ def _get_commit_id(self):
+ return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
+
+ def _head_has_tag(self, tag):
+ tags = subprocess.check_output(["git", "tag", "--points-at", "HEAD"])
+ return tag in tags.split("\n")
+
def get_module(module):
return Module(path=config.get_source_dir(),