summaryrefslogtreecommitdiff
path: root/buildstream/plugins/sources/git.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-01-04 14:26:32 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-01-04 14:30:21 -0500
commitec835b29406f9c153025e94aa8141695ca2cefeb (patch)
tree9ec71dbfbf231ef352651751fd1b511047db4cf4 /buildstream/plugins/sources/git.py
parent7f1d7bca09f46dfea029a28a1f409b36ed48a831 (diff)
downloadbuildstream-ec835b29406f9c153025e94aa8141695ca2cefeb.tar.gz
git plugin: Dont require the ref to exist after fetching
This is needed for refresh functionality.
Diffstat (limited to 'buildstream/plugins/sources/git.py')
-rw-r--r--buildstream/plugins/sources/git.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index 850c41635..3b70f0558 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -123,17 +123,17 @@ class GitMirror():
raise SourceError("%s: Failed to fetch from remote git repository: '%s'" %
(str(self.source), self.url))
- # It is an error if the expected ref is not found in the mirror
- if not self.has_ref():
- raise SourceError("%s: expected ref '%s' was not found in git repository: '%s'" %
- (str(self.source), self.ref, self.url))
-
def has_ref(self):
with open(os.devnull, "w") as fnull:
out = subprocess.call([self.source.host_git, 'cat-file', '-t', self.ref],
cwd=self.mirror, stdout=fnull, stderr=fnull)
return out == 0
+ def assert_ref(self):
+ if not self.has_ref():
+ raise SourceError("%s: expected ref '%s' was not found in git repository: '%s'" %
+ (str(self.source), self.ref, self.url))
+
def latest_commit(self, tracking):
with open(os.devnull, "w") as fnull:
output = subprocess.check_output([self.source.host_git, 'rev-parse', tracking],
@@ -259,6 +259,7 @@ class GitSource(Source):
self.mirror.ensure()
self.mirror.fetch()
node['ref'] = self.mirror.ref = self.mirror.latest_commit(self.track)
+ self.mirror.assert_ref()
# After refreshing we may have a new ref, so we need to ensure
# that we've cached the desired refs in our mirrors of submodules.
@@ -272,6 +273,7 @@ class GitSource(Source):
self.mirror.ensure()
if not self.mirror.has_ref():
self.mirror.fetch()
+ self.mirror.assert_ref()
# Here after performing any fetches, we need to also ensure that
# we've cached the desired refs in our mirrors of submodules.
@@ -328,6 +330,7 @@ class GitSource(Source):
mirror.ensure()
if not mirror.has_ref():
mirror.fetch()
+ mirror.assert_ref()
# Plugin entry point