@@ -41,37 +41,58 @@ public async Task LookupVersionLabelWithWorkingDirectoryChanges()
4141 await TestUtilities . RunGitCommand ( tempPath , "tag v1.2.3" ) ;
4242
4343 // Test 1: Clean working directory - should return tagged version
44+ Hash root ;
4445 using ( var repository = await Repository . Factory . OpenStructureAsync ( tempPath ) )
4546 {
46- var version = await Analyzer . LookupVersionLabelAsync ( repository , false , default ) ;
47+ root = repository . Head ! . Head ;
48+
49+ var version = await Analyzer . LookupVersionLabelAsync ( repository , true , default ) ;
4750 Assert . That ( version . ToString ( ) , Is . EqualTo ( "1.2.3" ) ) ;
4851 }
4952
5053 // Test 2: Modified file (unstaged) - should increment version
5154 File . WriteAllText ( testFile , "modified content" ) ;
5255 using ( var repository = await Repository . Factory . OpenStructureAsync ( tempPath ) )
5356 {
54- var version = await Analyzer . LookupVersionLabelAsync ( repository , false , default ) ;
57+ var version = await Analyzer . LookupVersionLabelAsync ( repository , true , default ) ;
5558 Assert . That ( version . ToString ( ) , Is . EqualTo ( "1.2.4" ) ) ;
5659 }
5760
5861 // Test 3: Staged file - should increment version
5962 await TestUtilities . RunGitCommand ( tempPath , "add test.txt" ) ;
6063 using ( var repository = await Repository . Factory . OpenStructureAsync ( tempPath ) )
6164 {
62- var version = await Analyzer . LookupVersionLabelAsync ( repository , false , default ) ;
65+ var version = await Analyzer . LookupVersionLabelAsync ( repository , true , default ) ;
6366 Assert . That ( version . ToString ( ) , Is . EqualTo ( "1.2.4" ) ) ;
6467 }
6568
66- // Test 4: Clean up staged file and test untracked file (should not increment)
67- await TestUtilities . RunGitCommand ( tempPath , "reset HEAD test.txt" ) ;
68- await TestUtilities . RunGitCommand ( tempPath , "checkout -- test.txt" ) ;
69+ // Test 4: Commit staged file and test untracked file
70+ await TestUtilities . RunGitCommand ( tempPath , "commit -m \" Test\" " ) ;
71+ using ( var repository = await Repository . Factory . OpenStructureAsync ( tempPath ) )
72+ {
73+ var version = await Analyzer . LookupVersionLabelAsync ( repository , true , default ) ;
74+ Assert . That ( version . ToString ( ) , Is . EqualTo ( "1.2.4" ) ) ;
75+ }
6976 var untrackedFile = Path . Combine ( tempPath , "untracked.txt" ) ;
7077 File . WriteAllText ( untrackedFile , "untracked content" ) ;
7178 using ( var repository = await Repository . Factory . OpenStructureAsync ( tempPath ) )
7279 {
73- var version = await Analyzer . LookupVersionLabelAsync ( repository , false , default ) ;
74- Assert . That ( version . ToString ( ) , Is . EqualTo ( "1.2.3" ) ) ; // Should not increment for untracked files
80+ var version = await Analyzer . LookupVersionLabelAsync ( repository , true , default ) ;
81+ Assert . That ( version . ToString ( ) , Is . EqualTo ( "1.2.5" ) ) ;
82+ }
83+
84+ // Test 5: Reset
85+ await TestUtilities . RunGitCommand ( tempPath , $ "reset --hard { root } ") ;
86+ using ( var repository = await Repository . Factory . OpenStructureAsync ( tempPath ) )
87+ {
88+ var version = await Analyzer . LookupVersionLabelAsync ( repository , true , default ) ;
89+ Assert . That ( version . ToString ( ) , Is . EqualTo ( "1.2.4" ) ) ;
90+ }
91+ await TestUtilities . RunGitCommand ( tempPath , $ "clean -xfd") ; // Remove `untracked.txt`
92+ using ( var repository = await Repository . Factory . OpenStructureAsync ( tempPath ) )
93+ {
94+ var version = await Analyzer . LookupVersionLabelAsync ( repository , true , default ) ;
95+ Assert . That ( version . ToString ( ) , Is . EqualTo ( "1.2.3" ) ) ;
7596 }
7697 }
7798 finally
0 commit comments