diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-11-12 17:28:57 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-11-12 17:28:57 +0000 |
commit | 2ac6f661130322e63b8d2737145ea11d445aaa79 (patch) | |
tree | dd30179d22c09cc73898d7db6218e0d620d74ac8 /morphlib/plugins | |
parent | 19b16a2cc6d67871d0a4298354eb446ada136a8e (diff) | |
parent | a5b913a83db94380fc91d15571f55cbf7b5c741b (diff) | |
download | morph-2ac6f661130322e63b8d2737145ea11d445aaa79.tar.gz |
Merge branch 'samthursfield/build-without-push' of git://git.baserock.org/baserock/morph
Diffstat (limited to 'morphlib/plugins')
-rw-r--r-- | morphlib/plugins/branch_and_merge_plugin.py | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index 21a5970c..efaa8dfe 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -1126,6 +1126,11 @@ class BranchAndMergePlugin(cliapp.Plugin): # Generate a UUID for the build. build_uuid = uuid.uuid4().hex + build_command = morphlib.buildcommand.BuildCommand(self.app) + build_command = self.app.hookmgr.call('new-build-command', + build_command) + push = self.app.settings['push-build-branches'] + self.app.status(msg='Starting build %(uuid)s', uuid=build_uuid) self.app.status(msg='Collecting morphologies involved in ' @@ -1143,26 +1148,34 @@ class BranchAndMergePlugin(cliapp.Plugin): # Create the build refs for all these repositories and commit # all uncommitted changes to them, updating all references # to system branch refs to point to the build refs instead. - self.update_build_refs(build_repos, branch, build_uuid) + self.update_build_refs(build_repos, branch, build_uuid, push) - # Push the temporary build refs. - self.push_build_refs(build_repos) + if push: + self.push_build_refs(build_repos) + build_branch_root = branch_root + else: + dirname = build_repos[branch_root]['dirname'] + build_branch_root = urlparse.urljoin('file://', dirname) # Run the build. - build_command = morphlib.buildcommand.BuildCommand(self.app) - build_command = self.app.hookmgr.call('new-build-command', - build_command) - build_command.build([branch_root, + build_command.build([build_branch_root, build_repos[branch_root]['build-ref'], system_name]) - # Delete the temporary refs on the server. - self.delete_remote_build_refs(build_repos) + if push: + self.delete_remote_build_refs(build_repos) self.app.status(msg='Finished build %(uuid)s', uuid=build_uuid) def get_system_build_repos(self, system_branch, branch_dir, branch_root, system_name): + '''Map upstream repository URLs to their checkouts in the system branch + + Also provides the list of morphologies stored in each repository, + grouped by kind. + + ''' + build_repos = {} def prepare_repo_info(repo, dirname): @@ -1205,7 +1218,7 @@ class BranchAndMergePlugin(cliapp.Plugin): return build_repos - def inject_build_refs(self, morphology, build_repos): + def inject_build_refs(self, morphology, build_repos, will_push): # Starting from a system or stratum morphology, update all ref # pointers of strata or chunks involved in a system build (represented # by build_repos) to point to temporary build refs of the repos @@ -1215,6 +1228,9 @@ class BranchAndMergePlugin(cliapp.Plugin): info['morph'] in build_repos[info['repo']]['strata'] or info['morph'] in build_repos[info['repo']]['chunks']): info['ref'] = build_repos[info['repo']]['build-ref'] + if not will_push: + dirname = build_repos[info['repo']]['dirname'] + info['repo'] = urlparse.urljoin('file://', dirname) if morphology['kind'] == 'system': for info in morphology['strata']: inject_build_ref(info) @@ -1230,7 +1246,10 @@ class BranchAndMergePlugin(cliapp.Plugin): branch_uuid, repo_uuid) info['build-ref'] = build_ref - def update_build_refs(self, build_repos, system_branch, build_uuid): + def update_build_refs(self, build_repos, system_branch, build_uuid, + will_push): + '''Update build branches for each repository with any local changes ''' + # Define the committer. committer_name = 'Morph (on behalf of %s)' % \ (morphlib.git.get_user_name(self.app.runcmd)) @@ -1282,7 +1301,7 @@ class BranchAndMergePlugin(cliapp.Plugin): for filename in filenames: # Inject temporary refs in the right places in each morphology. morphology = self.load_morphology(repo_dir, filename) - self.inject_build_refs(morphology, build_repos) + self.inject_build_refs(morphology, build_repos, will_push) handle, tmpfile = tempfile.mkstemp(suffix='.morph') self.save_morphology(repo_dir, tmpfile, morphology) |