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

WIP: Add rewrite for @bazel_tools//tools/build_defs/pkg to @rules_pkg #693

Closed
wants to merge 1 commit into from

Conversation

aiuto
Copy link
Contributor

@aiuto aiuto commented Aug 7, 2019

Add rewrite for load("@bazel_tools//tools/build_defs/pkg:...", ...)
to load("@rules_pkg//:...", ...)

See: bazelbuild/bazel#8857

It can't do WORKSPACE automatically, so it is sort of moot. Maybe not even legitimate to automate this kind of migration. The only valid update is to add one of these stanza to the workspace

if bazel_federation is NOT mentioned in WORKSPACE

maybe(
        http_archive,
        name = "rules_pkg",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/rules_pkg-0.2.0.tar.gz",
            "https://github.com/bazelbuild/rules_pkg/releases/download/0.2.0/rules_pkg-0.2.0.tar.gz",
        ],
        sha256 = "5bdc04987af79bd27bc5b00fe30f59a858f77ffa0bd2d8143d5b31ad8b1bd71c",
    )

Or, if @bazel_federation is already in the WORKSPACE

load("@bazel_federation//:repositories.bzl", "rules_pkg")
rules_pkg()

@aiuto
Copy link
Contributor Author

aiuto commented Aug 9, 2019

On second thought this is a dumb idea. buildifier should not do things that update WORKSPACE. That is complex enough so that it needs a much more sophisticated tool. I'm just keeping it until I capture the knowledge and turn it into docs for buildifier.

@vladmos
Copy link
Member

vladmos commented Aug 10, 2019

Perhaps it's better to implement such trasformations as a part of the fixer instead (in the warn/ package). There are a few differences:

  • Fixes there can be applied conditionally (i.e. you can specify what categories you're interested in),
  • They can have warnings (if you don't want to fix a file but just see what are the potential problems)
  • They can be suppressed with a special comment if you're sure you don't want a certain finding to be fixed
  • They don't affect the formatter (e.g. if you have a presubmit check that makes sure that your files are formatted correctly, it won't be broken if you just implement a new fix)

@aiuto aiuto closed this Apr 7, 2020
@aiuto aiuto deleted the rules_pkg branch April 7, 2020 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants