changeset 6460:63460acc2569

pullrequests: refactor default title code This refactoring simply emphasizes that the origin reference used to generate the default title is not always the same as the one actually used to create the pull request; for PRs not from a branch head, the branch name is stored so it can be used for creating new iterations.
author Søren Løvborg <sorenl@unity3d.com>
date Fri, 06 Jan 2017 14:57:19 +0100
parents 175813f77851
children a918c4c5a841
files kallithea/controllers/pullrequests.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/pullrequests.py	Sat Jan 14 20:59:57 2017 +0100
+++ b/kallithea/controllers/pullrequests.py	Fri Jan 06 14:57:19 2017 +0100
@@ -327,6 +327,7 @@
         (org_ref_type,
          org_ref_name,
          org_rev) = org_ref.split(':')
+        org_display = h.short_ref(org_ref_type, org_ref_name)
         if org_ref_type == 'rev':
             cs = org_repo.scm_instance.get_changeset(org_rev)
             org_ref = 'branch:%s:%s' % (cs.branch, cs.raw_id)
@@ -341,6 +342,7 @@
             cs = other_repo.scm_instance.get_changeset(other_rev)
             other_ref_name = cs.raw_id[:12]
             other_ref = '%s:%s:%s' % (other_ref_type, other_ref_name, cs.raw_id)
+        other_display = h.short_ref(other_ref_type, other_ref_name)
 
         cs_ranges, _cs_ranges_not, ancestor_revs = \
             CompareController._get_changesets(org_repo.scm_instance.alias,
@@ -373,11 +375,10 @@
         title = _form['pullrequest_title']
         if not title:
             if org_repo_name == other_repo_name:
-                title = '%s to %s' % (h.short_ref(org_ref_type, org_ref_name),
-                                      h.short_ref(other_ref_type, other_ref_name))
+                title = '%s to %s' % (org_display, other_display)
             else:
-                title = '%s#%s to %s#%s' % (org_repo_name, h.short_ref(org_ref_type, org_ref_name),
-                                            other_repo_name, h.short_ref(other_ref_type, other_ref_name))
+                title = '%s#%s to %s#%s' % (org_repo_name, org_display,
+                                            other_repo_name, other_display)
         description = _form['pullrequest_desc'].strip() or _('No description')
         try:
             created_by = User.get(request.authuser.user_id)