# HG changeset patch # User Thomas De Schampheleire <[email protected]> # Date 1429265659 -7200 # Fri Apr 17 12:14:19 2015 +0200 # Node ID 6e760af6050e567239155a7a43b5ab02eddf877d # Parent 32de32f6946110ecd0b8d2c79f0270025f3afaca pullrequests: add support for custom pull request id prefix
Currently, a pull request id is referenced as #5, and the '#' symbol is fixed. This commit adds a configuration parameter 'pull_request_prefix', defaulting to '#', that can be used to customize the prefix. For example, one could use 'PR-' to create references of the form 'PR-5'. diff --git a/development.ini b/development.ini --- a/development.ini +++ b/development.ini @@ -248,6 +248,10 @@ #issue_server_link_wiki = https://mywiki.com/{id} #issue_prefix_wiki = WIKI- +## pullrequest id prefix +## a prefix key to use when referring to pull request IDs. For example, using +## '#' will give '#5' while using 'PR-' will give 'PR-5'. +pull_request_prefix = # ## instance-id prefix ## a prefix key for this instance used for cache invalidation when running diff --git a/kallithea/bin/template.ini.mako b/kallithea/bin/template.ini.mako --- a/kallithea/bin/template.ini.mako +++ b/kallithea/bin/template.ini.mako @@ -245,6 +245,10 @@ #issue_server_link_wiki = https://mywiki.com/{id} #issue_prefix_wiki = WIKI- +<%text>## pullrequest id prefix</%text> +<%text>## a prefix key to use when referring to pull request IDs. For example, using</%text> +<%text>## '#' will give '#5' while using 'PR-' will give 'PR-5'.</%text> +pull_request_prefix = # <%text>## instance-id prefix</%text> <%text>## a prefix key for this instance used for cache invalidation when running</%text> diff --git a/kallithea/config/deployment.ini_tmpl b/kallithea/config/deployment.ini_tmpl --- a/kallithea/config/deployment.ini_tmpl +++ b/kallithea/config/deployment.ini_tmpl @@ -242,6 +242,10 @@ #issue_server_link_wiki = https://mywiki.com/{id} #issue_prefix_wiki = WIKI- +## pullrequest id prefix +## a prefix key to use when referring to pull request IDs. For example, using +## '#' will give '#5' while using 'PR-' will give 'PR-5'. +pull_request_prefix = # ## instance-id prefix ## a prefix key for this instance used for cache invalidation when running diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py +++ b/kallithea/lib/helpers.py @@ -741,7 +741,7 @@ repo_name = user_log.repository_name else: repo_name = user_log.repository.repo_name - return link_to(_('Pull request #%s') % pull_request_id, + return link_to(_('Pull request %s') % pull_request_reference(pull_request_id), url('pullrequest_show', repo_name=repo_name, pull_request_id=pull_request_id)) @@ -1414,6 +1414,10 @@ def changeset_status_lbl(changeset_status): return dict(ChangesetStatus.STATUSES).get(changeset_status) +def pull_request_reference(pull_request_id): + from kallithea import CONFIG + pull_request_prefix = CONFIG.get('pull_request_prefix', '#') + return '%s%s' % (pull_request_prefix, pull_request_id) def get_permission_name(key): return dict(Permission.PERMS).get(key) diff --git a/kallithea/model/comment.py b/kallithea/model/comment.py --- a/kallithea/model/comment.py +++ b/kallithea/model/comment.py @@ -130,9 +130,9 @@ comment_url = pull_request.url(canonical=True, anchor='comment-%s' % comment.comment_id) subj = safe_unicode( - h.link_to('Re pull request #%(pr_id)s: %(desc)s %(line)s' % \ + h.link_to('Re pull request %(pr_id)s: %(desc)s %(line)s' % \ {'desc': desc, - 'pr_id': comment.pull_request.pull_request_id, + 'pr_id': h.pull_request_reference(comment.pull_request.pull_request_id), 'line': line}, comment_url) ) @@ -148,7 +148,7 @@ #set some variables for email notification email_kwargs = { 'pr_title': pull_request.title, - 'pr_id': pull_request.pull_request_id, + 'pr_id': h.pull_request_reference(pull_request.pull_request_id), 'status_change': status_change, 'closing_pr': closing_pr, 'pr_comment_url': comment_url, diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py --- a/kallithea/model/notification.py +++ b/kallithea/model/notification.py @@ -298,8 +298,8 @@ # self.TYPE_PASSWORD_RESET self.TYPE_REGISTRATION: _('New user %(new_username)s registered'), # self.TYPE_DEFAULT - self.TYPE_PULL_REQUEST: _('Review request on %(repo_name)s pull request #%(pr_id)s from %(ref)s by %(pr_username)s'), - self.TYPE_PULL_REQUEST_COMMENT: _('Comment on %(repo_name)s pull request #%(pr_id)s from %(ref)s by %(comment_username)s'), + self.TYPE_PULL_REQUEST: _('Review request on %(repo_name)s pull request %(pr_id)s from %(ref)s by %(pr_username)s'), + self.TYPE_PULL_REQUEST_COMMENT: _('Comment on %(repo_name)s pull request %(pr_id)s from %(ref)s by %(comment_username)s'), } def get_email_description(self, type_, **kwargs): diff --git a/kallithea/model/pull_request.py b/kallithea/model/pull_request.py --- a/kallithea/model/pull_request.py +++ b/kallithea/model/pull_request.py @@ -129,10 +129,10 @@ pull_request_id=pr.pull_request_id)] subject = safe_unicode( h.link_to( - _('%(user)s wants you to review pull request #%(pr_id)s: %(pr_title)s') % \ + _('%(user)s wants you to review pull request %(pr_id)s: %(pr_title)s') % \ {'user': pr.author.username, 'pr_title': pr.title, - 'pr_id': pr.pull_request_id}, + 'pr_id': h.pull_request_reference(pr.pull_request_id)}, pr_url) ) body = pr.description @@ -144,7 +144,7 @@ 'pr_url': pr_url, 'pr_revisions': revision_data, 'repo_name': pr.other_repo.repo_name, - 'pr_id': pr.pull_request_id, + 'pr_id': h.pull_request_reference(pr.pull_request_id), 'ref': org_ref_name, 'pr_username': pr.author.username, 'threading': threading, diff --git a/kallithea/templates/changelog/changelog.html b/kallithea/templates/changelog/changelog.html --- a/kallithea/templates/changelog/changelog.html +++ b/kallithea/templates/changelog/changelog.html @@ -89,7 +89,7 @@ %if c.statuses.get(cs.raw_id): <div class="changeset-status-ico"> %if c.statuses.get(cs.raw_id)[2]: - <a class="tooltip" title="${_('Changeset status: %s\nClick to open associated pull request #%s') % (h.changeset_status_lbl(c.statuses.get(cs.raw_id)[0]), c.statuses.get(cs.raw_id)[2])}" href="${h.url('pullrequest_show',repo_name=c.statuses.get(cs.raw_id)[3],pull_request_id=c.statuses.get(cs.raw_id)[2])}"> + <a class="tooltip" title="${_('Changeset status: %s\nClick to open associated pull request %s') % (h.changeset_status_lbl(c.statuses.get(cs.raw_id)[0]), h.pull_request_reference(c.statuses.get(cs.raw_id)[2]))}" href="${h.url('pullrequest_show',repo_name=c.statuses.get(cs.raw_id)[3],pull_request_id=c.statuses.get(cs.raw_id)[2])}"> <i class="icon-circle changeset-status-${c.statuses.get(cs.raw_id)[0]}"></i> </a> %else: diff --git a/kallithea/templates/changelog/changelog_summary_data.html b/kallithea/templates/changelog/changelog_summary_data.html --- a/kallithea/templates/changelog/changelog_summary_data.html +++ b/kallithea/templates/changelog/changelog_summary_data.html @@ -17,7 +17,7 @@ %if c.statuses.get(cs.raw_id): <div class="changeset-status-ico shortlog"> %if c.statuses.get(cs.raw_id)[2]: - <a class="tooltip" title="${_('Changeset status: %s\nClick to open associated pull request #%s') % (c.statuses.get(cs.raw_id)[0], c.statuses.get(cs.raw_id)[2])}" href="${h.url('pullrequest_show',repo_name=c.statuses.get(cs.raw_id)[3],pull_request_id=c.statuses.get(cs.raw_id)[2])}"> + <a class="tooltip" title="${_('Changeset status: %s\nClick to open associated pull request %s') % (c.statuses.get(cs.raw_id)[0], h.pull_request_reference(c.statuses.get(cs.raw_id)[2]))}" href="${h.url('pullrequest_show',repo_name=c.statuses.get(cs.raw_id)[3],pull_request_id=c.statuses.get(cs.raw_id)[2])}"> <i class="icon-circle changeset-status-${c.statuses.get(cs.raw_id)[0]}"></i> </a> %else: diff --git a/kallithea/templates/pullrequests/pullrequest_show.html b/kallithea/templates/pullrequests/pullrequest_show.html --- a/kallithea/templates/pullrequests/pullrequest_show.html +++ b/kallithea/templates/pullrequests/pullrequest_show.html @@ -3,11 +3,11 @@ <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> <%block name="title"> - ${_('%s Pull Request #%s') % (c.repo_name, c.pull_request.pull_request_id)} + ${_('%s Pull Request %s') % (c.repo_name, h.pull_request_reference(c.pull_request.pull_request_id))} </%block> <%def name="breadcrumbs_links()"> - ${_('Pull request #%s from %s#%s') % (c.pull_request.pull_request_id, c.pull_request.org_repo.repo_name, c.cs_branch_name)} + ${_('Pull request %s from %s#%s') % (h.pull_request_reference(c.pull_request.pull_request_id), c.pull_request.org_repo.repo_name, c.cs_branch_name)} </%def> <%block name="header_menu"> diff --git a/production.ini b/production.ini --- a/production.ini +++ b/production.ini @@ -246,6 +246,10 @@ #issue_server_link_wiki = https://mywiki.com/{id} #issue_prefix_wiki = WIKI- +## pullrequest id prefix +## a prefix key to use when referring to pull request IDs. For example, using +## '#' will give '#5' while using 'PR-' will give 'PR-5'. +pull_request_prefix = # ## instance-id prefix ## a prefix key for this instance used for cache invalidation when running diff --git a/test.ini b/test.ini --- a/test.ini +++ b/test.ini @@ -248,6 +248,10 @@ #issue_server_link_wiki = https://mywiki.com/{id} #issue_prefix_wiki = WIKI- +## pullrequest id prefix +## a prefix key to use when referring to pull request IDs. For example, using +## '#' will give '#5' while using 'PR-' will give 'PR-5'. +pull_request_prefix = # ## instance-id prefix ## a prefix key for this instance used for cache invalidation when running _______________________________________________ kallithea-general mailing list [email protected] http://lists.sfconservancy.org/mailman/listinfo/kallithea-general
