rules_go icon indicating copy to clipboard operation
rules_go copied to clipboard

Gazelle does not pick up files added by patch

Open SpencerC opened this issue 1 year ago • 3 comments

What version of rules_go are you using?

0.50.0

What version of gazelle are you using?

0.38.0

What version of Bazel are you using?

7.3.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

macOS

Any other potentially useful information about your toolchain?

What did you do?

Attepmted to apply this patch with the following directive after our use_repo(go_deps,... statement in MODULE.bazel:

go_deps.module_override(
    patch_strip = 1,
    patches = [
        "//:testcontainers-auth-errors.patch",
    ],
    path = "github.com/testcontainers/testcontainers-go",
)

What did you expect to see?

A successful build.

What did you see instead?

external/gazelle~~go_deps~com_github_testcontainers_testcontainers_go/docker_auth.go:128:25: undefined: getRegistryCredentials

Gazelle does not seem to pick up the docker_config.go file added by the patch; manually adding it to the generated BUILD.bazel file solves the problem.

SpencerC avatar Sep 03 '24 17:09 SpencerC

Patches are applied after Gazelle is run, so this is expected. We could have "after Gazelle patches", but I'm not sure whether that's worth the complexity. How much larger is your patch due to this?

fmeum avatar Sep 03 '24 17:09 fmeum

How much larger is your patch due to this?

If I'm understanding you correctly, are you asking how much we have to add to our patch to make it work? Like could we just add a section to the patch to add the missing line to the generated BUILD.bazel? If that's possible (I'm not that that familiar with patch mechanics), I suppose we could. Its just a bit weird to support some patch operations and require special hacking for others.

My team, and hopefully other teams, are not overly reliant on patching, so totally understand if this isn't a boundry case you plan to support.

SpencerC avatar Sep 03 '24 18:09 SpencerC

We could also just modify the patch to append the code to an existing file. In this case, we got the patch from the package maintainer.

SpencerC avatar Sep 03 '24 18:09 SpencerC