mirror of
https://code.forgejo.org/actions/upload-artifact.git
synced 2025-05-18 07:04:45 +00:00
Merge ac7ab52308
into 6027e3dd17
This commit is contained in:
commit
cd93a24ea2
2 changed files with 28 additions and 1 deletions
|
@ -386,6 +386,7 @@ describe('Search', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Hidden files ignored by default', async () => {
|
it('Hidden files ignored by default', async () => {
|
||||||
|
const warningSpy = jest.spyOn(core, 'warning')
|
||||||
const searchPath = path.join(root, '**/*')
|
const searchPath = path.join(root, '**/*')
|
||||||
const searchResult = await findFilesToUpload(searchPath)
|
const searchResult = await findFilesToUpload(searchPath)
|
||||||
|
|
||||||
|
@ -394,14 +395,19 @@ describe('Search', () => {
|
||||||
expect(searchResult.filesToUpload).not.toContain(
|
expect(searchResult.filesToUpload).not.toContain(
|
||||||
fileInHiddenFolderInFolderA
|
fileInHiddenFolderInFolderA
|
||||||
)
|
)
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
expect.stringMatching(/Set include-hidden-files to true to include these files.$/)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Hidden files included', async () => {
|
it('Hidden files included', async () => {
|
||||||
|
const warningSpy = jest.spyOn(core, 'warning')
|
||||||
const searchPath = path.join(root, '**/*')
|
const searchPath = path.join(root, '**/*')
|
||||||
const searchResult = await findFilesToUpload(searchPath, true)
|
const searchResult = await findFilesToUpload(searchPath, true)
|
||||||
|
|
||||||
expect(searchResult.filesToUpload).toContain(hiddenFile)
|
expect(searchResult.filesToUpload).toContain(hiddenFile)
|
||||||
expect(searchResult.filesToUpload).toContain(fileInHiddenFolderPath)
|
expect(searchResult.filesToUpload).toContain(fileInHiddenFolderPath)
|
||||||
expect(searchResult.filesToUpload).toContain(fileInHiddenFolderInFolderA)
|
expect(searchResult.filesToUpload).toContain(fileInHiddenFolderInFolderA)
|
||||||
|
expect(warningSpy).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as glob from '@actions/glob'
|
import * as glob from '@actions/glob'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {debug, info} from '@actions/core'
|
import {debug, info, warning} from '@actions/core'
|
||||||
import {stat} from 'fs'
|
import {stat} from 'fs'
|
||||||
import {dirname} from 'path'
|
import {dirname} from 'path'
|
||||||
import {promisify} from 'util'
|
import {promisify} from 'util'
|
||||||
|
@ -90,6 +90,27 @@ export async function findFilesToUpload(
|
||||||
)
|
)
|
||||||
const rawSearchResults: string[] = await globber.glob()
|
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
|
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
|
Detect any files that could be overwritten for user awareness
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue