Skip to content

Instantly share code, notes, and snippets.

@evie404
Created November 27, 2019 20:01
Show Gist options
  • Save evie404/abadfd810ba13ad295f9987348ffc6af to your computer and use it in GitHub Desktop.
Save evie404/abadfd810ba13ad295f9987348ffc6af to your computer and use it in GitHub Desktop.
load("@bazel_gazelle//:deps.bzl", "go_repository")
# github_go_repository is a wrapper around go_repository to make the fetching of github repos easier
# by converting git clones to http archive downloads. The latter is fast, more reliable, actually
# cachable, and actually recommended by the Bazel team.
# It does have some caveats, so it's not meant to be a complete replacement of `go_repository`.
def github_go_repository(
name,
importpath,
commit,
repo_url = "",
**kwargs):
# when repo_url is not defined, we expect it to be the importpath
if repo_url == "":
repo_url = importpath
repo = repo_url.split("/").pop()
url = "https://" + repo_url + "/archive/" + commit + ".tar.gz"
go_repository(
name = name,
importpath = importpath,
strip_prefix = repo + "-" + commit,
urls = [url],
**kwargs)
@evie404
Copy link
Author

evie404 commented Dec 4, 2019

@mariusgrigoriu that's covered by kwargs

@evie404
Copy link
Author

evie404 commented Mar 7, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment