From a589c71784e4114675a220e664c04a3a6185a085 Mon Sep 17 00:00:00 2001 From: Vikram Rawat Date: Tue, 6 Oct 2026 06:35:18 +0000 Subject: [PATCH 1/4] chore: preserve dev/ after upstream sync --- .Rbuildignore | 1 + dev/check_feature.r | 93 +++++++++++++++++++++ dev/run_dev.r | 4 + dev/scripts/check_feature.ps1 | 12 +++ dev/scripts/check_feature.sh | 9 ++ dev/scripts/sync_upstream.ps1 | 12 +++ dev/scripts/sync_upstream.sh | 13 +++ dev/sync_upstream.r | 150 ++++++++++++++++++++++++++++++++++ 8 files changed, 294 insertions(+) create mode 100644 dev/check_feature.r create mode 100644 dev/run_dev.r create mode 100644 dev/scripts/check_feature.ps1 create mode 100644 dev/scripts/check_feature.sh create mode 100644 dev/scripts/sync_upstream.ps1 create mode 100644 dev/scripts/sync_upstream.sh create mode 100644 dev/sync_upstream.r diff --git a/.Rbuildignore b/.Rbuildignore index 0ce030ac..83c8e9da 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -21,3 +21,4 @@ images ^.revdeprefs\.yaml$ ^revdep$ ^\.covrignore$ +^dev/ diff --git a/dev/check_feature.r b/dev/check_feature.r new file mode 100644 index 00000000..71670959 --- /dev/null +++ b/dev/check_feature.r @@ -0,0 +1,93 @@ +# check_feature.r --- Test a feature branch against scda.test -- + +# Config --- user inputs -------------------------------------- + +if (!interactive()) { + stop("🚨 This script needs interactive mode for readline(). Run in RStudio/Positron!") +} + +branch_name <- readline("đŸŒŋ Branch name: ") +package <- readline("đŸ“Ļ Package name (default: junco): ") + +if (nchar(trimws(package)) == 0L) package <- "junco" + +package <- tolower(trimws(package)) +branch_name <- trimws(branch_name) + +if (nchar(branch_name) == 0L) { + stop("🚨 Branch name cannot be empty!") +} + +# Branch --- check if exists, create or switch ---------------- + +all_branches <- run_git("branch", "-a") +branch_exists <- any(grepl(sprintf("/%s$|^..%s$", branch_name, branch_name), all_branches)) + +if (branch_exists) { + message(sprintf("âš ī¸ Branch '%s' already exists!", branch_name)) + action <- tolower(trimws(readline(" [s]witch to it / [d]elete & recreate / [q]uit? "))) + + if (action == "q") { + stop("🛑 Aborted by user.") + } else if (action == "d") { + message(sprintf("đŸ—‘ī¸ Deleting '%s'...", branch_name)) + run_git("checkout", branch) + tryCatch(run_git("branch", "-D", branch_name), error = function(e) NULL) + tryCatch(run_git("push", "origin", "--delete", branch_name), error = function(e) NULL) + run_git("checkout", "-b", branch_name) + message(sprintf("đŸŒŋ Branch '%s' recreated fresh from '%s'!", branch_name, branch)) + } else { + run_git("checkout", branch_name) + run_git("fetch", "origin", branch_name) + message(sprintf("🔀 Switched to existing branch '%s'.", branch_name)) + } +} else { + run_git("checkout", "-b", branch_name) + message(sprintf("đŸŒŋ Branch '%s' created from '%s'!", branch_name, branch)) +} + +# DESCRIPTION --- update Remotes entry ------------------------ + +desc_path <- file.path(repo_root, "DESCRIPTION") +desc_lines <- readLines(desc_path) + +# Match org/package@branch but stop before comma if present +pkg_pattern <- sprintf("(\\S+/%s)@[^, ]+", package) +match_idx <- grep(pkg_pattern, desc_lines, ignore.case = TRUE) + +if (length(match_idx) == 0L) { + stop(sprintf("🚨 Package '%s' not found in DESCRIPTION Remotes!", package)) +} + +old_line <- desc_lines[match_idx] +new_line <- sub( + sprintf("(\\S+/%s)@[^, ]+", package), + sprintf("\\1@%s", branch_name), + old_line, + ignore.case = TRUE +) + +desc_lines[match_idx] <- new_line +writeLines(desc_lines, desc_path) + +message(sprintf("📝 DESCRIPTION updated:\n Old: %s\n New: %s", trimws(old_line), trimws(new_line))) + +# Push --- commit and push ------------------------------------ + +run_git("add", "DESCRIPTION") + +# Check if there's actually something to commit +staged <- run_git("diff", "--cached", "--name-only") + +if (length(staged) > 0L && any(nchar(staged) > 0L)) { + run_git("commit", "-m", sprintf("'feat: test %s@%s'", package, branch_name)) + run_git("push", "origin", branch_name) + message(sprintf("🚀 Pushed! Now go run the workflow on branch '%s'", branch_name)) +} else { + message("â„šī¸ DESCRIPTION unchanged — nothing to commit.") + run_git("push", "origin", branch_name) + message(sprintf("🚀 Branch '%s' is up to date on origin.", branch_name)) +} + +message("🔗 https://github.com/vikram-rawat/scda.test/actions") +message("🎉 Feature branch ready!") diff --git a/dev/run_dev.r b/dev/run_dev.r new file mode 100644 index 00000000..660d2346 --- /dev/null +++ b/dev/run_dev.r @@ -0,0 +1,4 @@ +# run_dev.r --- Orchestrator: sync upstream + test feature ----- + +source("dev/sync_upstream.r") +source("dev/check_feature.r") diff --git a/dev/scripts/check_feature.ps1 b/dev/scripts/check_feature.ps1 new file mode 100644 index 00000000..92b972dc --- /dev/null +++ b/dev/scripts/check_feature.ps1 @@ -0,0 +1,12 @@ +$ErrorActionPreference = "Stop" + +Set-Location (git rev-parse --show-toplevel) + +Write-Host "đŸŒŋ Creating branch '{{branch_name}}'..." +$result = git checkout -b {{branch_name}} 2>&1 +if ($LASTEXITCODE -ne 0) { + Write-Host "âš ī¸ Branch exists, switching..." + git checkout {{branch_name}} +} + +Write-Host "✅ Branch '{{branch_name}}' ready!" diff --git a/dev/scripts/check_feature.sh b/dev/scripts/check_feature.sh new file mode 100644 index 00000000..c163f900 --- /dev/null +++ b/dev/scripts/check_feature.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -euo pipefail + +cd "$(git rev-parse --show-toplevel)" + +echo "đŸŒŋ Creating branch '{{branch_name}}'..." +git checkout -b {{branch_name}} || { echo "âš ī¸ Branch exists, switching..."; git checkout {{branch_name}}; } + +echo "✅ Branch '{{branch_name}}' ready!" diff --git a/dev/scripts/sync_upstream.ps1 b/dev/scripts/sync_upstream.ps1 new file mode 100644 index 00000000..99e94ca1 --- /dev/null +++ b/dev/scripts/sync_upstream.ps1 @@ -0,0 +1,12 @@ +$ErrorActionPreference = "Stop" + +Set-Location (git rev-parse --show-toplevel) + +Write-Host "📡 Fetching {{upstream}}..." +git fetch {{upstream}} + +Write-Host "🔄 Resetting {{branch}} to {{upstream}}/{{branch}}..." +git checkout {{branch}} +git reset --hard {{upstream}}/{{branch}} + +Write-Host "✅ Done! {{branch}} synced with {{upstream}}/{{branch}}." diff --git a/dev/scripts/sync_upstream.sh b/dev/scripts/sync_upstream.sh new file mode 100644 index 00000000..2842cc6b --- /dev/null +++ b/dev/scripts/sync_upstream.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -euo pipefail + +cd "$(git rev-parse --show-toplevel)" + +echo "📡 Fetching {{upstream}}..." +git fetch {{upstream}} + +echo "🔄 Resetting {{branch}} to {{upstream}}/{{branch}}..." +git checkout {{branch}} +git reset --hard {{upstream}}/{{branch}} + +echo "✅ Done! {{branch}} synced with {{upstream}}/{{branch}}." diff --git a/dev/sync_upstream.r b/dev/sync_upstream.r new file mode 100644 index 00000000..b94d9a21 --- /dev/null +++ b/dev/sync_upstream.r @@ -0,0 +1,150 @@ +# sync_upstream.r --- Sync main with upstream via scripts ------ + +# Config --- edit these if remotes change ---------------------- + +upstream <- "upstream" +branch <- "main" +dev_branch <- "dev_scripts" +dev_pattern <- "^dev/" + +# Preflight --- check dependencies ---------------------------- + +if (!requireNamespace("glue", quietly = TRUE)) { + stop("🚨 glue package not installed. Run: install.packages('glue')") +} + +# Helper --- run git and stop on failure ---------------------- + +run_git <- function(...) { + args <- c(...) + result <- system2("git", args, stdout = TRUE, stderr = TRUE) + status <- attr(result, "status") + if (!is.null(status) && status != 0L) { + stop(sprintf( + "🚨 git %s failed:\n%s", + paste(args, collapse = " "), + paste(result, collapse = "\n") + )) + } + invisible(result) +} + +# Setup --- paths and OS detection ---------------------------- + +repo_root <- trimws(run_git("rev-parse", "--show-toplevel")) +setwd(repo_root) +message(sprintf("📁 Repo root: %s", repo_root)) + +is_windows <- .Platform$OS.type == "windows" + +# Preflight --- verify remotes exist -------------------------- + +remotes <- run_git("remote") +if (!upstream %in% remotes) { + stop(sprintf( + "🚨 Remote '%s' not found. Run:\ngit remote add %s https://github.com/insightsengineering/scda.test.git", + upstream, upstream + )) +} + +# Preflight --- verify dev_scripts branch exists -------------- + +all_branches <- run_git("branch", "-a") +has_dev_branch <- any(grepl(dev_branch, all_branches, fixed = TRUE)) +if (!has_dev_branch) { + stop(sprintf( + "🚨 Branch '%s' not found. Run:\ngit checkout -b %s && git push origin %s && git checkout main", + dev_branch, dev_branch, dev_branch + )) +} + +# Preflight --- must be on target branch ---------------------- + +current_branch <- trimws(run_git("branch", "--show-current")) +if (current_branch != branch) { + message(sprintf("🔀 Switching from '%s' to '%s'...", current_branch, branch)) + run_git("checkout", branch) +} + +# Template --- read from dev_scripts branch ------------------- + +template_file <- if (is_windows) "sync_upstream.ps1" else "sync_upstream.sh" +template_ref <- sprintf("%s:dev/scripts/%s", dev_branch, template_file) + +template_content <- tryCatch( + run_git("show", template_ref), + error = function(e) { + stop(sprintf("🚨 Template not found in branch '%s': %s", dev_branch, template_ref)) + } +) + +filled_script <- glue::glue( + paste(template_content, collapse = "\n"), + upstream = upstream, + branch = branch, + .open = "{{", + .close = "}}" +) + +# Execute --- write to temp, run, show output ------------------ + +tmp <- tempfile(fileext = if (is_windows) ".ps1" else ".sh") +on.exit(unlink(tmp), add = TRUE) +writeLines(filled_script, tmp) + +if (is_windows) { + shell_cmd <- "powershell" + shell_args <- c("-ExecutionPolicy", "Bypass", "-File", tmp) +} else { + Sys.chmod(tmp, "755") + shell_cmd <- "bash" + shell_args <- tmp +} + +message(sprintf("â–ļī¸ Running: %s %s", shell_cmd, basename(tmp))) + +result <- system2(shell_cmd, shell_args, stdout = TRUE, stderr = TRUE) +status <- attr(result, "status") +if (is.null(status)) status <- 0L + +cat(result, sep = "\n") + +if (status != 0L) { + stop(sprintf("❌ Sync failed (exit %d). Fix the template in '%s' branch.", status, dev_branch)) +} + +message("✅ Sync complete! 🎉") + +# Restore --- checkout dev/ from dev_scripts branch ----------- + +message(sprintf("📂 Restoring dev/ from '%s' branch...", dev_branch)) +run_git("checkout", dev_branch, "--", "dev/") +message("📂 dev/ restored! đŸŽ¯") + +# Commit --- add dev/ back to history ------------------------- + +run_git("add", "dev/") +run_git("commit", "-m", "'chore: preserve dev/ after upstream sync'") +message("📝 dev/ committed!") + +# Housekeeping --- re-add dev/ exclusion to .Rbuildignore ------ + +rbuildignore_path <- file.path(repo_root, ".Rbuildignore") +rbuildignore <- readLines(rbuildignore_path) + +has_dev_entry <- any(grepl(dev_pattern, rbuildignore, fixed = TRUE)) + +if (!has_dev_entry) { + message("🔧 Re-adding dev/ exclusion to .Rbuildignore...") + writeLines(c(rbuildignore, dev_pattern), rbuildignore_path) + run_git("add", ".Rbuildignore") + run_git("commit", "--amend", "--no-edit") + message("📝 .Rbuildignore patched!") +} + +# Push --- force push to origin -------------------------------- + +run_git("push", "origin", branch, "--force") +message("🚀 Pushed to origin!") + +message("🎉 All done! main is synced with upstream + dev/ preserved!") From 13a67d4bb73c4e8eee856f69bbb818775ab9e806 Mon Sep 17 00:00:00 2001 From: Vikram Rawat Date: Tue, 6 Oct 2026 06:36:00 +0000 Subject: [PATCH 2/4] feat: test junco@fix/439-s-freq-j-optional-args-and-validation --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index eddc662a..e78af76c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -52,7 +52,7 @@ Suggests: VignetteBuilder: knitr Remotes: - johnsonandjohnson/junco@dev, + johnsonandjohnson/junco@fix/439-s-freq-j-optional-args-and-validation, johnsonandjohnson/pharmaverseadamjnj@main, johnsonandjohnson/pharmaversesdtmjnj@main, pharmaverse/formatters@main, From 59d8cd315807bf70bc43c866518e65429a2d88f6 Mon Sep 17 00:00:00 2001 From: Vikram Rawat Date: Wed, 7 Oct 2026 07:27:08 +0000 Subject: [PATCH 3/4] remove extra code --- dev/check_feature.r | 93 --------------------- dev/run_dev.r | 4 - dev/scripts/check_feature.ps1 | 12 --- dev/scripts/check_feature.sh | 9 -- dev/scripts/sync_upstream.ps1 | 12 --- dev/scripts/sync_upstream.sh | 13 --- dev/sync_upstream.r | 150 ---------------------------------- 7 files changed, 293 deletions(-) delete mode 100644 dev/check_feature.r delete mode 100644 dev/run_dev.r delete mode 100644 dev/scripts/check_feature.ps1 delete mode 100644 dev/scripts/check_feature.sh delete mode 100644 dev/scripts/sync_upstream.ps1 delete mode 100644 dev/scripts/sync_upstream.sh delete mode 100644 dev/sync_upstream.r diff --git a/dev/check_feature.r b/dev/check_feature.r deleted file mode 100644 index 71670959..00000000 --- a/dev/check_feature.r +++ /dev/null @@ -1,93 +0,0 @@ -# check_feature.r --- Test a feature branch against scda.test -- - -# Config --- user inputs -------------------------------------- - -if (!interactive()) { - stop("🚨 This script needs interactive mode for readline(). Run in RStudio/Positron!") -} - -branch_name <- readline("đŸŒŋ Branch name: ") -package <- readline("đŸ“Ļ Package name (default: junco): ") - -if (nchar(trimws(package)) == 0L) package <- "junco" - -package <- tolower(trimws(package)) -branch_name <- trimws(branch_name) - -if (nchar(branch_name) == 0L) { - stop("🚨 Branch name cannot be empty!") -} - -# Branch --- check if exists, create or switch ---------------- - -all_branches <- run_git("branch", "-a") -branch_exists <- any(grepl(sprintf("/%s$|^..%s$", branch_name, branch_name), all_branches)) - -if (branch_exists) { - message(sprintf("âš ī¸ Branch '%s' already exists!", branch_name)) - action <- tolower(trimws(readline(" [s]witch to it / [d]elete & recreate / [q]uit? "))) - - if (action == "q") { - stop("🛑 Aborted by user.") - } else if (action == "d") { - message(sprintf("đŸ—‘ī¸ Deleting '%s'...", branch_name)) - run_git("checkout", branch) - tryCatch(run_git("branch", "-D", branch_name), error = function(e) NULL) - tryCatch(run_git("push", "origin", "--delete", branch_name), error = function(e) NULL) - run_git("checkout", "-b", branch_name) - message(sprintf("đŸŒŋ Branch '%s' recreated fresh from '%s'!", branch_name, branch)) - } else { - run_git("checkout", branch_name) - run_git("fetch", "origin", branch_name) - message(sprintf("🔀 Switched to existing branch '%s'.", branch_name)) - } -} else { - run_git("checkout", "-b", branch_name) - message(sprintf("đŸŒŋ Branch '%s' created from '%s'!", branch_name, branch)) -} - -# DESCRIPTION --- update Remotes entry ------------------------ - -desc_path <- file.path(repo_root, "DESCRIPTION") -desc_lines <- readLines(desc_path) - -# Match org/package@branch but stop before comma if present -pkg_pattern <- sprintf("(\\S+/%s)@[^, ]+", package) -match_idx <- grep(pkg_pattern, desc_lines, ignore.case = TRUE) - -if (length(match_idx) == 0L) { - stop(sprintf("🚨 Package '%s' not found in DESCRIPTION Remotes!", package)) -} - -old_line <- desc_lines[match_idx] -new_line <- sub( - sprintf("(\\S+/%s)@[^, ]+", package), - sprintf("\\1@%s", branch_name), - old_line, - ignore.case = TRUE -) - -desc_lines[match_idx] <- new_line -writeLines(desc_lines, desc_path) - -message(sprintf("📝 DESCRIPTION updated:\n Old: %s\n New: %s", trimws(old_line), trimws(new_line))) - -# Push --- commit and push ------------------------------------ - -run_git("add", "DESCRIPTION") - -# Check if there's actually something to commit -staged <- run_git("diff", "--cached", "--name-only") - -if (length(staged) > 0L && any(nchar(staged) > 0L)) { - run_git("commit", "-m", sprintf("'feat: test %s@%s'", package, branch_name)) - run_git("push", "origin", branch_name) - message(sprintf("🚀 Pushed! Now go run the workflow on branch '%s'", branch_name)) -} else { - message("â„šī¸ DESCRIPTION unchanged — nothing to commit.") - run_git("push", "origin", branch_name) - message(sprintf("🚀 Branch '%s' is up to date on origin.", branch_name)) -} - -message("🔗 https://github.com/vikram-rawat/scda.test/actions") -message("🎉 Feature branch ready!") diff --git a/dev/run_dev.r b/dev/run_dev.r deleted file mode 100644 index 660d2346..00000000 --- a/dev/run_dev.r +++ /dev/null @@ -1,4 +0,0 @@ -# run_dev.r --- Orchestrator: sync upstream + test feature ----- - -source("dev/sync_upstream.r") -source("dev/check_feature.r") diff --git a/dev/scripts/check_feature.ps1 b/dev/scripts/check_feature.ps1 deleted file mode 100644 index 92b972dc..00000000 --- a/dev/scripts/check_feature.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -$ErrorActionPreference = "Stop" - -Set-Location (git rev-parse --show-toplevel) - -Write-Host "đŸŒŋ Creating branch '{{branch_name}}'..." -$result = git checkout -b {{branch_name}} 2>&1 -if ($LASTEXITCODE -ne 0) { - Write-Host "âš ī¸ Branch exists, switching..." - git checkout {{branch_name}} -} - -Write-Host "✅ Branch '{{branch_name}}' ready!" diff --git a/dev/scripts/check_feature.sh b/dev/scripts/check_feature.sh deleted file mode 100644 index c163f900..00000000 --- a/dev/scripts/check_feature.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -cd "$(git rev-parse --show-toplevel)" - -echo "đŸŒŋ Creating branch '{{branch_name}}'..." -git checkout -b {{branch_name}} || { echo "âš ī¸ Branch exists, switching..."; git checkout {{branch_name}}; } - -echo "✅ Branch '{{branch_name}}' ready!" diff --git a/dev/scripts/sync_upstream.ps1 b/dev/scripts/sync_upstream.ps1 deleted file mode 100644 index 99e94ca1..00000000 --- a/dev/scripts/sync_upstream.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -$ErrorActionPreference = "Stop" - -Set-Location (git rev-parse --show-toplevel) - -Write-Host "📡 Fetching {{upstream}}..." -git fetch {{upstream}} - -Write-Host "🔄 Resetting {{branch}} to {{upstream}}/{{branch}}..." -git checkout {{branch}} -git reset --hard {{upstream}}/{{branch}} - -Write-Host "✅ Done! {{branch}} synced with {{upstream}}/{{branch}}." diff --git a/dev/scripts/sync_upstream.sh b/dev/scripts/sync_upstream.sh deleted file mode 100644 index 2842cc6b..00000000 --- a/dev/scripts/sync_upstream.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -cd "$(git rev-parse --show-toplevel)" - -echo "📡 Fetching {{upstream}}..." -git fetch {{upstream}} - -echo "🔄 Resetting {{branch}} to {{upstream}}/{{branch}}..." -git checkout {{branch}} -git reset --hard {{upstream}}/{{branch}} - -echo "✅ Done! {{branch}} synced with {{upstream}}/{{branch}}." diff --git a/dev/sync_upstream.r b/dev/sync_upstream.r deleted file mode 100644 index b94d9a21..00000000 --- a/dev/sync_upstream.r +++ /dev/null @@ -1,150 +0,0 @@ -# sync_upstream.r --- Sync main with upstream via scripts ------ - -# Config --- edit these if remotes change ---------------------- - -upstream <- "upstream" -branch <- "main" -dev_branch <- "dev_scripts" -dev_pattern <- "^dev/" - -# Preflight --- check dependencies ---------------------------- - -if (!requireNamespace("glue", quietly = TRUE)) { - stop("🚨 glue package not installed. Run: install.packages('glue')") -} - -# Helper --- run git and stop on failure ---------------------- - -run_git <- function(...) { - args <- c(...) - result <- system2("git", args, stdout = TRUE, stderr = TRUE) - status <- attr(result, "status") - if (!is.null(status) && status != 0L) { - stop(sprintf( - "🚨 git %s failed:\n%s", - paste(args, collapse = " "), - paste(result, collapse = "\n") - )) - } - invisible(result) -} - -# Setup --- paths and OS detection ---------------------------- - -repo_root <- trimws(run_git("rev-parse", "--show-toplevel")) -setwd(repo_root) -message(sprintf("📁 Repo root: %s", repo_root)) - -is_windows <- .Platform$OS.type == "windows" - -# Preflight --- verify remotes exist -------------------------- - -remotes <- run_git("remote") -if (!upstream %in% remotes) { - stop(sprintf( - "🚨 Remote '%s' not found. Run:\ngit remote add %s https://github.com/insightsengineering/scda.test.git", - upstream, upstream - )) -} - -# Preflight --- verify dev_scripts branch exists -------------- - -all_branches <- run_git("branch", "-a") -has_dev_branch <- any(grepl(dev_branch, all_branches, fixed = TRUE)) -if (!has_dev_branch) { - stop(sprintf( - "🚨 Branch '%s' not found. Run:\ngit checkout -b %s && git push origin %s && git checkout main", - dev_branch, dev_branch, dev_branch - )) -} - -# Preflight --- must be on target branch ---------------------- - -current_branch <- trimws(run_git("branch", "--show-current")) -if (current_branch != branch) { - message(sprintf("🔀 Switching from '%s' to '%s'...", current_branch, branch)) - run_git("checkout", branch) -} - -# Template --- read from dev_scripts branch ------------------- - -template_file <- if (is_windows) "sync_upstream.ps1" else "sync_upstream.sh" -template_ref <- sprintf("%s:dev/scripts/%s", dev_branch, template_file) - -template_content <- tryCatch( - run_git("show", template_ref), - error = function(e) { - stop(sprintf("🚨 Template not found in branch '%s': %s", dev_branch, template_ref)) - } -) - -filled_script <- glue::glue( - paste(template_content, collapse = "\n"), - upstream = upstream, - branch = branch, - .open = "{{", - .close = "}}" -) - -# Execute --- write to temp, run, show output ------------------ - -tmp <- tempfile(fileext = if (is_windows) ".ps1" else ".sh") -on.exit(unlink(tmp), add = TRUE) -writeLines(filled_script, tmp) - -if (is_windows) { - shell_cmd <- "powershell" - shell_args <- c("-ExecutionPolicy", "Bypass", "-File", tmp) -} else { - Sys.chmod(tmp, "755") - shell_cmd <- "bash" - shell_args <- tmp -} - -message(sprintf("â–ļī¸ Running: %s %s", shell_cmd, basename(tmp))) - -result <- system2(shell_cmd, shell_args, stdout = TRUE, stderr = TRUE) -status <- attr(result, "status") -if (is.null(status)) status <- 0L - -cat(result, sep = "\n") - -if (status != 0L) { - stop(sprintf("❌ Sync failed (exit %d). Fix the template in '%s' branch.", status, dev_branch)) -} - -message("✅ Sync complete! 🎉") - -# Restore --- checkout dev/ from dev_scripts branch ----------- - -message(sprintf("📂 Restoring dev/ from '%s' branch...", dev_branch)) -run_git("checkout", dev_branch, "--", "dev/") -message("📂 dev/ restored! đŸŽ¯") - -# Commit --- add dev/ back to history ------------------------- - -run_git("add", "dev/") -run_git("commit", "-m", "'chore: preserve dev/ after upstream sync'") -message("📝 dev/ committed!") - -# Housekeeping --- re-add dev/ exclusion to .Rbuildignore ------ - -rbuildignore_path <- file.path(repo_root, ".Rbuildignore") -rbuildignore <- readLines(rbuildignore_path) - -has_dev_entry <- any(grepl(dev_pattern, rbuildignore, fixed = TRUE)) - -if (!has_dev_entry) { - message("🔧 Re-adding dev/ exclusion to .Rbuildignore...") - writeLines(c(rbuildignore, dev_pattern), rbuildignore_path) - run_git("add", ".Rbuildignore") - run_git("commit", "--amend", "--no-edit") - message("📝 .Rbuildignore patched!") -} - -# Push --- force push to origin -------------------------------- - -run_git("push", "origin", branch, "--force") -message("🚀 Pushed to origin!") - -message("🎉 All done! main is synced with upstream + dev/ preserved!") From 17155a31220e9711ff055db48894302c2da759db Mon Sep 17 00:00:00 2001 From: Vikram Rawat Date: Thu, 8 Oct 2026 13:03:41 +0000 Subject: [PATCH 4/4] update snapshot --- .../testthat/_snaps/tsflab01apart2/tsflab01apart2of3.rtf | 4 ++-- .../testthat/_snaps/tsflab01apart3/tsflab01apart3of3.rtf | 2 +- tests/testthat/_snaps/tsids02/tsids02.rtf | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) mode change 100644 => 100755 tests/testthat/_snaps/tsflab01apart3/tsflab01apart3of3.rtf diff --git a/tests/testthat/_snaps/tsflab01apart2/tsflab01apart2of3.rtf b/tests/testthat/_snaps/tsflab01apart2/tsflab01apart2of3.rtf index 8048cca8..54861298 100755 --- a/tests/testthat/_snaps/tsflab01apart2/tsflab01apart2of3.rtf +++ b/tests/testthat/_snaps/tsflab01apart2/tsflab01apart2of3.rtf @@ -272,8 +272,8 @@ \clbrdrt\clbrdrl\clbrdrb\clbrdrr\clvertalb\cellx8899 \clbrdrt\clbrdrl\clbrdrb\clbrdrr\clvertalb\cellx12701 \pard\intbl\ql\fs18 \intbl\li267\fi-87 Cycle 03 \cell \pard\intbl\qc\fs18 0/5 \cell -\pard\intbl\qc\fs18 NE (NE, NE) \cell -\pard\intbl\qc\fs18 NE (NE, NE) \cell +\pard\intbl\qc\fs18 NA \cell +\pard\intbl\qc\fs18 NA \cell \row } diff --git a/tests/testthat/_snaps/tsflab01apart3/tsflab01apart3of3.rtf b/tests/testthat/_snaps/tsflab01apart3/tsflab01apart3of3.rtf old mode 100644 new mode 100755 index 9e5be1c5..b30665ee --- a/tests/testthat/_snaps/tsflab01apart3/tsflab01apart3of3.rtf +++ b/tests/testthat/_snaps/tsflab01apart3/tsflab01apart3of3.rtf @@ -365,7 +365,7 @@ \pard\intbl\qc\fs18 4.38 (3.88, 4.88) \cell \pard\intbl\qc\fs18 -0.02 (-0.62, 0.59) \cell \pard\intbl\qc\fs18 -0.20 (-0.81, 0.41) \cell -\pard\intbl\qc\fs18 NE (NE, NE) \cell +\pard\intbl\qc\fs18 NA \cell \row } diff --git a/tests/testthat/_snaps/tsids02/tsids02.rtf b/tests/testthat/_snaps/tsids02/tsids02.rtf index 971f464a..efc120e8 100755 --- a/tests/testthat/_snaps/tsids02/tsids02.rtf +++ b/tests/testthat/_snaps/tsids02/tsids02.rtf @@ -248,8 +248,8 @@ \pard\intbl\qc\fs18 43 (51.2%) \cell \pard\intbl\qc\fs18 22 (25.6%) \cell \pard\intbl\qc\fs18 114 (44.9%) \cell -\pard\intbl\qc\fs18 0.0 (0.0, 0.0) \cell -\pard\intbl\qc\fs18 0.0 (0.0, 0.0) \cell +\pard\intbl\qc\fs18 32.8 (18.7, 46.8) \cell +\pard\intbl\qc\fs18 25.6 (11.5, 39.7) \cell \row } @@ -320,8 +320,8 @@ \pard\intbl\qc\fs18 48 (57.1%) \cell \pard\intbl\qc\fs18 24 (27.9%) \cell \pard\intbl\qc\fs18 116 (45.7%) \cell -\pard\intbl\qc\fs18 0.0 (0.0, 0.0) \cell -\pard\intbl\qc\fs18 0.0 (0.0, 0.0) \cell +\pard\intbl\qc\fs18 24.5 (10.2, 38.8) \cell +\pard\intbl\qc\fs18 29.2 (15.0, 43.4) \cell \row }