summaryrefslogtreecommitdiff
path: root/buildstream/plugins/sources/git.py
diff options
context:
space:
mode:
authorDaniel Playle <dplayle@bloomberg.net>2017-10-31 17:28:03 +0000
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-11-11 17:43:55 +0900
commit90850f2bdadfb582556f5783c9f47fda46e57bfb (patch)
treec1855275db5ea4791c8f1f7f00923e5bfe90a46e /buildstream/plugins/sources/git.py
parent5530bab052c25fe2c16f8f2116ca468b6a895174 (diff)
downloadbuildstream-90850f2bdadfb582556f5783c9f47fda46e57bfb.tar.gz
Change origin to point at source repo
This changes workspaces created with the git source element so that the origin remote points to the source repository of the build element as opposed to the internal repository in the bst cache. This introduces an addition of the init_workspace method in the source API. This method, which defaults to calling stage, is for the setup of the workspace after the creation of the workspace directory. This is a part of issue #53
Diffstat (limited to 'buildstream/plugins/sources/git.py')
-rw-r--r--buildstream/plugins/sources/git.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index baf159d82..d7a87c86c 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -142,8 +142,22 @@ class GitMirror():
# We need to pass '--no-hardlinks' because there's nothing to
# stop the build from overwriting the files in the .git directory
# inside the sandbox.
- self.source.call([self.source.host_git, 'clone', '--no-hardlinks', self.mirror, fullpath],
- fail="Failed to checkout git mirror {} in directory: {}".format(self.mirror, fullpath))
+ self.source.call([self.source.host_git, 'clone', '--no-checkout', '--no-hardlinks', self.mirror, fullpath],
+ fail="Failed to create git mirror {} in directory: {}".format(self.mirror, fullpath))
+
+ self.source.call([self.source.host_git, 'checkout', '--force', self.ref],
+ fail="Failed to checkout git ref {}".format(self.ref),
+ cwd=fullpath)
+
+ def init_workspace(self, directory):
+ fullpath = os.path.join(directory, self.path)
+
+ self.source.call([self.source.host_git, 'clone', '--no-checkout', self.mirror, fullpath],
+ fail="Failed to clone git mirror {} in directory: {}".format(self.mirror, fullpath))
+
+ self.source.call([self.source.host_git, 'remote', 'set-url', 'origin', self.url],
+ fail='Failed to add remote origin "{}"'.format(self.url),
+ cwd=fullpath)
self.source.call([self.source.host_git, 'checkout', '--force', self.ref],
fail="Failed to checkout git ref {}".format(self.ref),
@@ -295,6 +309,15 @@ class GitSource(Source):
self.refresh_submodules()
self.fetch_submodules()
+ def init_workspace(self, directory):
+ # XXX: may wish to refactor this as some code dupe with stage()
+ self.refresh_submodules()
+
+ with self.timed_activity('Setting up workspace "{}"'.format(directory), silent_nested=True):
+ self.mirror.init_workspace(directory)
+ for mirror in self.submodules:
+ mirror.init_workspace(directory)
+
def stage(self, directory):
# Need to refresh submodule list here again, because