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

Allow ~/home in downloaderConfig of RepositoryOptions #24618

Closed

Conversation

kiron1
Copy link
Contributor

@kiron1 kiron1 commented Dec 10, 2024

Similar to --distdir it makes sense to provide a --experimental_downloader_config from ~/.bazelrc where it is more convenient to address a file in ones home directory by using ~/... syntax instead of on absolute path.

@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Dec 10, 2024
@kiron1 kiron1 force-pushed the downloader-config-path-convert branch from 8a707e7 to 7070f16 Compare December 11, 2024 02:48
UrlRewriter rewriter =
UrlRewriter.getDownloaderUrlRewriter(
env.getWorkspace(), repoOptions.downloaderConfig, env.getReporter());
env.getWorkspace(), configPath, env.getReporter());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Could you change the signature of this method to accept a PathFragment instead of a String?

@kiron1 kiron1 force-pushed the downloader-config-path-convert branch from 7070f16 to f816a57 Compare December 17, 2024 01:39
@kiron1 kiron1 requested a review from fmeum December 17, 2024 03:02
@@ -86,11 +87,11 @@ public class UrlRewriter {
* @param reporter Used for logging when URLs are rewritten.
*/
public static UrlRewriter getDownloaderUrlRewriter(
Path workspaceRoot, String configPath, Reporter reporter) throws UrlRewriterParseException {
Path workspaceRoot, PathFragment configPath, Reporter reporter) throws UrlRewriterParseException {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Path workspaceRoot, PathFragment configPath, Reporter reporter) throws UrlRewriterParseException {
Path workspaceRoot, @Nullable PathFragment configPath, Reporter reporter) throws UrlRewriterParseException {

@fmeum fmeum requested a review from meteorcloudy December 17, 2024 10:13
Copy link
Member

@meteorcloudy meteorcloudy left a comment

Choose a reason for hiding this comment

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

Thanks for the improvement! Can we add a test for this?

Similar to `--distdir` it makes sense to provide a
`--experimental_downloader_config` from `~/.bazelrc` where it is more
convenient to address a file in ones home directory by using `~/...`
syntax instead of an absolute path.
@kiron1 kiron1 force-pushed the downloader-config-path-convert branch from f816a57 to 07becea Compare December 18, 2024 09:07
@kiron1
Copy link
Contributor Author

kiron1 commented Dec 18, 2024

Thanks for the improvement! Can we add a test for this?

Can you please link to an existing test which can be extended? I could not find any test for --experimental_downloader_config nor one for --distdir which does test for ~/... to work.

@fmeum
Copy link
Collaborator

fmeum commented Dec 18, 2024

@meteorcloudy That's a unit test though and this PR relies on changes to RepositoryOptions.

@kiron1
Copy link
Contributor Author

kiron1 commented Dec 18, 2024

Probably should be in https://github.com/bazelbuild/bazel/blob/master/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/UrlRewriterTest.java

I don't see there a fitting example. In this test file it creates a rewriter by calling the c'tor UrlRewriter(Consumer<String> log, String filePathForErrorReporting, Reader reader).

But in this PR we only change the outside observable behaviour where an user can call bazel with --experimental_downloader_config=~/.bazelmirror and the file from $HOME/.bazelmirror gets opened unlike now, where bazel would try to open a literal file called ~/.bazelmirror without resolving the ~ to the home directory.

@meteorcloudy
Copy link
Member

Oh I see, then the converter itself should have been well tested:
https://cs.opensource.google/bazel/bazel/+/master:src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java;l=176-193

@meteorcloudy meteorcloudy added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Dec 18, 2024
@fmeum
Copy link
Collaborator

fmeum commented Dec 18, 2024

@bazel-io fork 8.1.0

@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Dec 19, 2024
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Jan 18, 2025
Similar to `--distdir` it makes sense to provide a `--experimental_downloader_config` from `~/.bazelrc` where it is more convenient to address a file in ones home directory by using `~/...` syntax instead of on absolute path.

Closes bazelbuild#24618.

PiperOrigin-RevId: 708007102
Change-Id: Ia8d0ebc1cb79c95ea58888c08746adc917d3fb63
github-merge-queue bot pushed a commit that referenced this pull request Jan 20, 2025
Similar to `--distdir` it makes sense to provide a
`--experimental_downloader_config` from `~/.bazelrc` where it is more
convenient to address a file in ones home directory by using `~/...`
syntax instead of on absolute path.

Closes #24618.

PiperOrigin-RevId: 708007102
Change-Id: Ia8d0ebc1cb79c95ea58888c08746adc917d3fb63

Commit
0ce2d7d

Co-authored-by: Kiron <[email protected]>
fmeum pushed a commit to fmeum/bazel that referenced this pull request Jan 29, 2025
Similar to `--distdir` it makes sense to provide a `--experimental_downloader_config` from `~/.bazelrc` where it is more convenient to address a file in ones home directory by using `~/...` syntax instead of on absolute path.

Closes bazelbuild#24618.

PiperOrigin-RevId: 708007102
Change-Id: Ia8d0ebc1cb79c95ea58888c08746adc917d3fb63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants