Repository navigation
feat(dotfiles-updater): skip build/switch when no changes detected #558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better robustness and to follow modern bash best practices, it's recommended to use the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This optimization skips the install when commits match, but doesn't account for scenarios where the previous install.sh run may have failed partially. Consider tracking the last successful install commit in a state file (e.g., ~/.dotfiles-updater-last-success) and comparing against that instead of just HEAD. This would ensure a retry if the previous install failed. Prompt for Agent |
||||||||
| echo "No changes detected (current: ${CURRENT_COMMIT:0:8}). Skipping build and switch." | ||||||||
| exit 0 | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Early exit skips Prompt for AI agents
Suggested change
|
||||||||
| fi | ||||||||
|
Comment on lines
+23
to
+26
|
||||||||
|
|
||||||||
| echo "Changes detected: ${CURRENT_COMMIT:0:8} -> ${REMOTE_COMMIT:0:8}" | ||||||||
|
|
||||||||
| # Reset to latest | ||||||||
| git reset --hard origin/main | ||||||||
|
|
||||||||
| # Run the install script | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the git fetch operation. If the fetch fails (network issues, remote unavailable), the script will exit due to
set -e, but REMOTE_COMMIT will never be set. Adding explicit error handling or at least logging would make debugging easier:Agent: 🏛 Architecture •
• 
Prompt for Agent