mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-10 15:39:40 -05:00
Allow configuring prefix for referencing Issue and PRs #4357
Closed
opened 2025-11-02 05:47:55 -06:00 by GiteaMirror
·
24 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v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.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/proposal
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#4357
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @davidsvantesson on GitHub (Nov 20, 2019).
Description
Currently hash (#) is used to reference both PRs and issues. As issues and PRs uses the same number series per repository in Gitea this is not a problem. But if you use external issue tracker all references will refer to the external site, and it is not possible to refer a PR (except with the full url).
My suggestion is to allow configuring the prefix for references issues and PRs (independently) so it is possible to distinguish them. So in addition to the default (#) you can use e.g.
Maybe anything can be allowed, but there should be some recommendation on suitable prefixes to not clash with other uses (e.g. '@' would be unsuitable).
The configuration could be made in app.ini (for site default) and per repo in settings.
Do you think this would be doable? Any comments?
@guillep2k commented on GitHub (Nov 20, 2019):
I think it's doable, but I wouldn't make it freely configurable. I'd chose one alternate symbol set and let the user chose between them either for issues or PRs.
¤is not available in all keyboards, but%should be.@guillep2k commented on GitHub (Nov 20, 2019):
Note: I'd have a three level setting in
app.ini: no change, only for repositories with external trackers, or for all repositories. The no change setting is to maintain compatibility with existing repositories. I'd use theapp.inivalue as default for new reposotiries, and then the actual value should be stored in the repo itself. An UI to change it can be added in a later PR.@davidsvantesson commented on GitHub (Nov 20, 2019):
I think the hash sign is quite general accepted as reference for issues. The only thing I want to add is the ability to specify if reference to an issue or pr. So I am not sure there really is a need to change what symbol to use for referencing, or if a setting is needed...
Something I was positively surprised of was that Gitea already supports referring to issues in other organizations and repositories (in the format
go-gitea/gitea#9088). Can we extend that to support specifying if the reference is to pr or issue? E.g.PR#9088andISSUE#9088(preferably case insensitive sopr#9088works as well). If you don't specify either it defaults to issue as today (redirected to pull if internal issue tracker is used). Possibly the default (pr or issue) can be a setting.In combination with specifying repo it would be
go-gitea/gitea/pr#9088andgo-gitea/gitea/issue#9088(or is the reversed order better?)@guillep2k commented on GitHub (Nov 20, 2019):
You're right, currently there's no way of referencing a PR in the same repo. But you've also made me just realize that the cross-repo references are completely broken when they are in or refer to a repo with external issue tracker because the repo.metas() are always taken from the repository of the rendered content. 😢
Anyway, we can allow
PR#for repos with external issue trackers, but that will be a problem for cross references too. Oh, it's very complicated!@guillep2k commented on GitHub (Nov 20, 2019):
I'm trying to complete this table, can you help me?
#1234User1/Repo1User1/Repo1#1234User1/Repo1UserZ/RepoZ#1234UserZ/RepoZ#1234User1/Repo1User1/Repo1#1234User1/Repo1UserZ/RepoZ#1234UserZ/RepoZUserZ/RepoZ#1234UserZ/RepoZPR#1234User1/Repo1User1/Repo1 ???User1/Repo1UserZ/RepoZ ???UserZ/RepoZAAA-1234AAA-1234forUser1/Repo1User1/Repo1 ??? AAA-1234AAA-1234forUser1/Repo1UserZ/RepoZ ??? AAA-1234AAA-1234forUserZ/RepoZThe latest section if for issues with alphanumeric format (I guess some external tracker uses that).
@davidsvantesson commented on GitHub (Nov 20, 2019):
I just looked in a bit on alphanumeric a bit and I don't think they work as you specified, they seem to be without hash (see regex).
You have typo on row 6 (wrong repo)
@guillep2k commented on GitHub (Nov 20, 2019):
You're right. I forgot. I wrote that myself. 😋
@davidsvantesson commented on GitHub (Nov 20, 2019):
I think we should have
User1/Repo1/PR#1234UserZ/RepoZ/PR#1234Also I think it would be neat to support this:
RepoX#1234RepoX/PR#1234(org default to the same as repo that reference is made from).
But maybe that is problematic if someone fork the repo.... ?
@guillep2k commented on GitHub (Nov 20, 2019):
I don't think forks are problematic as they don't migrate issues/PRs.
RepoX/#1234andUser1/Repo1/PR#1234do not conform to the currently supported syntax (which we must continue to support). Somehow seems a little hacky?User1/Repo1#PR1234sounds like a better fit to me, but I just saw another user use thePR#1234syntax in a PR on this very repo, which makes me think that other systems use it (GitHub ignored it, by the way).The thing is that too many options will become a burden, because it limits what you can write without creating a reference (you cannot choose if the reference is created or not). References will be seen in the referenced issue/PR as a comment and can't be deleted (they will be formatted with strike through if removed).
@davidsvantesson commented on GitHub (Nov 20, 2019):
I don't understand why it doesn't conform to current syntax, it would still support both
User1/Repo1#1234andUser1/Repo1/PR#1234. So I don't see a problem with backwards compatibility. This change shouldn't force specifying if the link is to issue or pr, the default would still be issues (possibly configurable).Regarding
RepoX/#1234it would be the same. Only if someone have writtenRepoX/#1234somewhere today and don't expect it to render a reference it would break the backwards compatibility. The problem with forks can be that after forking the repo is not inOrgXany longer but underUserY, so the cross reference would change to try to find the same repo underUserY(which doesn't have the issue).At least I think the style should be the same for internal and cross-references, so either
PR#1234andorg/repo/PR#1234, OR#PR1234andorg/repo#PR1234@guillep2k commented on GitHub (Nov 20, 2019):
You've got an extra
/. It's:User1/Repo1#1234, notUser1/Repo1/#1234.@davidsvantesson commented on GitHub (Nov 20, 2019):
Sorry, that shouldn't be there. Only if you want to specify it's an PR reference you need the extra slash, so
User1/Repo1#1234is the normal syntax andUser1/Repo1/PR#1234to specify it's a PR reference.@guillep2k commented on GitHub (Nov 20, 2019):
That's what I find hacky. But perhaps it's the best we can do. How do you feel about
#PR1234? It shouldn't clash with anything.@davidsvantesson commented on GitHub (Nov 20, 2019):
I prefer having it before, partly because
#PR1234looks like another issue numbering system (quite similar to the alphanumeric). But I think it is mostly a question of taste.Maybe the alphanumeric style should be left out from this, at last for now? It would limit that you can't refer to an alphanumeric issue on another repo, but you can still refer to both PRs and numeric issues. I'm afraid it would add to many clashes with normal written text.
@davidsvantesson commented on GitHub (Nov 20, 2019):
Looking at some other systems..
JIRA-1234, so internal links is not affected).!1234)issueorpull requestis specified before hashtag (e.g.issue #1234andpull request #1234. Not clear if anything is rendered if you don't use either keyword)My opinion would be to either go for GitLab way (
!1234for referencing PR), or similar to BitBucket but maybe with onlyPR#1234instead ofpull request #1234.Would people expect this to be localized, so instead of
PRyou can use something else? Exclamation mark has the benefit of not need to be localized.@guillep2k commented on GitHub (Nov 20, 2019):
Currently it doesn't support cross-references, so it's OK for me. The problem is that once we decide for one format we won't be able to change it in the future, so we must be aware of the choices we make.
I'm not against
PR#1234when it's alone, but I don't like adding a slash foruser1/repo1/PR#1234because we currently don't use it, and I'd go for consistency rather than aesthetics. My view on the options:PR#1234- pros: looks natural, users won't need to "think" to apply it for local PRs; cons: clashes with the current system, it's not i18n.#PR1234- pros: kinda looks natural (PRcan be regarded as a clarification), doesn't clash with the current system; cons maybe it looks like a new numbering scheme?, it's not i18n.%1234- pros i18n friendly, doesn't clash with the current system; cons difficult to remember (what symbol was it, again?)#1234PR- pros: kinda looks natural (PRcan be regarded as a clarification) but not so much, doesn't clash with the current system; cons maybe it looks like a new numbering scheme?, it's not i18n.@davidsvantesson commented on GitHub (Nov 20, 2019):
If we use a symbol I would suggest using exclamation mark as GitLab, no need to reinvent the wheel and easier for people switching to Gitea.
I think we can also consider the Bitbucket way:
pull request #1234. pros: natural text + it supports cross-reference fully compatible with current system (pull request org/repo#1234); cons: it's not i18n.@guillep2k commented on GitHub (Nov 20, 2019):
I didn't know about GitLab. The Bitbucket way seems very difficult to implement correctly. So, this?:
#1234User1/Repo1!1234User1/Repo1#1234User1/Repo1!1234User1/Repo1User1/Repo1#1234User1/Repo1User1/Repo1!1234User1/Repo1User1/Repo1#1234User1/Repo1User1/Repo1!1234User1/Repo1UserZ/RepoZ#1234UserZ/RepoZUserZ/RepoZ!1234UserZ/RepoZUserZ/RepoZ#1234UserZ/RepoZUserZ/RepoZ!1234UserZ/RepoZAAA-1234AAA-1234forUser1/Repo1!1234User1/Repo1User1/Repo1!1234User1/Repo1AAA-1234forUserZ/RepoZUserZ/RepoZ!1234UserZ/RepoZThe last section is for repositories with external trackers that use alphanumeric format.
@guillep2k commented on GitHub (Nov 21, 2019):
So, I'm working on this based in the table above. Let's see how other people like it. 😄
@davidsvantesson commented on GitHub (Nov 21, 2019):
With the localization in mind, I think the exclamation mark is the way to go.
The feature will be slightly breaking. However I don't think it is common to have !1234 used for something else in markdown/text, so that might not be a problem.
However there are other places where # should be replaced with !. What I can think of now is when you do Squash and Merge on a PR, then the PR number is written by default in the heading. This should be replaced (
PR title (#1234)->PR title (!1234)). But there might be persons that doesn't like that change? Should it be a app.ini setting?@guillep2k commented on GitHub (Nov 21, 2019):
Good catch. If the PR I'm working on is accepted, then what we can do is to automatically use the
!1234format when issues are external and numeric, which is the only combination that would make#1234incorrect for the PR. In all other cases,#1234will work as expected, independently that!1234will also work for PRs.@davidsvantesson commented on GitHub (Nov 21, 2019):
For consistency I think it would be good to have a setting to always use ! instead of # in that case. Because you might start a repository without external tracker and then switch, which would make the old commits incorrect. Also you might have different repos where only one is with external tracker then it makes sense to always use ! for PRs.
@guillep2k commented on GitHub (Nov 21, 2019):
Mmm.... I'm not so sure about that. The fact that different repos have different needs makes it so an
app.inisetting is not appropriate. Then we have all the existing repositories that already use#(and by existing I mean now and at the moment theapp.inisetting is changed). Plus users (not admins, which will have access toapp.ini) that might hate the change if they don't need it. Finally, if the repo switches between external and internal tracking they will get all the references wrong anyway. 😄@davidsvantesson commented on GitHub (Nov 21, 2019):
You are probably right app.ini is not suitable for such setting. If needed it can maybe be repo pr unit setting. But that can be discussed once we have the possibility to use ! for pr reference 😄