forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bazelbuild#12 from Wyverald/git
Patch support for overrides & git_override support
- Loading branch information
Showing
9 changed files
with
170 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/com/google/devtools/build/lib/bazel/bzlmod/GitOverride.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.google.devtools.build.lib.bazel.bzlmod; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.devtools.build.lib.bazel.bzlmod.repo.RepoSpec; | ||
|
||
@AutoValue | ||
public abstract class GitOverride implements NonRegistryOverride { | ||
|
||
private static final String GIT_REPOSITORY_RULE_CLASS = | ||
"@bazel_tools//tools/build_defs/repo:git.bzl%git_repository"; | ||
|
||
public static GitOverride create(String remote, String commit, ImmutableList<String> patches, int patchStrip) { | ||
return new AutoValue_GitOverride(remote, commit, patches, patchStrip); | ||
} | ||
|
||
public abstract String getRemote(); | ||
public abstract String getCommit(); | ||
public abstract ImmutableList<String> getPatches(); | ||
public abstract int getPatchStrip(); | ||
|
||
@Override | ||
public RepoSpec getRepoSpec(String repoName) { | ||
ImmutableMap.Builder<String, Object> attrBuilder = ImmutableMap.builder(); | ||
attrBuilder.put("name", repoName) | ||
.put("remote", getRemote()) | ||
.put("commit", getCommit()) | ||
.put("patches", getPatches()) | ||
.put("patch_args", ImmutableList.of("-p" + getPatchStrip())); | ||
return new RepoSpec(GIT_REPOSITORY_RULE_CLASS, attrBuilder.build()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 8 additions & 2 deletions
10
src/main/java/com/google/devtools/build/lib/bazel/bzlmod/SingleVersionOverride.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
package com.google.devtools.build.lib.bazel.bzlmod; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.common.collect.ImmutableList; | ||
|
||
@AutoValue | ||
public abstract class SingleVersionOverride implements RegistryOverride { | ||
|
||
public static SingleVersionOverride create(String version, String registry) { | ||
return new AutoValue_SingleVersionOverride(version, registry); | ||
public static SingleVersionOverride create(String version, String registry, | ||
ImmutableList<String> patches, int patchStrip) { | ||
return new AutoValue_SingleVersionOverride(version, registry, patches, patchStrip); | ||
} | ||
|
||
public abstract String getVersion(); | ||
|
||
@Override | ||
public abstract String getRegistry(); | ||
|
||
public abstract ImmutableList<String> getPatches(); | ||
|
||
public abstract int getPatchStrip(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters