-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for isolated
go_deps
usages (#1584)
Since isolated extension usages have their own sets of tags and repos, overrides can be allowed for such usages even in non-root modules. These usages also have to use their own dedicated repo config file.
- Loading branch information
Showing
15 changed files
with
123 additions
and
7 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
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
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 @@ | ||
test_dep |
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 +1,2 @@ | ||
common --enable_bzlmod | ||
common --experimental_isolated_extension_usages |
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 +1 @@ | ||
6.2.0 | ||
6.3.1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("@rules_go//go:def.bzl", "go_test") | ||
|
||
go_test( | ||
name = "test", | ||
srcs = ["test.go"], | ||
visibility = ["//visibility:public"], | ||
deps = ["@com_github_stretchr_testify//require"], | ||
) |
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,50 @@ | ||
module( | ||
name = "test_dep", | ||
version = "1.0.0", | ||
) | ||
|
||
bazel_dep(name = "rules_go", version = "0.41.0") | ||
bazel_dep(name = "gazelle", version = "0.31.0") | ||
|
||
# An isolated extension usage does not share any tags with any other usage and results in a | ||
# completely separate set of repos. We explicitly use different directives and patches here to | ||
# verify that they do not interfere with those of the root test module. | ||
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps", isolate = True) | ||
go_deps.module( | ||
path = "github.com/stretchr/testify", | ||
sum = "h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=", | ||
version = "v1.8.0", | ||
) | ||
go_deps.gazelle_override( | ||
directives = [ | ||
"gazelle:go_naming_convention import", | ||
], | ||
path = "github.com/stretchr/testify", | ||
) | ||
go_deps.module_override( | ||
patch_strip = 1, | ||
patches = [ | ||
"//patches:testify.patch", | ||
], | ||
path = "github.com/stretchr/testify", | ||
) | ||
|
||
go_deps.module( | ||
indirect = True, | ||
path = "gopkg.in/yaml.v3", | ||
sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=", | ||
version = "v3.0.1", | ||
) | ||
go_deps.gazelle_override( | ||
path = "gopkg.in/yaml.v3", | ||
directives = [ | ||
"gazelle:go_naming_convention import", | ||
], | ||
) | ||
go_deps.module( | ||
indirect = True, | ||
path = "github.com/davecgh/go-spew", | ||
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", | ||
version = "v1.1.1", | ||
) | ||
use_repo(go_deps, "com_github_stretchr_testify") |
Empty file.
Empty file.
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,13 @@ | ||
diff --git a/require/require.go b/require/require.go | ||
index a6e1b7c..bc21879 100644 | ||
--- a/require/require.go | ||
+++ b/require/require.go | ||
@@ -12,6 +12,8 @@ import ( | ||
time "time" | ||
) | ||
|
||
+const Hello = "not_hello" | ||
+ | ||
// Condition uses a Comparison to assert a complex condition. | ||
func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) { | ||
if h, ok := t.(tHelper); ok { |
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,13 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPatch(t *testing.T) { | ||
// A patch is used to add this constant with a value that differs from that patched into the | ||
// root module's version of this dep. | ||
require.Equal(t, "not_hello", require.Hello) | ||
} |