@@ -230,6 +230,10 @@ describe('ensureCorrectShaCheckedOut', () => {
230230 execSync ( 'git config user.email [email protected] ' , { cwd :
dir } ) 231231 execSync ( 'git config user.name Mona' , { cwd : dir } )
232232
233+ // Add a file to the repo
234+ fs . writeFileSync ( `${ dir } /file1.txt` , fileContent )
235+ execSync ( 'git add .' , { cwd : dir } )
236+
233237 // Add two commits
234238 execSync ( 'git commit --allow-empty -m "test"' , { cwd : dir } )
235239 execSync ( 'git commit --allow-empty -m "test"' , { cwd : dir } )
@@ -284,4 +288,27 @@ describe('ensureCorrectShaCheckedOut', () => {
284288 fsHelper . ensureTagAndRefCheckedOut ( `refs/heads/main` , commit2 , dir )
285289 ) . rejects . toThrow ( 'Tag ref provided is not in expected format.' )
286290 } )
291+
292+ it ( 'throws if there are untracked files in the working directory' , async ( ) => {
293+ // Add an untracked file
294+ fs . writeFileSync ( `${ dir } /untracked-file.txt` , fileContent )
295+
296+ await expect ( async ( ) =>
297+ fsHelper . ensureTagAndRefCheckedOut ( `refs/tags/${ tag2 } ` , commit2 , dir )
298+ ) . rejects . toThrow (
299+ 'The working directory has uncommitted changes. Uploading modified code from the checked out repository is not supported by this action.'
300+ )
301+ } )
302+
303+ it ( 'throws if there are uncommitted changes in the working directory' , async ( ) => {
304+ // Add an untracked file
305+ fs . writeFileSync ( `${ dir } /file1.txt` , fileContent + fileContent )
306+ execSync ( 'git add .' , { cwd : dir } )
307+
308+ await expect ( async ( ) =>
309+ fsHelper . ensureTagAndRefCheckedOut ( `refs/tags/${ tag2 } ` , commit2 , dir )
310+ ) . rejects . toThrow (
311+ 'The working directory has uncommitted changes. Uploading modified code from the checked out repository is not supported by this action.'
312+ )
313+ } )
287314} )
0 commit comments