fix(local): shell-quote git args in the auto-patch push and trial-build gate #126
2 changed files with 13 additions and 4 deletions
|
|
@ -435,7 +435,9 @@ if (do_write) {
|
||||||
save_ledger(merge_ledger(load_ledger(), new_ledger_records))
|
save_ledger(merge_ledger(load_ledger(), new_ledger_records))
|
||||||
|
|
||||||
git <- function(...) {
|
git <- function(...) {
|
||||||
st <- system2("git", c(...), stdout = TRUE, stderr = TRUE)
|
# system2() with captured output runs via /bin/sh, so shell-quote every arg
|
||||||
|
# (commit messages contain "()", refs contain "^{}", etc.).
|
||||||
|
st <- system2("git", shQuote(c(...)), stdout = TRUE, stderr = TRUE)
|
||||||
if (!identical(attr(st, "status"), NULL)) {
|
if (!identical(attr(st, "status"), NULL)) {
|
||||||
stop(sprintf(
|
stop(sprintf(
|
||||||
"git %s failed:\n%s",
|
"git %s failed:\n%s",
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,16 @@ current <- if (file.exists(registry_file)) {
|
||||||
# silently treating the base as empty would trial-build the WHOLE registry
|
# silently treating the base as empty would trial-build the WHOLE registry
|
||||||
# instead of just the entries the branch adds.
|
# instead of just the entries the branch adds.
|
||||||
registry_rel <- "local/patches/registry.json"
|
registry_rel <- "local/patches/registry.json"
|
||||||
|
# system2() with captured output runs via /bin/sh, so shell-quote the git args
|
||||||
|
# (refs contain "^{}" and ":" that the shell would otherwise mangle).
|
||||||
ref_ok <- suppressWarnings(system2(
|
ref_ok <- suppressWarnings(system2(
|
||||||
"git",
|
"git",
|
||||||
c("rev-parse", "--verify", "--quiet", sprintf("%s^{commit}", base_ref)),
|
shQuote(c(
|
||||||
|
"rev-parse",
|
||||||
|
"--verify",
|
||||||
|
"--quiet",
|
||||||
|
sprintf("%s^{commit}", base_ref)
|
||||||
|
)),
|
||||||
stdout = TRUE,
|
stdout = TRUE,
|
||||||
stderr = FALSE
|
stderr = FALSE
|
||||||
))
|
))
|
||||||
|
|
@ -63,14 +70,14 @@ if (!is.null(attr(ref_ok, "status"))) {
|
||||||
}
|
}
|
||||||
in_base <- suppressWarnings(system2(
|
in_base <- suppressWarnings(system2(
|
||||||
"git",
|
"git",
|
||||||
c("ls-tree", base_ref, "--", registry_rel),
|
shQuote(c("ls-tree", base_ref, "--", registry_rel)),
|
||||||
stdout = TRUE,
|
stdout = TRUE,
|
||||||
stderr = FALSE
|
stderr = FALSE
|
||||||
))
|
))
|
||||||
file_in_base <- length(in_base) > 0L && any(nzchar(in_base))
|
file_in_base <- length(in_base) > 0L && any(nzchar(in_base))
|
||||||
base_json <- suppressWarnings(system2(
|
base_json <- suppressWarnings(system2(
|
||||||
"git",
|
"git",
|
||||||
c("show", sprintf("%s:%s", base_ref, registry_rel)),
|
shQuote(c("show", sprintf("%s:%s", base_ref, registry_rel))),
|
||||||
stdout = TRUE,
|
stdout = TRUE,
|
||||||
stderr = FALSE
|
stderr = FALSE
|
||||||
))
|
))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue