diff --git a/flake.nix b/flake.nix index 43e5a7e..ea888d2 100644 --- a/flake.nix +++ b/flake.nix @@ -45,10 +45,28 @@ if [ ! -d "$module_path" ]; then echo "Adding worktree for $branch in $module_path" git worktree add "$module_path" "$branch" 2>/dev/null - # else - # echo "Worktree for $branch already exists" + else + cd "$module_path" + git fetch origin "$branch" >/dev/null 2>&1 + if ! git diff --quiet HEAD "origin/$branch"; then + echo "Updates available for $branch in $module_path" + fi + cd - >/dev/null fi done + + # Check for and remove orphaned module directories + if [ -d "modules" ]; then + for dir in modules/*; do + if [ -d "$dir" ]; then + module_name="$(basename "$dir")" + if ! echo "$branches" | grep -q "^mod_$module_name$"; then + echo "Removing orphaned module directory: $dir" + git worktree remove --force "$dir" + fi + fi + done + fi ''; mod_status = pkgs.writeShellScriptBin "mod_status" '' cwd=$(pwd) diff --git a/hosts/lio/flake.lock b/hosts/lio/flake.lock index 9c21650..5022ec8 100644 --- a/hosts/lio/flake.lock +++ b/hosts/lio/flake.lock @@ -1364,11 +1364,11 @@ "rust-overlay": "rust-overlay_3" }, "locked": { - "lastModified": 1737571139, - "narHash": "sha256-e5nK+KmfS+bYmKo4g3zC8lsEND0nYoBmn+qocmVM50o=", + "lastModified": 1737610236, + "narHash": "sha256-UfC+hBu09KEepjnqbXGqRJ0jTlV8HTuD1GjB+ZjTjYM=", "ref": "refs/heads/master", - "rev": "a6a34c6eddafe0d838465232c17e0893e909edd0", - "revCount": 259, + "rev": "631d85a771f3e22822b9ac02d895e2a06aa1e183", + "revCount": 260, "type": "git", "url": "https://git.joshuabell.xyz/nvim" },