diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-12-13 14:23:33 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-12-13 15:37:54 +0000 |
commit | bec9ecbbb7ab988488c77ea1fe995164ec0c073f (patch) | |
tree | d1cfa253711a26d99700d21943ee20e4d1e184f0 /morphlib/plugins/branch_and_merge_plugin.py | |
parent | 351bfaf77e7a424053700f0d68a941e177215b59 (diff) | |
download | morph-bec9ecbbb7ab988488c77ea1fe995164ec0c073f.tar.gz |
morph branch: Check if the ref already exists before anything else
This was done to ensure tests.branching/branch-fails-if-branch-exists
always passes, but also seems like the right approach in general.
Diffstat (limited to 'morphlib/plugins/branch_and_merge_plugin.py')
-rw-r--r-- | morphlib/plugins/branch_and_merge_plugin.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index 31b661b6..e6b78475 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -516,11 +516,15 @@ class BranchAndMergePlugin(cliapp.Plugin): new_branch = args[1] commit = 'master' if len(args) == 2 else args[2] + self.lrc, self.rrc = morphlib.util.new_repo_caches(self.app) + if self.lrc.get_repo(repo).ref_exists(new_branch): + raise cliapp.AppException('branch %s already exists in ' + 'repository %s' % (new_branch, repo)) + # Create the system branch directory. workspace = self.deduce_workspace() branch_dir = os.path.join(workspace, new_branch) os.makedirs(branch_dir) - self.lrc, self.rrc = morphlib.util.new_repo_caches(self.app) try: # Create a .morph-system-branch directory to clearly identify @@ -540,11 +544,6 @@ class BranchAndMergePlugin(cliapp.Plugin): repo_dir = os.path.join(branch_dir, self.convert_uri_to_path(repo)) self.clone_to_directory(repo_dir, repo, commit) - # Check if branch already exists locally or in a remote - if self.resolve_ref(repo_dir, new_branch) is not None: - raise cliapp.AppException('branch %s already exists in ' - 'repository %s' % (new_branch, repo)) - # Create a new branch in the local morphs repository. self.app.runcmd(['git', 'checkout', '-b', new_branch, commit], cwd=repo_dir) |