Skip to content

Commit

Permalink
fix: status check logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Jan 10, 2025
1 parent 19526dd commit ac32997
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## v1.3.1 (2025-01-10)

- Makes various changes to how Dotfiles are sourced providing a vastly improved experience, ensuring that Dotfiles are fetched on every shell but without requiring the user to wait for that lengthy process
- Use `git fetch` instead of `git remote update` to cut down on checked branches
- Only recurse through submodules if changed, on-demand
- Removed the temp dots timestamp file and concept added in v1.2.1 which was prone to failure due to VS Code ([closes #9](https://github.com/Justintime50/dots/issues/9))
- Run `git fetch` in a suppressed subshell, allowing for shells to startup fast without waiting for that process to finalize. This ensures that every subsequent shell will show the dotfiles status if it differs

## v1.3.0 (2025-01-03)

- Adds `dots_diff` as a command to see what dotfiles have changed
Expand Down
25 changes: 6 additions & 19 deletions src/dots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DOTFILES_DIR="$HOME/.dotfiles" # Cannot be `~/.dots` as we will use this for int
DOTS_CONFIG_FILE="$DOTFILES_DIR/dots-config.sh"

# Dots required variables (DO NOT EDIT)
DOTS_VERSION="v1.3.0"
DOTS_VERSION="v1.3.1"
HOSTNAME="$(hostname)" # Required for macOS as it's not set automatically like it is on Linux
DOTS_HOME_DIR="$HOME/.dots"
DOTS_DIR="$DOTFILES_DIR/dots/src"
Expand Down Expand Up @@ -47,17 +47,6 @@ _dots_check_shell_config_file() {
fi
}

# Ensures we only check the status of the dotfiles if they haven't been checked on this boot or once every 72 hours
_dots_check_status() {
_dots_check_status_filepath="/tmp/dots_check_status"

if [ ! -f "$_dots_check_status_filepath" ] || [ "$(find "$_dots_check_status_filepath" -mmin +$((72 * 60)) 2>/dev/null | wc -l)" -gt 0 ]; then
touch $_dots_check_status_filepath
else
return 1
fi
}

### HELPERS ###

# Checks that dotfiles are up to date each time a terminal starts
Expand Down Expand Up @@ -89,11 +78,9 @@ _dots_init_message() {
echo "Shell: $SHELL"
echo "Hostname: $HOSTNAME" # We print Hostname here to assist with multi-machine Dotfile management
if [ -z "$DOTS_DISABLE_DOTFILES_STATUS" ]; then
if _dots_check_status; then
echo ""
echo "Dotfiles status:"
_dots_get_dotfiles_status
fi
echo ""
echo "Dotfiles status:"
_dots_get_dotfiles_status
fi
echo "#############################################"
}
Expand Down Expand Up @@ -179,8 +166,8 @@ dots_clean() {

# Gets the status of dotfiles
dots_status() {
git -C "$DOTFILES_DIR" remote update >/dev/null 2>&1 || echo "Error updating from remote Dotfiles"
git -C "$DOTFILES_DIR" status -s -b || echo "Couldn't check remote Dotfiles"
(git -C "$DOTFILES_DIR" fetch --recurse-submodules=on-demand >/dev/null 2>&1 &)
git -C "$DOTFILES_DIR" status -sb || echo "Couldn't check remote Dotfiles"
}

# Gets the diff of dotfiles
Expand Down

0 comments on commit ac32997

Please sign in to comment.