Skip to content
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

Make autolinking issues and PRs in markdown files configurable #33639

Open
neonmoe opened this issue Feb 18, 2025 · 6 comments
Open

Make autolinking issues and PRs in markdown files configurable #33639

neonmoe opened this issue Feb 18, 2025 · 6 comments
Assignees
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@neonmoe
Copy link

neonmoe commented Feb 18, 2025

Description

Previously, in at least 1.19.3, linking to PRs and issues with e.g. #123 in a markdown file resulted in them being autolinked when the markdown was rendered, but in 1.23.3 (and the dev version at demo.gitea.com), this is no longer the case.

I reproduced this in a testing instance with the following docker compose (and whatever defaults it gave in the install step), just changing the version from 1.19.3 to 1.23.3.

networks:
  gitea_testing:
    external: false

services:
  server:
    image: docker.io/gitea/gitea:1.19.3
    container_name: gitea_testing
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - gitea_testing
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "4480:3000"
      - "4422:22"

And just for completeness, here's the README.md seen in the screenshot:

linking issue #1

Even if this is intentional, it would be nice if the previous behavior could be re-enabled with a configuration option. I couldn't find any issues, PRs, or release notes about this topic.

Reproduced on demo.gitea.com: https://demo.gitea.com/neonmoe/testing-repo

Gitea Version

1.23.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

Image

Git Version

No response

Operating System

No response

How are you running Gitea?

Both demo.gitea.com and using the docker-compose config I pasted in the main issue description.

Database

SQLite

@wxiaoguang wxiaoguang self-assigned this Feb 19, 2025
@wxiaoguang

This comment has been minimized.

@wxiaoguang

This comment has been minimized.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Feb 19, 2025

The change is from #26365, to match GitHub behavior.

The workaround is "using full URL link" ......

See GitHub:

Image

@wxiaoguang wxiaoguang added issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail and removed type/bug labels Feb 19, 2025
@neonmoe
Copy link
Author

neonmoe commented Feb 19, 2025

That's understandable, but would it be possible to add a configuration option for this? It would be quite a lot of work to manually replace all the autolinks with a real link, and we'd need to update our development tooling to generate real links. It was very convenient how e.g. commit messages and PR titles could previously be copied as-is into a changelog file, and it'd just work.

@wxiaoguang
Copy link
Contributor

I could try if I get time.


If you are able to build your own binary program, you could apply this patch (only 1 line):

diff --git a/models/repo/repo.go b/models/repo/repo.go
index c5060a419f..d1fd8d4982 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -537,6 +537,7 @@ func (repo *Repository) ComposeDocumentMetas(ctx context.Context) map[string]str
        // does document(file) need the "teams" and "org" from common metas?
        metas := maps.Clone(repo.composeCommonMetas(ctx))
        metas["markdownLineBreakStyle"] = "document"
+       metas["markupAllowShortIssuePattern"] = "true"
        return metas
 }

Then

TAGS="bindata sqlite sqlite_unlock_notify" make build

Then mount the docker volume to host:

    volumes:
      - ./gitea-app/gitea:/app/gitea
      - (others....)

Then use your own binary to replace ./gitea-app/gitea and restart the container.

@neonmoe
Copy link
Author

neonmoe commented Feb 19, 2025

Thank you very much for the patch, that works great!

@wxiaoguang wxiaoguang added type/proposal The new feature has not been accepted yet but needs to be discussed first. and removed issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail labels Feb 19, 2025
@wxiaoguang wxiaoguang changed the title Autolinking issues and PRs in markdown files stopped working in some version after 1.19.3 Make autolinking issues and PRs in markdown files configurable Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

2 participants