go-get meta tags are incorrect, cause infinite recursion #1088

Closed
opened 2025-11-02 03:48:09 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @rsc on GitHub (Sep 22, 2017).

Here's a site running gitea: https://zxq.co/ripple/hanayo/routers/oauth?go-get=1. It says:

<meta name="go-import" content="zxq.co/ripple/hanayo/routers/oauth git https://zxq.co/ripple/hanayo.git">

The general form of this tag is

<meta name="go-import" content="IMPORT VCS REPO">

which says that the code at the root directory of VCS REPO is what to use for IMPORT. The tag above is incorrect because it says that https://zxq.co/ripple/hanayo.git is what to use for zxq.co/ripple/hanayo/routers/oauth, but in fact it's what to use for zxq.co/ripple/hanayo.

The correct tag is:

<meta name="go-import" content="zxq.co/ripple/hanayo git https://zxq.co/ripple/hanayo.git">

That is, even though we asked about zxq.co/ripple/hanayo/routers/oauth, the meta tag should tell about the root of the git repo not the current subdirectory (the subdirectory will be deduced from the root).

This happens because routers/repo/http.go includes the subdir in:

func composeGoGetImport(owner, repo, sub string) string {
	return path.Join(setting.Domain, setting.AppSubURL, owner, repo, sub)
}

I believe it would fix this problem to simply drop the ", sub" from the call.

Originally created by @rsc on GitHub (Sep 22, 2017). Here's a site running gitea: https://zxq.co/ripple/hanayo/routers/oauth?go-get=1. It says: <meta name="go-import" content="zxq.co/ripple/hanayo/routers/oauth git https://zxq.co/ripple/hanayo.git"> The general form of this tag is <meta name="go-import" content="IMPORT VCS REPO"> which says that the code at the root directory of VCS REPO is what to use for IMPORT. The tag above is incorrect because it says that https://zxq.co/ripple/hanayo.git is what to use for zxq.co/ripple/hanayo/routers/oauth, but in fact it's what to use for zxq.co/ripple/hanayo. The correct tag is: <meta name="go-import" content="zxq.co/ripple/hanayo git https://zxq.co/ripple/hanayo.git"> That is, even though we asked about zxq.co/ripple/hanayo/routers/oauth, the meta tag should tell about the root of the git repo not the current subdirectory (the subdirectory will be deduced from the root). This happens because [routers/repo/http.go](https://github.com/go-gitea/gitea/blob/master/routers/repo/http.go) includes the subdir in: ``` func composeGoGetImport(owner, repo, sub string) string { return path.Join(setting.Domain, setting.AppSubURL, owner, repo, sub) } ``` I believe it would fix this problem to simply drop the ", sub" from the call.
GiteaMirror added the type/bug label 2025-11-02 03:48:09 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1088