Skip to content
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

Resolve dependencies from both host go.mod and module's go.mod #225

Merged
merged 9 commits into from
Feb 9, 2024

Conversation

janhancic
Copy link
Contributor

@janhancic janhancic commented Feb 7, 2024

Previously we would only look at the host repo's go.mod or the module's go.mod, but not both.
This changes makes it so that we always look at both available go.mod files and add logic to prevent reading the replace directives in the module's go.mod if we also have the host repo's go.mod configured.

Another notable change is to use gomod.Parse instead of gomod.ParseLax for the host repo. It turns out we weren't actually parsing the replace directives (the map was always empty). It didn't cause issues internally because we only use the replace directives to change versions, and not paths.

Previously we would only look at the host repo's go.mod or the module's
go.mod, but not both.
This changes makes it so that we always look at both available go.mod
files and add logic to prevent reading the `replace` directives in the
module's go.mod if we also have the host repo's go.mod configured.
@goddenrich
Copy link
Contributor

Not sure if we can test the expected replace directive behaviour here. Theres a bit of complexity there thats not obvious that could do with a test.

@janhancic janhancic requested a review from goddenrich February 8, 2024 09:34
Copy link
Contributor

@Tatskaari Tatskaari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one Jan!

You could bump tools/please_go/VERSION and tools/please_go/ChangeLog in this PR if you want.

If the host go.mod file contains a `replace` directive for a module that
we are generating and the directive only changes the version, the dependency
resolution went into an infinite recursion.

Update the code so that we use strict parsing only for the host repo's
go.mod and not for the module's, as that can cause issues.
@janhancic janhancic merged commit 6c52c57 into please-build:master Feb 9, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants