@@ -109,3 +109,64 @@ teardown() {
109109 marker_age=$( find " $fake_dir /.last-update-check" -mmin +1 2> /dev/null || true)
110110 assert_equal " $marker_age " " "
111111}
112+
113+ # =============================================================================
114+ # Update with untracked files tests
115+ # =============================================================================
116+
117+ @test " setup.sh update handles untracked files without failing" {
118+ setup_isolated_home
119+ local fake_dir=" ${TEST_DIR} /devtools"
120+ local remote_dir=" ${TEST_DIR} /remote.git"
121+
122+ # Create local repo with two commits and tags
123+ mkdir -p " $fake_dir "
124+ cd " $fake_dir "
125+ export GIT_CONFIG_NOSYSTEM=1
126+ export GIT_CONFIG_GLOBAL=" ${HOME} /.gitconfig"
127+ export GIT_EDITOR=true # Prevent editor from opening
128+ git init -q --initial-branch=main
129+ git config user.email " test@example.com"
130+ git config user.name " Test"
131+ echo " initial" > README.md
132+ git add README.md
133+ git commit -q -m " Initial commit"
134+ git tag -a v1.0.0 -m " v1.0.0" # Use annotated tag with message
135+
136+ # Make a new commit and tag v1.0.1
137+ echo " updated" > README.md
138+ git add README.md
139+ git commit -q -m " Update"
140+ git tag -a v1.0.1 -m " v1.0.1"
141+
142+ # Create a bare remote and push everything
143+ git init -q --bare " $remote_dir "
144+ git remote add origin " $remote_dir "
145+ git push --all origin 2> /dev/null
146+ git push --tags origin 2> /dev/null
147+
148+ # Go back to v1.0.0 (simulating outdated install)
149+ git checkout v1.0.0 --quiet
150+
151+ # Create untracked files (simulating user's local experiments)
152+ # These would conflict with checkout if not handled properly
153+ echo " my local test" > untracked-test-file.txt
154+ mkdir -p new-utils
155+ echo " local utility" > new-utils/my-util.sh
156+
157+ # Create old marker to trigger update check
158+ touch " $fake_dir /.last-update-check"
159+ touch -d " 61 minutes ago" " $fake_dir /.last-update-check"
160+
161+ # Run setup in non-interactive mode (CI=true auto-updates)
162+ export CI=true
163+ run " $SCRIPT_DIR /setup.sh" " $remote_dir " " $fake_dir "
164+
165+ assert_success
166+ assert_output --partial " Updated to v1.0.1"
167+
168+ # Verify we're now on v1.0.1
169+ cd " $fake_dir "
170+ run git describe --tags --abbrev=0
171+ assert_output " v1.0.1"
172+ }
0 commit comments