-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Go modules in subdirectories #502
Comments
Ugh. I tried to design the multi-package tagging to work the way Go wants, but I used the package name instead of the path 🤦. I think naming the package the same as the path to the module will make this work, as a workaround. I don't think it'll be that much work to fix this, it'll technically be a breaking change, but probably not for anyone actually using Knope or they would have encountered this issue already 😅. Hopefully I can get to it this weekend |
@dbanty Hm, I may be misunderstanding, but are you saying Knope should generate a tag using one or more components from the package name in My package name does match the module name, so I don't think that should cause any problems. |
....also, no rush! For now the explicit |
@BatmanAoD I meant specifying the package name in knope as if you had multiple packages: https://knope-dev.github.io/knope/config/packages.html But I'm glad you've got a workaround! |
Okay, I see now! So it appears that regardless of the type of file being versioned, I also see that having both So this:
...would result in tags of the form |
Yeah, 100% that is the correct behavior, and the ultimate fix for this issue. I also need to think of a way to make Command variables useful with the multi-package syntax, but that’s a more challenging issue 😅 |
Is |
Fixes #502 --------- Co-authored-by: Dylan Anthony <[email protected]>
Okay, this now generates the correct tag! 🎉 ...unfortunately, the behavior is still a little surprising: if Knope also generates a commit (e.g. because it updated the module path in
...actually, I am pretty sure that for versions above 1.0, Go will reject this, since the tagged |
Ugh, that makes sense because the I could add a commit into I would not create the tag until the So I guess adding commit with a special Go-specific step is the way to go unless you have any other ideas 😁. |
Hmm, I'm not sure I understand the problem with delaying the tagging until If that's the issue, here's a possibly-heretical suggestion: how about generating a comment with the full version number in |
Heretical? Maybe… but probably also a lot easier to manage 😁. You’re the Go dev, so if it’s okay with you then it’s okay with me! |
I do use Go, but only under duress 😆 Let me ask a few friends who are probably more in tune with idiomatic Go tooling practices what they think. |
@BatmanAoD One last thing I want to sort out, to make sure that this solution works: how does one typically embed a version in a Go binary? I saw some usage of Is there another common technique that you know of which would require needing the version at build time (after |
Oh jeeze, sorry, that is waaay outside the scope of my ecosystem knowledge. |
No worries! I’ll just fix the known tagging problem for now and we can adjust if someone has trouble in the future. Thanks! |
Okay, I think #565 does it! I'd appreciate you testing it out if you get some time @BatmanAoD |
Hm...I think this might actually have broken having Go and non-Go code in the same "package": With just
With just
With both:
|
Thanks for continuing to test this! I just pushed a fix, with added tests and a better error message so now when there are inconsistent versions it will tell you where it got those versions from. |
Thanks for continuing to work on it! Oh, I was testing I still have the unreachable-tag issue (#505), but not yet any useful information about how Knope is reaching the problematic tag. |
I think this issue can be closed, though! |
Yeah… probably gonna be some complex thing about Git internals I didn’t understand 😅. We’ll keep adding more logging until we find it!
Excellent, I’ll get a release out with the recent improvements then look at expanding |
…565) Closes #502 (again) --------- Co-authored-by: Dylan Anthony <[email protected]>
When using a go module that's defined in a subdirectory of a repository, Go expects the version tag to start with the path of the parent directory of the
go.mod
file (reference). So for<repo>/foo/bar/go.mod
, Go would expect tags of the formfoo/bar/v...
.When Knope encounters a
go.mod
file in a subdirectory, it should create a tag in this format (presumably in addition to the standardv...
) when tagging a release. It would probably be simplest to check whether thego.mod
is in a subdirectory relative toKnope.toml
(orpwd
if there isn't one), but the "right" approach would be to query git to find the repository root. (The CLI command isgit rev-parse --show-toplevel
; hopefullygit2
provides access to this functionality.) Conversely, when determining the current version of ago.mod
file, it should look for tags in this format and use them if present.(Related to #207)
The text was updated successfully, but these errors were encountered: