mirror of
				https://github.com/actions/upload-artifact.git
				synced 2025-10-31 15:53:44 +00:00 
			
		
		
		
	Warn excluded hidden files
This commit is contained in:
		
							parent
							
								
									6027e3dd17
								
							
						
					
					
						commit
						ac7ab52308
					
				| @ -386,6 +386,7 @@ describe('Search', () => { | ||||
|   }) | ||||
| 
 | ||||
|   it('Hidden files ignored by default', async () => { | ||||
|     const warningSpy = jest.spyOn(core, 'warning') | ||||
|     const searchPath = path.join(root, '**/*') | ||||
|     const searchResult = await findFilesToUpload(searchPath) | ||||
| 
 | ||||
| @ -394,14 +395,19 @@ describe('Search', () => { | ||||
|     expect(searchResult.filesToUpload).not.toContain( | ||||
|       fileInHiddenFolderInFolderA | ||||
|     ) | ||||
|     expect(warningSpy).toHaveBeenCalledWith( | ||||
|       expect.stringMatching(/Set include-hidden-files to true to include these files.$/) | ||||
|     ) | ||||
|   }) | ||||
| 
 | ||||
|   it('Hidden files included', async () => { | ||||
|     const warningSpy = jest.spyOn(core, 'warning') | ||||
|     const searchPath = path.join(root, '**/*') | ||||
|     const searchResult = await findFilesToUpload(searchPath, true) | ||||
| 
 | ||||
|     expect(searchResult.filesToUpload).toContain(hiddenFile) | ||||
|     expect(searchResult.filesToUpload).toContain(fileInHiddenFolderPath) | ||||
|     expect(searchResult.filesToUpload).toContain(fileInHiddenFolderInFolderA) | ||||
|     expect(warningSpy).not.toHaveBeenCalled() | ||||
|   }) | ||||
| }) | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| import * as glob from '@actions/glob' | ||||
| import * as path from 'path' | ||||
| import {debug, info} from '@actions/core' | ||||
| import {debug, info, warning} from '@actions/core' | ||||
| import {stat} from 'fs' | ||||
| import {dirname} from 'path' | ||||
| import {promisify} from 'util' | ||||
| @ -90,6 +90,27 @@ export async function findFilesToUpload( | ||||
|   ) | ||||
|   const rawSearchResults: string[] = await globber.glob() | ||||
| 
 | ||||
|   /* | ||||
|     Check for hidden files by comparing results with includeHiddenFiles=true | ||||
|   */ | ||||
|   if (!includeHiddenFiles) { | ||||
|     const globberWithHidden = await glob.create( | ||||
|       searchPath, | ||||
|       getDefaultGlobOptions(true) | ||||
|     ) | ||||
|     const rawSearchResultsWithHidden = await globberWithHidden.glob() | ||||
| 
 | ||||
|     const hiddenFiles = rawSearchResultsWithHidden.filter( | ||||
|       file => !rawSearchResults.includes(file) | ||||
|     ) | ||||
| 
 | ||||
|     if (hiddenFiles.length > 0) { | ||||
|       warning( | ||||
|         `The path "${searchPath}" excluded ${hiddenFiles.length} hidden files. Set include-hidden-files to true to include these files.` | ||||
|       ) | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
|     Files are saved with case insensitivity. Uploading both a.txt and A.txt will files to be overwritten | ||||
|     Detect any files that could be overwritten for user awareness | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user