summaryrefslogtreecommitdiff
path: root/morphlib/plugins
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-12-13 17:43:08 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-12-13 17:43:08 +0000
commit35f9111d9497160c44a5e4fa2b8a1964e68d0fd5 (patch)
treef908f10baf4ef22a2fe1b85411399ebc07848dbe /morphlib/plugins
parent2723ce3a8fa56ddec0c003e23bc037fade2ceb23 (diff)
parentbec9ecbbb7ab988488c77ea1fe995164ec0c073f (diff)
downloadmorph-35f9111d9497160c44a5e4fa2b8a1964e68d0fd5.tar.gz
Merge remote-tracking branch 'remotes/origin/samthursfield/ambiguous-refs' into baserock/merge-queue
Diffstat (limited to 'morphlib/plugins')
-rw-r--r--morphlib/plugins/branch_and_merge_plugin.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py
index a65b28ed..0c6209da 100644
--- a/morphlib/plugins/branch_and_merge_plugin.py
+++ b/morphlib/plugins/branch_and_merge_plugin.py
@@ -195,8 +195,8 @@ class BranchAndMergePlugin(cliapp.Plugin):
def resolve_ref(self, repodir, ref):
try:
- return self.app.runcmd(['git', 'show-ref', ref],
- cwd=repodir).split()[0]
+ return self.app.runcmd(['git', 'rev-parse', '--verify', ref],
+ cwd=repodir)[0:40]
except:
return None
@@ -517,11 +517,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
@@ -541,11 +545,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)