Skip to content

Commit

Permalink
use carved out module for x/tools/go/vcs (#3671)
Browse files Browse the repository at this point in the history
This part of golang.org/x/tools was removed from tools.
The vcs code is still available in a separate module with a version marked as "deprecated".
Let's use it for now.
  • Loading branch information
malt3 authored Aug 28, 2023
1 parent 2e821f6 commit 5206498
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
19 changes: 19 additions & 0 deletions go/private/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,25 @@ def go_rules_dependencies(force = False):
patch_args = ["-p1"],
)

# Needed for go/tools/fetch_repo
# releaser:upgrade-dep golang tools
wrapper(
http_archive,
name = "org_golang_x_tools_go_vcs",
# v0.12.0, latest as of 2023-08-12
urls = [
"https://mirror.bazel.build/github.com/golang/tools/archive/refs/tags/go/vcs/v0.1.0-deprecated.zip",
"https://github.com/golang/tools/archive/refs/tags/go/vcs/v0.1.0-deprecated.zip",
],
sha256 = "1b389268d126467105305ae4482df0189cc80a13aaab28d0946192b4ad0737a8",
strip_prefix = "tools-go-vcs-v0.1.0-deprecated/go/vcs",
patches = [
# releaser:patch-cmd gazelle -repo_root . -go_prefix golang.org/x/tools/go/vcs -go_naming_convention import_alias
Label("//third_party:org_golang_x_tools_go_vcs-gazelle.patch"),
],
patch_args = ["-p1"],
)

# releaser:upgrade-dep golang sys
wrapper(
http_archive,
Expand Down
4 changes: 2 additions & 2 deletions go/tools/fetch_repo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ go_library(
srcs = ["main.go"],
importpath = "github.com/bazelbuild/rules_go/go/tools/fetch_repo",
visibility = ["//visibility:private"],
deps = ["@org_golang_x_tools//go/vcs:go_default_library"],
deps = ["@org_golang_x_tools_go_vcs//:go_default_library"],
)

go_test(
name = "go_default_test",
size = "small",
srcs = ["fetch_repo_test.go"],
embed = [":go_default_library"],
deps = ["@org_golang_x_tools//go/vcs:go_default_library"],
deps = ["@org_golang_x_tools_go_vcs//:go_default_library"],
)
30 changes: 30 additions & 0 deletions third_party/org_golang_x_tools_go_vcs-gazelle.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff -urN a/BUILD.bazel b/BUILD.bazel
--- a/BUILD.bazel 1970-01-01 01:00:00.000000000 +0100
+++ b/BUILD.bazel 2023-08-12 19:21:03.606016940 +0200
@@ -0,0 +1,26 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+
+go_library(
+ name = "vcs",
+ srcs = [
+ "discovery.go",
+ "env.go",
+ "http.go",
+ "vcs.go",
+ ],
+ importpath = "golang.org/x/tools/go/vcs",
+ visibility = ["//visibility:public"],
+ deps = ["@org_golang_x_sys//execabs:go_default_library"],
+)
+
+alias(
+ name = "go_default_library",
+ actual = ":vcs",
+ visibility = ["//visibility:public"],
+)
+
+go_test(
+ name = "vcs_test",
+ srcs = ["vcs_test.go"],
+ embed = [":vcs"],
+)

0 comments on commit 5206498

Please sign in to comment.