← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:friendly-git-ref-names into launchpad:master

 

Tom Wardill has proposed merging ~twom/launchpad:friendly-git-ref-names into launchpad:master.

Commit message:
Fix failures in friendly git ref names

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/380302
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:friendly-git-ref-names into launchpad:master.
diff --git a/lib/lp/code/browser/gitref.py b/lib/lp/code/browser/gitref.py
index 99d4882..25021bc 100644
--- a/lib/lp/code/browser/gitref.py
+++ b/lib/lp/code/browser/gitref.py
@@ -288,7 +288,7 @@ class GitRefRegisterMergeProposalView(LaunchpadFormView):
         # If we have a target, and the user hasn't entered a value.
         if term and not self.widgets['target_git_path'].hasInput():
             branch_display = term.value.default_branch
-            if branch_display.startswith("refs/heads/"):
+            if branch_display and branch_display.startswith("refs/heads/"):
                 branch_display = branch_display[len("refs/heads/"):]
             self.widgets['target_git_path'].setRenderedValue(branch_display)
 
diff --git a/lib/lp/code/browser/tests/test_branchmergeproposal.py b/lib/lp/code/browser/tests/test_branchmergeproposal.py
index 2e3055a..e42a9c5 100644
--- a/lib/lp/code/browser/tests/test_branchmergeproposal.py
+++ b/lib/lp/code/browser/tests/test_branchmergeproposal.py
@@ -869,7 +869,7 @@ class TestRegisterBranchMergeProposalViewGit(
             target_branch.repository)._default_branch = target_branch.path
         view = self._createView()
         self.assertEqual(
-            target_branch.repository.default_branch,
+            target_branch.repository.default_branch.split('/')[-1],
             view.widgets['target_git_path']._getCurrentValue())
 
     def test_default_branch_no_default_set(self):