Skip to content

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

@rsc

Description

@rsc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions