Skip to content

Commit b080e88

Browse files
authored
Merge pull request #189 from actions/jcambass/2024-09-03/only-exclude-git-folder
Only Exclude .git Folder
2 parents 49e9053 + 8753087 commit b080e88

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

__tests__/fs-helper.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('stageActionFiles', () => {
3030
)
3131
})
3232

33-
it('copies all non-hidden files to the staging directory', () => {
33+
it('copies all files (excluding the .git folder) to the staging directory', () => {
3434
fs.writeFileSync(`${sourceDir}/action.yml`, fileContent)
3535

3636
fs.mkdirSync(`${sourceDir}/.git`)
@@ -44,12 +44,14 @@ describe('stageActionFiles', () => {
4444
expect(fs.existsSync(`${stagingDir}/src/main.js`)).toBe(true)
4545
expect(fs.existsSync(`${stagingDir}/src/other.js`)).toBe(true)
4646

47-
// Hidden files should not be copied
47+
// Hidden files are copied
48+
expect(fs.existsSync(`${stagingDir}/.github`)).toBe(true)
49+
50+
// .git folder is not copied
4851
expect(fs.existsSync(`${stagingDir}/.git`)).toBe(false)
49-
expect(fs.existsSync(`${stagingDir}/.github`)).toBe(false)
5052
})
5153

52-
it('copies all non-hidden files to the staging directory, even if action.yml is in a subdirectory', () => {
54+
it('copies all files (excluding the .git folder) to the staging directory, even if action.yml is in a subdirectory', () => {
5355
fs.mkdirSync(`${sourceDir}/my-sub-action`, { recursive: true })
5456
fs.writeFileSync(`${sourceDir}/my-sub-action/action.yml`, fileContent)
5557

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/fs-helper.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function readFileContents(filePath: string): Buffer {
9090
return fs.readFileSync(filePath)
9191
}
9292

93-
// Copy actions files from sourceDir to targetDir, excluding files and folders not relevant to the action
93+
// Copy actions files from sourceDir to targetDir, excluding the .git folder.
9494
// Errors if the repo appears to not contain any action files, such as an action.yml file
9595
export function stageActionFiles(actionDir: string, targetDir: string): void {
9696
let actionYmlFound = false
@@ -103,8 +103,12 @@ export function stageActionFiles(actionDir: string, targetDir: string): void {
103103
actionYmlFound = true
104104
}
105105

106-
// Filter out hidden folers like .git and .github
107-
return basename === '.' || !basename.startsWith('.')
106+
// Filter out the .git folder.
107+
if (basename === '.git') {
108+
return false
109+
}
110+
111+
return true
108112
}
109113
})
110114

0 commit comments

Comments
 (0)