diff --git a/CHANGELOG.md b/CHANGELOG.md index 218bcb65..090a9991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release ### Security ### Added - fetch: added --switch-to-main flag to switch to the default branch and rebase it when not on it, skipping if there are uncommitted changes +- git/ignore-changelog: script to add CHANGELOG.md to .markdownlintignore across git repositories +- git/reset-all: script to run git reset --hard HEAD across all git repositories +- git/push-all: script to push all git repositories ### Fixed - Shell scripts were cleaned up to pass pre-commit checks, and git/fetch now uses consistent info/success output. - Replace raw echo output with standard die/success/info helpers in network/wg-create @@ -42,6 +45,7 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release - git/fetch: Unset core.hookspath for each repo during fetch so that globally-configured hook paths do not persist on individual repos - check: use mapfile array for file collection to handle filenames containing spaces correctly - check: guard against empty file list before checking — prevents false-positive success when no scripts are found +- git/ignore-changelog: skip push hooks when pushing to target repositories ### Changed - Replace raw echo with standard output helpers (die/info/success) in github/cancel-workflows - Replace raw echo with standard output helpers (die/info/success) in git/update-repos-personal diff --git a/git/ignore-changelog b/git/ignore-changelog new file mode 100755 index 00000000..f1852d6a --- /dev/null +++ b/git/ignore-changelog @@ -0,0 +1,70 @@ +#! /bin/sh + +die() { + printf '\n\033[31m✗\033[0m %s\n' "$*" >&2 + exit 1 +} + +success() { + printf '\n\033[32m✓\033[0m %s\n' "$*" +} + +info() { + printf '\n\033[32m→\033[0m %s\n' "$*" +} + +warn() { + printf '\n\033[33m!\033[0m %s\n' "$*" +} + +IGNORE_FILE=".markdownlintignore" +ENTRY="CHANGELOG.md" +COMMIT_MSG="Add CHANGELOG.md to .markdownlintignore" +DRY_RUN=0 + +for arg in "$@"; do + case "$arg" in + -n|--dry-run) DRY_RUN=1 ;; + *) die "Unknown argument: $arg" ;; + esac +done + +[ "$DRY_RUN" -eq 1 ] && info "Dry run — no files will be written or committed" + +for dir in "$(pwd)"/*/; do + [ -e "${dir}.git" ] || continue + + info "$dir" + + if [ ! -f "${dir}${IGNORE_FILE}" ]; then + if [ "$DRY_RUN" -eq 1 ]; then + info "Would create ${IGNORE_FILE} with ${ENTRY}" + else + printf '%s\n' "$ENTRY" > "${dir}${IGNORE_FILE}" + info "Created ${IGNORE_FILE}" + fi + elif grep -qx "$ENTRY" "${dir}${IGNORE_FILE}"; then + success "Already excludes ${ENTRY} — skipping" + continue + else + if [ "$DRY_RUN" -eq 1 ]; then + info "Would append ${ENTRY} to existing ${IGNORE_FILE}" + else + printf '\n%s\n' "$ENTRY" >> "${dir}${IGNORE_FILE}" + info "Appended ${ENTRY} to ${IGNORE_FILE}" + fi + fi + + if [ "$DRY_RUN" -eq 1 ]; then + info "Would commit and push: ${COMMIT_MSG}" + continue + fi + + git -C "$dir" add "$IGNORE_FILE" || { warn "git add failed in $dir"; continue; } + git -C "$dir" commit -m "$COMMIT_MSG" -n || { warn "git commit failed in $dir"; continue; } + if git -C "$dir" push --no-verify; then + success "Pushed $dir" + else + warn "git push failed in $dir (committed locally)" + fi +done diff --git a/git/push-all b/git/push-all new file mode 100755 index 00000000..b0e274e2 --- /dev/null +++ b/git/push-all @@ -0,0 +1,24 @@ +#! /bin/sh + +die() { + printf '\n\033[31m✗\033[0m %s\n' "$*" >&2 + exit 1 +} + +success() { + printf '\n\033[32m✓\033[0m %s\n' "$*" +} + +info() { + printf '\n\033[32m→\033[0m %s\n' "$*" +} + +find "$(pwd)"/* -name '*.git' -print | sed "s|/.git$||" | sort -u | grep -v .cache | while IFS= read -r line +do + info "$line" + CURRENT_DIR=$line + + git -C "$CURRENT_DIR" push --no-verify 2>&1 + + success "Done." +done diff --git a/git/reset-all b/git/reset-all new file mode 100755 index 00000000..a1c83d58 --- /dev/null +++ b/git/reset-all @@ -0,0 +1,24 @@ +#! /bin/sh + +die() { + printf '\n\033[31m✗\033[0m %s\n' "$*" >&2 + exit 1 +} + +success() { + printf '\n\033[32m✓\033[0m %s\n' "$*" +} + +info() { + printf '\n\033[32m→\033[0m %s\n' "$*" +} + +find "$(pwd)"/* -name '*.git' -print | sed "s|/.git$||" | sort -u | grep -v .cache | while IFS= read -r line +do + info "$line" + CURRENT_DIR=$line + + git -C "$CURRENT_DIR" reset --hard HEAD 2>&1 + + success "Done." +done