Correctly tagging a module in a subdirectory of a Github repo

229 views
Skip to first unread message

Jim Idle

unread,
Mar 3, 2023, 11:09:48 PM3/3/23
to golang-nuts
For historic reasons, which are too difficult to change (and pre-modules), the runtime module for the ANTLR v4 Go runtime is held in a subdirectory of the antlr/antlr4 Github repo. This is complicated by the fact that organizations have written scripts into their build to copy the source code into their monorepos and so on (I'm looking at you Google ;). I cannot just put the source code into its own repo and be done with it. Also, there are a ton of automated scripts for testing and release etc. There are something like 45 projects within Google alone that rely on the source location and tag presence etc.

In the past, tags with the v prefix had been created that point to the root of the repo (to clarify, I mean the tags don't contain the prefix - I know tags point at commit hashes). They were not created for go and people have used them in builds - I cannot just delete them. For instance, there is a tag v.4.11.1 which seemed to totally throw off the go get etc and while using the path to the runtime in the import works, it meant that the entire repo source is installed as if it were the go module, and the go.mod for a project and the ~/go/pkg/mod shows github.com/antlr/ant...@v4.11.1+incompatible. I can understand why this is.

With the latest release v4.12.0, I created tags with the directory prefix: runtime/Go/antlr/v4/v4.12.0 a la:

git tag -a v4.12.0 -m "ssads" runtime/Go/antlr/v4

And there is no v4.12.0 tag. There is a 4.12.0 tag for use by non-go users in the future.

This seems to work in that the cache now only contains the v4 source for go. So far so good. But when a go get is issued, the go.mod (and reflected in cache) for a project seems to indicate the commit hash and not the version, so the module for a project that uses it will look like this:

module x/y/z

go 1.19

require (
    github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230219212500-1f9a474cc2dc
)

require golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 // indirect


Where I was expecting to see v4.12.0. The go.mod for the runtime is stored inthe /v4 directory of course, but there is no other go.mod, such as at the root of the repo.

The docs are a little light on this area, so I cannot tell if this is what should be expected, or whether my tags are not quite correct in some way.

The current latest tag is:


The previous incorrect tag is:


I suspect that the directory associated tag is not correct, and that:


Is just getting the latest commit to master, or the commit at the point where the tag was created. I am aware that tags point at the commit and refer to the repo as a whole. I'm even looking suspiciously at that uppercase G.

I suspect this because:

go get -u github.com/antlr/antlr4/runtime/Go/antlr/v...@v4.12.0
go: github.com/antlr/antlr4/runtime/Go/antlr/v...@v4.12.0: invalid version: unknown revision runtime/Go/antlr/v4.12.0

So, I am wondering if there are any devops guys on here (I am a wizened old coder, used to having devops guys to ask ;), that no how to do this correctly?

Any pointers appreciated. Hopefully I am just misunderstanding something here.

Jim

Jim Idle

unread,
Mar 4, 2023, 12:05:32 AM3/4/23
to golang-nuts
Just to follow up on my question, I have read all the docs again, and I am thinking that I used the wrong tag syntax. I think it should either be:

git tag -a  runtime/Go/antlr/v4/v4.12.0 -m "ssads" runtime/Go/antlr/v4

or just

git tag -a  runtime/Go/antlr/v4/v4.12.0 -m "ssads"

Am I on the right path?

Sorry to speculate here on the group, but I cannot just go start messing around on the master branch and testing it out, or I would have done so.

Jim
Reply all
Reply to author
Forward
0 new messages