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 (11)
include:
- component: "${CI_SERVER_HOST}/ci/component/bazelisk/bazelisk@v1.0.0-beta.3"
- component: "${CI_SERVER_HOST}/ci/component/bazelisk/bazelisk@v1.0.0-beta.4"
inputs:
variables: |
CI_PROJECT_DIR
......@@ -21,6 +21,12 @@ default:
test:
extends: .bazelisk
cache:
- !reference [.bazelisk, cache]
- key: "bazel-cache-${CI_PROJECT_ID}"
paths:
- ".cache/bazel/disk"
- ".cache/bazel/repo"
parallel:
matrix:
- ROOT:
......
# [1.0.0-alpha.6](https://git.gitlab.arm.com/bazel/rules_git/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2024-08-20)
### Bug Fixes
- make fetch repository `git` direcotry public ([5169ce3](https://git.gitlab.arm.com/bazel/rules_git/commit/5169ce36d3f1dc899f3b0e9baeb24ced5b6e9875))
### Features
- **archive:** add `prefix` attribute ([58aecad](https://git.gitlab.arm.com/bazel/rules_git/commit/58aecad116e02e876dec356fd8430c173f5a50a1))
- **checkout:** add `prefix` attribute ([2714200](https://git.gitlab.arm.com/bazel/rules_git/commit/271420007abb52a6822fd1c92836cc4449d7489e))
- **fetch:** add `recursive` attribute ([ff8ece9](https://git.gitlab.arm.com/bazel/rules_git/commit/ff8ece97a48ed3a2574e59563de95882f6c5d8db))
# [1.0.0-alpha.5](https://git.gitlab.arm.com/bazel/rules_git/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2024-08-02)
### Bug Fixes
......
module(
name = "rules_git",
version = "1.0.0-alpha.5",
version = "1.0.0-alpha.6",
bazel_compatibility = [
">=7.1.0",
],
......
# Increase output log size
build --experimental_ui_max_stdouterr_bytes=268435456
# Declare all run commands that are loaded
common --announce_rc
......
......@@ -26,6 +26,10 @@ while test 0 -ne "${#}"; do
shift
FORMAT="${1?Must provide an argument for --format}"
;;
"--prefix")
shift
PREFIX="${1?Must provide an argument for --prefix}"
;;
"--output")
shift
OUTPUT="${1?Must provide an argument for --output}"
......@@ -39,7 +43,7 @@ while test 0 -ne "${#}"; do
esac
shift
done
readonly GITDIR FORMAT OUTPUT
readonly GITDIR FORMAT OUTPUT PREFIX
if test "${#}" -eq 0; then
echo >&2 "Must provide modules to archive"
exit 2
......@@ -78,7 +82,7 @@ done
--git-dir "${DST}" \
archive \
--format="${FORMAT}" \
--prefix="${RELATIVE}/" \
--prefix="${PREFIX-./}${RELATIVE}/" \
"${COMMIT}"
done
} | "${COMPRESS}" >"${OUTPUT}"
......@@ -30,6 +30,10 @@ ATTRS = {
executable = True,
cfg = "exec",
),
"prefix": attr.string(
doc = "A path prefix to for the archive.",
default = "./",
),
}
def _find_head(file):
......@@ -74,6 +78,7 @@ def implementation(ctx):
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("--prefix").add(ctx.attr.prefix)
args.add("--output").add(archive)
args.add_all(modules, map_each = _module)
......
......@@ -50,7 +50,7 @@ fi
# * `HEAD` must be writable
# * `objects`/`refs _must_ exist
# [1]: https://github.com/git/git/blob/21306a098c3f174ad4c2a5cddb9069ee27a548b0/setup.c#L355
DST="${WORKTREE}.working"
DST=".git"
readonly DST
"${MKDIR}" -p "${DST}"
for SRC in "${GITDIR}/"*; do
......
......@@ -19,6 +19,10 @@ ATTRS = {
allow_single_file = True,
default = ":template",
),
"prefix": attr.string(
doc = "A path prefix to checkout into.",
default = ".",
),
}
def _find_head(file):
......@@ -60,7 +64,7 @@ def implementation(ctx):
args = ctx.actions.args()
args.add_joined("--git-dir", ctx.files.dir, map_each = _find_head, join_with = ",", omit_if_empty = False)
args.add("--work-tree", worktree.path)
args.add("--work-tree", "{}/{}".format(worktree.path, ctx.attr.prefix))
args.add("--force")
args.add("checkout")
args.add_all(modules, map_each = _module)
......
......@@ -18,33 +18,39 @@ alias(
visibility = ["//visibility:public"],
)
alias(
name = "dir",
actual = "//.git:dir",
visibility = ["//visibility:public"],
)
git_checkout(
name = "checkout",
dir = "//.git:dir",
module = ":{{name}}",
dir = ":dir",
module = ":module",
visibility = ["//visibility:public"],
)
git_archive(
name = "archive.tar",
dir = "//.git:dir",
module = ":{{name}}",
dir = ":dir",
module = ":module",
visibility = ["//visibility:public"],
)
git_archive(
name = "archive.tar.gz",
compress = "@rules_git//git/archive/compress:gzip",
dir = "//.git:dir",
module = ":{{name}}",
dir = ":dir",
module = ":module",
visibility = ["//visibility:public"],
)
git_archive(
name = "archive.tar.bz2",
compress = "@rules_git//git/archive/compress:bzip2",
dir = "//.git:dir",
module = ":{{name}}",
dir = ":dir",
module = ":module",
visibility = ["//visibility:public"],
)
......@@ -52,7 +58,7 @@ git_archive(
name = "archive.tar.xz",
compress = "@rules_git//git/archive/compress:xz",
dir = "//.git:dir",
module = ":{{name}}",
module = ":module",
visibility = ["//visibility:public"],
)
......@@ -60,6 +66,6 @@ git_archive(
name = "archive.tar.zst",
compress = "@rules_git//git/archive/compress:zstd",
dir = "//.git:dir",
module = ":{{name}}",
module = ":module",
visibility = ["//visibility:public"],
)
......@@ -17,6 +17,10 @@ ATTRS = _ATTRS | {
"reference": attr.string(
doc = "A reference that contains the commit.",
),
"recursive": attr.bool(
doc = "Fetch all nested submodules.",
default = True,
),
}
def _guess(rctx, remote, commit, reference, *, dir, git, guesses = ("refs/heads/main", "refs/heads/master", "refs/heads/trunk")):
......@@ -189,7 +193,7 @@ def _submodules(rctx, module, *, dir, git):
remote = module.remote,
)
def _recursive(rctx, *, remote, commit, reference, dir, git):
def _modules(rctx, *, remote, commit, reference, dir, git, recursive = True):
"""
Recursively fetches a remote commit into a `git` directory.
......@@ -200,6 +204,7 @@ def _recursive(rctx, *, remote, commit, reference, dir, git):
reference: A reference that contains the commit SHA.
dir: The `git` directory to store the object into.
git: The path to the `git` CLI.
recursive: Fetch all nested submodules
Returns:
The collection of modules fetched.
......@@ -214,6 +219,10 @@ def _recursive(rctx, *, remote, commit, reference, dir, git):
)
modules = [root]
if not recursive:
return modules
for i in range(0, 0x7ee7babe):
if len(modules) <= i:
break
......@@ -226,7 +235,7 @@ def _recursive(rctx, *, remote, commit, reference, dir, git):
return modules
def fetch(rctx, *, remote = None, commit = None, reference = None, dir = None, git = None):
def fetch(rctx, *, remote = None, commit = None, reference = None, dir = None, git = None, recursive = True):
"""
Fetches a remote commit into a `git` directory.
......@@ -239,6 +248,7 @@ def fetch(rctx, *, remote = None, commit = None, reference = None, dir = None, g
reference: A reference that contains the commit SHA.
dir: The `git` directory to store the object into.
git: The path to the `git` CLI.
recursive: Fetch all nested submodules
Returns:
The collection of modules fetched.
......@@ -254,7 +264,7 @@ def fetch(rctx, *, remote = None, commit = None, reference = None, dir = None, g
if len(commit) != 40 or not commit.isalnum():
fail("Can only fetch fully qualified commits: {}".format(commit))
modules = _recursive(rctx, git = git, dir = dir, commit = commit, reference = reference, remote = remote)
modules = _modules(rctx, git = git, dir = dir, commit = commit, reference = reference, remote = remote, recursive = recursive)
head = dir.get_child("HEAD")
rctx.file(head, commit, executable = False)
......