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

bzlmod: support git repos in source.json #20912

Closed
wants to merge 17 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Respond to review comments.
Change-Id: I5d158550762d13f57d90d3686e2d82a759ff9bb1
nachumg committed Jan 18, 2024
commit 4a9008e80fed594f6dff4f9412e80bb4b46b7b46
12 changes: 9 additions & 3 deletions site/en/external/registry.md
Original file line number Diff line number Diff line change
@@ -74,9 +74,15 @@ An index registry must follow the format below:
`"tar"`, `"tar.gz"`, `"tgz"`, `"tar.xz"`, `"txz"`, `"tar.zst"`, `"tzst"`, `tar.bz2`, `"ar"`, or `"deb"`.
* The type can be changed to use a git repository, with these fields:
* `type`: `git_repository`
* The fields described at https://bazel.build/rules/lib/repo/git except for:
* `workspace_file`
* `workspace_file_content`
* The following fields as described at https://bazel.build/rules/lib/repo/git:
* `remote`
* `commit`
* `shallow_since`
* `tag`
* `init_submodules`
* `recursive_init_submodules`
* `verbose`
* `strip_prefix`
* The type can be changed to use a local path, representing a
`local_repository` repo, with these fields:
* `type`: `local_path`
Original file line number Diff line number Diff line change
@@ -125,7 +125,6 @@ private static class SourceJson {

/** Represents fields in {@code source.json} for each archive-type version of a module. */
private static class ArchiveSourceJson {
String type = "archive";
URL url;
String integrity;
String stripPrefix;
@@ -136,29 +135,19 @@ private static class ArchiveSourceJson {

/** Represents fields in {@code source.json} for each local_path-type version of a module. */
private static class LocalPathSourceJson {
String type = "local_path";
String path;
}

/** Represents fields in {@code source.json} for each git_repository-type version of a module. */
private static class GitRepoSourceJson {
String type = "git_repository";
String remote;
String commit;
String shallowSince;
String tag;
String branch;
boolean initSubmodules;
boolean recursiveInitSubmodules;
boolean verbose;
String stripPrefix;
List<String> patches;
String patchTool;
List<String> patchArgs;
List<String> patchCmds;
List<String> patchCmdsWin;
String buildFile;
String buildFileContent;
}

/**
@@ -361,18 +350,10 @@ private RepoSpec createGitRepoSpec(
.setCommit(sourceJson.commit)
.setShallowSince(sourceJson.shallowSince)
.setTag(sourceJson.tag)
.setBranch(sourceJson.branch)
.setInitSubmodules(sourceJson.initSubmodules)
.setRecursiveInitSubmodules(sourceJson.recursiveInitSubmodules)
.setVerbose(sourceJson.verbose)
.setStripPrefix(sourceJson.stripPrefix)
.setPatches(sourceJson.patches)
.setPatchTool(sourceJson.patchTool)
.setPatchArgs(sourceJson.patchArgs)
.setPatchCmds(sourceJson.patchCmds)
.setPatchCmdsWin(sourceJson.patchCmdsWin)
.setBuildFile(sourceJson.buildFile)
.setBuildFileContent(sourceJson.buildFileContent)
.build();
}

2 changes: 0 additions & 2 deletions src/test/py/bazel/bzlmod/test_utils.py
Original file line number Diff line number Diff line change
@@ -27,8 +27,6 @@
import urllib.request
import zipfile

import sys # TODO remove


def download(url):
"""Download a file and return its content in bytes."""