From e42dc4075ff263f2e910a36d42fbc024b275f4db Mon Sep 17 00:00:00 2001 From: Shun Kakinoki Date: Mon, 12 Jan 2026 12:11:08 +0000 Subject: [PATCH 1/3] feat(dotfiles-updater): skip build/switch when no changes detected Only run install.sh (make build && make switch) when there are actual git changes from origin/main. This avoids unnecessary rebuilds during the periodic 3hr update cycle. --- .../services/dotfiles-updater/update.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/home-manager/services/dotfiles-updater/update.sh b/home-manager/services/dotfiles-updater/update.sh index d2d4705c4..38042f8e7 100755 --- a/home-manager/services/dotfiles-updater/update.sh +++ b/home-manager/services/dotfiles-updater/update.sh @@ -10,8 +10,24 @@ if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then exit 0 fi -# Fetch and pull latest changes +# Store current commit hash before fetching +CURRENT_COMMIT=$(git rev-parse HEAD) + +# Fetch latest changes git fetch origin main + +# Get the latest remote commit +REMOTE_COMMIT=$(git rev-parse origin/main) + +# Check if there are any changes +if [ "$CURRENT_COMMIT" = "$REMOTE_COMMIT" ]; then + echo "No changes detected (current: ${CURRENT_COMMIT:0:8}). Skipping build and switch." + exit 0 +fi + +echo "Changes detected: ${CURRENT_COMMIT:0:8} -> ${REMOTE_COMMIT:0:8}" + +# Reset to latest git reset --hard origin/main # Run the install script From 7306027d02e37c5d9cd669e1beeea86fd7da7122 Mon Sep 17 00:00:00 2001 From: Shun Kakinoki Date: Mon, 12 Jan 2026 12:12:55 +0000 Subject: [PATCH 2/3] test(dotfiles-updater): add tests for change detection Add ShellSpec tests to verify: - Current commit is stored before fetch - Remote commit is retrieved after fetch - Commits are compared to detect changes - Appropriate messages are logged for both cases --- spec/dotfiles_updater_spec.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spec/dotfiles_updater_spec.sh b/spec/dotfiles_updater_spec.sh index 27353836c..71b7fe0ef 100644 --- a/spec/dotfiles_updater_spec.sh +++ b/spec/dotfiles_updater_spec.sh @@ -50,6 +50,34 @@ The output should include 'git reset --hard origin/main' End End +Describe 'change detection' +It 'stores current commit before fetching' +When run bash -c "grep 'CURRENT_COMMIT=\$(git rev-parse HEAD)' '$SCRIPT'" +The output should include 'CURRENT_COMMIT=$(git rev-parse HEAD)' +End + +It 'gets remote commit after fetching' +When run bash -c "grep 'REMOTE_COMMIT=\$(git rev-parse origin/main)' '$SCRIPT'" +The output should include 'REMOTE_COMMIT=$(git rev-parse origin/main)' +End + +It 'compares commits to detect changes' +When run bash -c "grep 'CURRENT_COMMIT.*=.*REMOTE_COMMIT' '$SCRIPT'" +The output should include 'CURRENT_COMMIT' +The output should include 'REMOTE_COMMIT' +End + +It 'skips build when no changes detected' +When run bash -c "grep 'No changes detected' '$SCRIPT'" +The output should include 'No changes detected' +End + +It 'logs when changes are detected' +When run bash -c "grep 'Changes detected' '$SCRIPT'" +The output should include 'Changes detected' +End +End + Describe 'installation' It 'runs install.sh after update' When run bash -c "grep './install.sh' '$SCRIPT'" From b4dd1d8b1b8585e0a153db207c92a577f8ff89a2 Mon Sep 17 00:00:00 2001 From: Shun Kakinoki Date: Mon, 12 Jan 2026 12:22:43 +0000 Subject: [PATCH 3/3] fix(tests): disable SC2016 for literal string assertions ShellCheck complains about unexpanded expressions in single quotes, but these are intentional literal string matches in test assertions. --- spec/dotfiles_updater_spec.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/dotfiles_updater_spec.sh b/spec/dotfiles_updater_spec.sh index 71b7fe0ef..2f3d6eddc 100644 --- a/spec/dotfiles_updater_spec.sh +++ b/spec/dotfiles_updater_spec.sh @@ -53,11 +53,13 @@ End Describe 'change detection' It 'stores current commit before fetching' When run bash -c "grep 'CURRENT_COMMIT=\$(git rev-parse HEAD)' '$SCRIPT'" +# shellcheck disable=SC2016 The output should include 'CURRENT_COMMIT=$(git rev-parse HEAD)' End It 'gets remote commit after fetching' When run bash -c "grep 'REMOTE_COMMIT=\$(git rev-parse origin/main)' '$SCRIPT'" +# shellcheck disable=SC2016 The output should include 'REMOTE_COMMIT=$(git rev-parse origin/main)' End