Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • bazel/rules_git
1 result
Show changes
Commits on Source (8)
# `bzlmod` pre-release registries
common --registry https://bcr.bazel.build
common --registry=https://gitlab.arm.com/bazel/rules_download/-/releases/v1.0.0-alpha.8/downloads
common --registry=https://gitlab.arm.com/bazel/rules_coreutils/-/releases/v1.0.0-alpha.6/downloads
# Build cache
build --experimental_guard_against_concurrent_changes
......
7.1.1
7.2.1rc2
......@@ -30,7 +30,8 @@ test:
- local
- remote
script:
- cd "${ROOT}"; bazelisk test --config="${CONFIG}" //...
- (cd "${ROOT}"; bazelisk build --config="${CONFIG}" //...)
- (cd "${ROOT}"; bazelisk test --config="${CONFIG}" //...)
# TODO: switch this out for `rules_semantic_release`
semantic-release:
......
# [1.0.0-alpha.3](https://git.gitlab.arm.com/bazel/rules_git/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2024-08-02)
### Bug Fixes
- pin to Bazel 7.2.1rc2 for `TreeArtifact` [bugfix] ([34881e7](https://git.gitlab.arm.com/bazel/rules_git/commit/34881e7af1fbca6c43fefd4349bb06ca441cfe4d)), closes [/github.com/bazelbuild/bazel/issues/22151#issuecomment-2183467522](https://git.gitlab.arm.com//github.com/bazelbuild/bazel/issues/22151/issues/issuecomment-2183467522)
### Features
- add `git_archive` rule ([0b386ee](https://git.gitlab.arm.com/bazel/rules_git/commit/0b386ee9f38cac8c9d83e83ca38ab8f88ee27b86))
- upgrade to `bazel-git@1.0.0-beta.9` ([5d6a7e3](https://git.gitlab.arm.com/bazel/rules_git/commit/5d6a7e3ad7876b000cc46de65322f6d17eee4234))
# [1.0.0-alpha.2](https://git.gitlab.arm.com/bazel/rules_git/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2024-05-15)
### Bug Fixes
......
module(
name = "rules_git",
version = "1.0.0-alpha.2",
version = "1.0.0-alpha.3",
bazel_compatibility = [
">=7.1.0",
],
......@@ -8,9 +8,10 @@ module(
)
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "toolchain_utils", version = "1.0.0-beta.9")
bazel_dep(name = "toolchain_utils", version = "1.0.0-beta.13")
bazel_dep(name = "download_utils", version = "1.0.0-beta.2")
bazel_dep(name = "rules_coreutils", version = "1.0.0-beta.1")
bazel_dep(name = "rules_coreutils", version = "1.0.0-beta.4")
bazel_dep(name = "ape", version = "1.0.0-beta.12")
download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "download_file")
......@@ -25,15 +26,15 @@ download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "downlo
"entrypoint": "git",
},
output = binary,
urls = ["https://gitlab.arm.com/api/v4/projects/bazel%2Fgit/packages/generic/release/1.0.0-alpha.8/{}".format(binary)],
urls = ["https://gitlab.arm.com/api/v4/projects/bazel%2Fgit/packages/generic/release/1.0.0-alpha.9/{}".format(binary)],
)
for binary, integrity in (
("amd64-linux-bazel-git", "sha256-krzgELhKTt+I/Wg6Vi9T+gfF1vQnRHtx61tlNmXgUAw="),
("arm64-linux-bazel-git", "sha256-JgRhWkcfh72AaR0aBV/M+Bf8CL/cYrtzwcObkqx4hEs="),
("amd64-darwin-bazel-git", "sha256-6audwdUyig0itmhkawBROxLdFYMog6nCkjFhPZSOTFg="),
("arm64-darwin-bazel-git", "sha256-nb3pJ+ZD8xMBjUCgJ5WP52ZqtKhcuUh1kDXvHnrqBL0="),
("amd64-windows-bazel-git.exe", "sha256-MI9lEjEg0kKbJhMidX9nbQY/xEmVdQ2KVnsyrR7ifbY="),
("arm64-windows-bazel-git.exe", "sha256-rPFzGUiXlO2SHnw5k4/CR+sFJQt3xptUOAKIlVuh24Q="),
("amd64-linux-bazel-git", "sha256-fWAiKdC+wreO/Rm5+qlDDJXBDd16QprJsJo1/RNv2SU="),
("arm64-linux-bazel-git", "sha256-kXscEZO2t0kb4628WgFtyJEG9ldhfmmxESeftooHtdA="),
("amd64-darwin-bazel-git", "sha256-aI/sGwYgbEc3oOvGCk/ZsQ0orwfxzqC6PyIPBdOQsgg="),
("arm64-darwin-bazel-git", "sha256-8Y3IRacAg1nmL1/FIbLVPcoM8/J3zrcPzS8NKR8eai8="),
("amd64-windows-bazel-git.exe", "sha256-ZrpJMlSyG9ZES6OfI4Gd+1SyvL3P5meCX3vvve4isf4="),
("arm64-windows-bazel-git.exe", "sha256-ks6HpcSGN4QTjLLiXWUnWxIDO4hrmEPB1a1jvmllagM="),
)
]
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
# `bzlmod` pre-release registries
common --registry https://bcr.bazel.build
common --registry=https://gitlab.arm.com/bazel/rules_download/-/releases/v1.0.0-alpha.8/downloads
common --registry=https://gitlab.arm.com/bazel/rules_coreutils/-/releases/v1.0.0-alpha.6/downloads
# Build cache
build --experimental_guard_against_concurrent_changes
......
7.1.1
7.2.1rc2
......@@ -5,9 +5,11 @@ module(
],
)
bazel_dep(name = "rules_git", version = "0.0.0")
bazel_dep(name = "rules_git")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "rules_diff", version = "1.0.0-beta.3")
bazel_dep(name = "toolchain_utils", version = "1.0.0-beta.9", dev_dependency=True)
bazel_dep(name = "toolchain_utils", version = "1.0.0-beta.11", dev_dependency = True)
local_path_override(
module_name = "rules_git",
......
This diff is collapsed.
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_diff//diff/directory/test:defs.bzl", "diff_directory_test")
diff_directory_test(
......@@ -6,3 +7,38 @@ diff_directory_test(
a = "@github-git-git-2.43.0//:checkout",
b = "@github-git-git-c089584ac8dedc3aa7c2c404839bc098050298a2//:checkout",
)
build_test(
name = "archive.tar",
targets = [
"@github-git-git-c089584ac8dedc3aa7c2c404839bc098050298a2//:archive.tar",
],
)
build_test(
name = "archive.tar.gz",
targets = [
"@github-git-git-c089584ac8dedc3aa7c2c404839bc098050298a2//:archive.tar.gz",
],
)
build_test(
name = "archive.tar.bz2",
targets = [
"@github-git-git-c089584ac8dedc3aa7c2c404839bc098050298a2//:archive.tar.bz2",
],
)
build_test(
name = "archive.tar.xz",
targets = [
"@github-git-git-c089584ac8dedc3aa7c2c404839bc098050298a2//:archive.tar.xz",
],
)
build_test(
name = "archive.tar.zst",
targets = [
"@github-git-git-c089584ac8dedc3aa7c2c404839bc098050298a2//:archive.tar.zst",
],
)
alias(
name = "template",
actual = select({
"@toolchain_utils//toolchain/constraint/os:windows": ":nt.tmpl.bat",
"//conditions:default": "posix.tmpl.sh",
}),
visibility = ["//visibility:public"],
)
alias(
name = "cat",
actual = "@ape//ape:cat",
visibility = ["//visibility:public"],
)
alias(
name = "gzip",
actual = "@ape//ape:gzip",
visibility = ["//visibility:public"],
)
alias(
name = "bzip2",
actual = "@ape//ape:bzip2",
visibility = ["//visibility:public"],
)
alias(
name = "xz",
actual = "@ape//ape:xz",
visibility = ["//visibility:public"],
)
alias(
name = "zstd",
actual = "@ape//ape:zstd",
visibility = ["//visibility:public"],
)
load(":rule.bzl", _archive = "archive")
visibility("public")
git_archive = _archive
#! /usr/bin/env sh
# Strict Shell
set -o errexit
set -o nounset
# Bazel replacements
SORT="{{sort}}"
CP="{{cp}}"
CHMOD="{{chmod}}"
LN="{{ln}}"
MKDIR="{{mkdir}}"
COMPRESS="{{compress}}"
GIT="{{git}}"
readonly SORT CP CHMOD LN MKDIR COMPRESS GIT
# Parse arguments
while test 0 -ne "${#}"; do
case "${1}" in
"--git-dir")
shift
GITDIR="${1?Must provide an argument for --git-dir}"
;;
"archive") ;;
"--format")
shift
FORMAT="${1?Must provide an argument for --format}"
;;
"--output")
shift
OUTPUT="${1?Must provide an argument for --output}"
shift
break
;;
*)
printf >&2 'Error: unknown argument: %s\n' "${1}"
exit 2
;;
esac
shift
done
readonly GITDIR FORMAT OUTPUT
if test "${#}" -eq 0; then
echo >&2 "Must provide modules to archive"
exit 2
fi
# The `git` CLI has strict requirements for the `.git` directory[1]
# Specifically:
# * `HEAD` if a symlink _must_ point to a file in the `refs` directory
# * `HEAD` must be writable
# * `objects`/`refs _must_ exist
# [1]: https://github.com/git/git/blob/21306a098c3f174ad4c2a5cddb9069ee27a548b0/setup.c#L355
DST="${OUTPUT}.working"
readonly DST
"${MKDIR}" -p "${DST}"
for SRC in "${GITDIR}/"*; do
case "${SRC}" in
*"/HEAD")
"${CP}" -p "${SRC}" "${DST}/${SRC#"${GITDIR}"/}"
"${CHMOD}" u+w "${DST}/${SRC#"${GITDIR}"/}"
;;
*"/objects" | *"/refs") # TODO: can we symlink here?
"${CP}" -RLp "${SRC}" "${DST}/${SRC#"${GITDIR}"/}"
;;
*)
"${LN}" -s "${SRC}" "${DST}/${SRC#"${GITDIR}"/}"
;;
esac
done
# Do the archive of the module
{
(for MODULE in "${@}"; do echo "${MODULE}"; done) |
"${SORT}" -rt ":" |
while IFS=: read -r RELATIVE COMMIT; do
"${GIT}" \
--git-dir "${DST}" \
archive \
--format="${FORMAT}" \
--prefix="${RELATIVE}/" \
"${COMMIT}"
done
} | "${COMPRESS}" >"${OUTPUT}"
load("//git/modules:defs.bzl", "GitModulesInfo")
visibility("//...")
DOC = """Checks out a working tree from a fetched repository."""
ATTRS = {
"dir": attr.label(
doc = "`git` directory to checkout `commit`.",
mandatory = True,
),
"module": attr.label(
doc = "The commit SHA to archive the `objects`.",
providers = [GitModulesInfo],
mandatory = True,
),
"template": attr.label(
doc = "The script to template and run.",
allow_single_file = True,
default = ":template",
),
"format": attr.string(
doc = "The format of the archive",
values = ["tar"],
default = "tar",
),
"compress": attr.label(
doc = "A compression binary.",
default = "//git/archive/compress:cat",
executable = True,
cfg = "exec",
),
}
def _find_head(file):
if file.basename == "HEAD":
return file.dirname
return None
def _module(module):
return "{}:{}".format(module.path, module.commit)
def implementation(ctx):
sort = ctx.toolchains["@rules_coreutils//coreutils/toolchain/sort:type"]
chmod = ctx.toolchains["@rules_coreutils//coreutils/toolchain/chmod:type"]
cp = ctx.toolchains["@rules_coreutils//coreutils/toolchain/cp:type"]
ln = ctx.toolchains["@rules_coreutils//coreutils/toolchain/ln:type"]
mkdir = ctx.toolchains["@rules_coreutils//coreutils/toolchain/mkdir:type"]
git = ctx.toolchains["//git/toolchain/git:type"]
rendered = ctx.actions.declare_file("{}.rendered.{}".format(ctx.label.name, ctx.file.template.extension))
substitutions = ctx.actions.template_dict()
# TODO: remove `.path` when `TemplateDict#add` supports `File` for Path Mapping
substitutions.add("{{sort}}", sort.executable.path)
substitutions.add("{{chmod}}", chmod.executable.path)
substitutions.add("{{cp}}", cp.executable.path)
substitutions.add("{{ln}}", ln.executable.path)
substitutions.add("{{mkdir}}", mkdir.executable.path)
substitutions.add("{{compress}}", ctx.executable.compress.path)
substitutions.add("{{git}}", git.executable.path)
ctx.actions.expand_template(
output = rendered,
template = ctx.file.template,
computed_substitutions = substitutions,
is_executable = True,
)
modules = ctx.attr.module[GitModulesInfo].modules
archive = ctx.actions.declare_file("{}".format(ctx.label.name))
args = ctx.actions.args()
args.add_joined("--git-dir", ctx.files.dir, map_each = _find_head, join_with = ",", omit_if_empty = False)
args.add("archive")
args.add("--format").add(ctx.attr.format)
args.add("--output").add(archive)
args.add_all(modules, map_each = _module)
ctx.actions.run(
outputs = [archive],
inputs = ctx.files.dir,
executable = rendered,
tools = [
sort.run,
chmod.run,
cp.run,
ln.run,
mkdir.run,
git.run,
ctx.attr.compress.files_to_run,
],
arguments = [args],
mnemonic = "GitArchive",
)
return DefaultInfo(files = depset([archive]))
git_archive = rule(
doc = DOC,
attrs = ATTRS,
implementation = implementation,
toolchains = [
"//git/toolchain/git:type",
"@rules_coreutils//coreutils/toolchain/sort:type",
"@rules_coreutils//coreutils/toolchain/chmod:type",
"@rules_coreutils//coreutils/toolchain/cp:type",
"@rules_coreutils//coreutils/toolchain/ln:type",
"@rules_coreutils//coreutils/toolchain/mkdir:type",
],
)
archive = git_archive
load("@rules_git//git/module:defs.bzl", "git_module")
load("@rules_git//git/checkout:defs.bzl", "git_checkout")
load("@rules_git//git/archive:defs.bzl", "git_archive")
git_module(
name = "{{name}}",
......@@ -23,3 +24,42 @@ git_checkout(
module = ":{{name}}",
visibility = ["//visibility:public"],
)
git_archive(
name = "archive.tar",
dir = "//.git:dir",
module = ":{{name}}",
visibility = ["//visibility:public"],
)
git_archive(
name = "archive.tar.gz",
compress = "@rules_git//git/archive/compress:gzip",
dir = "//.git:dir",
module = ":{{name}}",
visibility = ["//visibility:public"],
)
git_archive(
name = "archive.tar.bz2",
compress = "@rules_git//git/archive/compress:bzip2",
dir = "//.git:dir",
module = ":{{name}}",
visibility = ["//visibility:public"],
)
git_archive(
name = "archive.tar.xz",
compress = "@rules_git//git/archive/compress:xz",
dir = "//.git:dir",
module = ":{{name}}",
visibility = ["//visibility:public"],
)
git_archive(
name = "archive.tar.zst",
compress = "@rules_git//git/archive/compress:zstd",
dir = "//.git:dir",
module = ":{{name}}",
visibility = ["//visibility:public"],
)
......@@ -2,7 +2,7 @@ load("@bazel_skylib//lib:structs.bzl", "structs")
load(":execute.bzl", "execute")
load(":submodules.bzl", "submodules")
load(":init.bzl", "init", _ATTRS = "ATTRS")
load(":log.bzl", "log", "LEVEL")
load(":log.bzl", "LEVEL", "log")
visibility("//git/...")
......