Skip to content

Commit

Permalink
Add init_submodules to git_override
Browse files Browse the repository at this point in the history
This is slightly different from the starlark version which has a separate init_submodules and recursive_init_submodules for historical reasons.

Closes #20937.

PiperOrigin-RevId: 600337195
Change-Id: I6e26d58f442d3e2c85feee20c14017b5a13fa588
  • Loading branch information
keith authored and copybara-github committed Jan 22, 2024
1 parent addf41b commit 5cf7714
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public static GitOverride create(
String commit,
ImmutableList<String> patches,
ImmutableList<String> patchCmds,
int patchStrip) {
return new AutoValue_GitOverride(remote, commit, patches, patchCmds, patchStrip);
int patchStrip,
boolean initSubmodules) {
return new AutoValue_GitOverride(
remote, commit, patches, patchCmds, patchStrip, initSubmodules);
}

/** The URL pointing to the git repository. */
Expand All @@ -50,6 +52,9 @@ public static GitOverride create(
/** The number of path segments to strip from the paths in the supplied patches. */
public abstract int getPatchStrip();

/** Whether submodules in the fetched repo should be recursively initialized. */
public abstract boolean getInitSubmodules();

/** Returns the {@link RepoSpec} that defines this repository. */
@Override
public RepoSpec getRepoSpec(RepositoryName repoName) {
Expand All @@ -60,7 +65,9 @@ public RepoSpec getRepoSpec(RepositoryName repoName) {
.put("commit", getCommit())
.put("patches", getPatches())
.put("patch_cmds", getPatchCmds())
.put("patch_args", ImmutableList.of("-p" + getPatchStrip()));
.put("patch_args", ImmutableList.of("-p" + getPatchStrip()))
.put("init_submodules", getInitSubmodules())
.put("recursive_init_submodules", getInitSubmodules());
return RepoSpec.builder()
.setBzlFile(GIT_REPOSITORY_PATH)
.setRuleClassName("git_repository")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,14 +1038,21 @@ public void archiveOverride(
named = true,
positional = false,
defaultValue = "0"),
@Param(
name = "init_submodules",
doc = "Whether submodules in the fetched repo should be recursively initialized.",
named = true,
positional = false,
defaultValue = "False"),
})
public void gitOverride(
String moduleName,
String remote,
String commit,
Iterable<?> patches,
Iterable<?> patchCmds,
StarlarkInt patchStrip)
StarlarkInt patchStrip,
boolean initSubmodules)
throws EvalException {
hadNonModuleCall = true;
addOverride(
Expand All @@ -1055,7 +1062,8 @@ public void gitOverride(
commit,
Sequence.cast(patches, String.class, "patches").getImmutableList(),
Sequence.cast(patchCmds, String.class, "patchCmds").getImmutableList(),
patchStrip.toInt("git_override.patch_strip")));
patchStrip.toInt("git_override.patch_strip"),
initSubmodules));
}

@StarlarkMethod(
Expand Down

0 comments on commit 5cf7714

Please sign in to comment.