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

Associate default prefixes with external repositories #13

Closed
jayconrod opened this issue Dec 7, 2017 · 0 comments
Closed

Associate default prefixes with external repositories #13

jayconrod opened this issue Dec 7, 2017 · 0 comments

Comments

@jayconrod
Copy link
Contributor

(Migrated from bazel-contrib/rules_go#606)

We should associate prefixes with external repository names. These prefixes would be used transform import paths to Bazel labels for repositories that haven't been fetched and can't be indexed yet (see #12).

In the examples below, we would transform dependencies on github.com/example/project to @repo_with_custom_name//:go_default_library.

For go_repository, we can infer this from importpath or remote.

go_repository(
    name = "repo_with_custom_name",
    importpath = "github.com/example/project",
)

We may be able to do this for git_repository, too, in some cases.

git_repository(
    name = "repo_with_custom_name",
    remote = "https://github.com/example/project",
)

This wouldn't work with import path redirection. In particular, it wouldn't work with golang.org, gopkg.in, any fork, or private repositories. Gazelle should recognize directives in WORKSPACE to override the import path.

# gazelle:importpath github.com/example/project
git_repository(
    name = "repo_with_custom_name",
    remote = "https://github.com/fork/project",
)

If Gazelle can't discover the repository by parsing WORKSPACE (i.e., if a repository is declared in a macro), we should be able to read standalone declarations that map the prefix to the repo name.

# gazelle:importpath repo_with_custom_name github.com/example/project
jayconrod pushed a commit to jayconrod/bazel-gazelle that referenced this issue Jan 9, 2018
Gazelle now reads go_repository rules from WORKSPACE when starting
up. When externalResolver encounters an import path that is covered by
one of the declared external repositories, it will emit a label using
that repository's name. This allows custom repository names.

Fixes bazel-contrib#13
jayconrod added a commit that referenced this issue Jan 11, 2018
Gazelle now reads go_repository rules from WORKSPACE when starting
up. When externalResolver encounters an import path that is covered by
one of the declared external repositories, it will emit a label using
that repository's name. This allows custom repository names.

Fixes #13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant