Skip to content

"Copy Link" yields wrong URL in pull request #16102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 6 tasks
sotho opened this issue Jun 8, 2021 · 0 comments · Fixed by #16230
Closed
2 of 6 tasks

"Copy Link" yields wrong URL in pull request #16102

sotho opened this issue Jun 8, 2021 · 0 comments · Fixed by #16230
Labels

Comments

@sotho
Copy link
Contributor

sotho commented Jun 8, 2021

Description

In a pull request each comment has a link that can be used to reference the comment.
The link can be obtained by

  1. right clicking on the text "sotho commented 15 hours ago" -> Copy Link (from browser context menu), this gives e.g.:
    https://try.gitea.io/BracTest/piparallel/pulls/7#issuecomment-87880
  2. click on "..." -> "Copy Link" (from gitea context menu), this gives e.g.:
    https://try.gitea.io/BracTest/piparallel/issues/7#issuecomment-87880

If the internal issue tracker is enabled the second URL forwards to the first it seems.
If the internal issue tracker is disabled and forwarding to an external tracker, then the second URL does not work properly.

I would expect that both methods should yield the same URL.
For the second method the file templates/repo/issue/view_content/context_menu.tmpl builds the URL:

    {{ if .issue }}
        {{ $referenceUrl = Printf "%s%s/issues/%d#%s" AppUrl .ctx.Repository.FullName .ctx.Issue.Index .item.HashTag }}
    {{ else }}
        {{ $referenceUrl = Printf "%s%s/pulls/%d/files#%s" AppUrl .ctx.Repository.FullName .ctx.Issue.Index .item.HashTag }}
    {{ end }}

Changing "%s%s/issues/%d#%s" to "%s%s/pulls/%d#%s" fixes it for my use case, but might break the issue tracker?

sebastian-sauer added a commit to sebastian-sauer/gitea that referenced this issue Jun 22, 2021
if a pull request is displayed use the /pulls path
if a pull requests diff is displayed use the /pulls/{id}/files url
if an issue is displayed use the issues url

fixes go-gitea#16102

Signed-off-by: Sebastian Sauer <[email protected]>
zeripath pushed a commit that referenced this issue Jun 22, 2021
if a pull request is displayed use the /pulls path
if a pull requests diff is displayed use the /pulls/{id}/files url
if an issue is displayed use the issues url

Fixes #16102

Signed-off-by: Sebastian Sauer <[email protected]>
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this issue Aug 10, 2021
if a pull request is displayed use the /pulls path
if a pull requests diff is displayed use the /pulls/{id}/files url
if an issue is displayed use the issues url

Fixes go-gitea#16102

Signed-off-by: Sebastian Sauer <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants