Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/fm-fleet-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,18 @@ report_stuck() {
}

sync_project() {
local git_root project_root
PROJ=$1
label=$(project_label)

if [ ! -d "$PROJ" ]; then
echo "$label: skipped: not a directory"
return 0
fi
if ! git -C "$PROJ" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
git_root=$(git -C "$PROJ" rev-parse --show-toplevel 2>/dev/null) || git_root=
project_root=$(cd "$PROJ" && pwd -P) || project_root=
if [ -z "$git_root" ] || [ -z "$project_root" ] \
|| [ "$(cd "$git_root" 2>/dev/null && pwd -P)" != "$project_root" ]; then
echo "$label: skipped: not a git repo"
return 0
fi
Expand Down
25 changes: 25 additions & 0 deletions tests/fm-fleet-sync.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,30 @@ test_whole_fleet_form() {
pass "whole-fleet form processes every clone under projects/"
}

test_non_repo_directory_inside_enclosing_repo_skipped() {
local home remote orphan out
home=$(new_home)
remote="$TMP_ROOT/enclosing-$HOME_N.git"
orphan="$home/projects/fake-gnhf-worktrees"

git init -q "$home"
git -C "$home" symbolic-ref HEAD refs/heads/main
commit_file "$home" root.txt v0 C0
git clone --quiet --bare "$home" "$remote"
git -C "$home" remote add origin "file://$remote"
git -C "$home" fetch -q origin
git -C "$home" checkout -q -b feature
mkdir -p "$orphan/sub"

out=$(run_sync "$home" "$orphan")

assert_contains "$out" "fake-gnhf-worktrees: skipped: not a git repo" \
"non-repo container nested inside an enclosing repository is skipped"
assert_not_contains "$out" "STUCK" "non-repo container is not flagged STUCK"
assert_not_contains "$out" "diverged" "non-repo container is not reported as diverged"
pass "non-repo container inside an enclosing repository is skipped cleanly"
}

test_bootstrap_relays_recovered_and_stuck() {
local home stuck rec out
home=$(new_home)
Expand Down Expand Up @@ -619,6 +643,7 @@ test_single_project_by_projects_relative_name_resolves
test_single_project_by_projects_relative_name_ignores_cwd_shadow
test_single_project_unresolvable_name_still_skips
test_whole_fleet_form
test_non_repo_directory_inside_enclosing_repo_skipped
test_bootstrap_relays_recovered_and_stuck
test_orphaned_stale_packed_refs_lock_recovers
test_live_packed_refs_lock_is_never_removed
Expand Down