Open suzuki-shunsuke opened 2 years ago
I didn't know this. https://go.dev/ref/mod#vcs-version
If a module is defined in a subdirectory within the repository, that is, the module subdirectory portion of the module path is not empty, then each tag name must be prefixed with the module subdirectory, followed by a slash. For example, the module golang.org/x/tools/gopls is defined in the gopls subdirectory of the repository with root path golang.org/x/tools. The version v0.4.0 of that module must have the tag named gopls/v0.4.0 in that repository.
Maybe, it is difficult to get module subdirectory. I don't know the rule.
e.g.
Currently, if I run aqua g -i golang.org/x/tools/gopls
, - name: golang.org/x/tools/gopls@gopls/v0.15.3
gets inserted.
I think there're two ways to fix this:
- name: golang.org/x/tools/gopls@v0.15.3
insteadgopls/
part when running go install
It depends on which you expect the users to write:
name: golang.org/x/tools/gopls@v0.15.3
name: golang.org/x/tools/gopls@gopls/v0.15.3
IMHO 1 feels more natural. Or do you want to support both?
In either case, the prefix needs to be trimmed. This seems to be the way go finds the repository root path. From the definition written in this sentence, it should be able to calculate the module subdirectory from the repository root path and the path
field in the registry.
That said, while checking the behavior, I found that go list -m -versions -json $module_path
returns a version list (example: go list -m -versions -json github.com/zeromicro/go-zero/tools/goctl
). In this way, you can get the version without the module subdirectory and also support modules that are not hosted on GitHub, even those using mercurial (hg) instead of git.
Feature Overview
Support formatting the version string. For example, support removing the prefix.
Why is the feature needed?
This is required to support zeromicro/go-zero, goctl.
The following configuration doesn't work.
aqua.yaml
registry.yaml
The GitHub tag
tools/goctl/v1.3.9
is invalid as Go package version. We have to formattools/goctl/v1.3.9
tov1.3.9
.https://pkg.go.dev/github.com/zeromicro/go-zero/tools/goctl?tab=versions
Does the feature include Breaking Changes?
No.
Example Code