Skip to content

Commit 29a73ca

Browse files
dhasani23David Hasani
andauthored
fix(amazonq): exclude .github dir from upload ZIP (#8165)
## Problem `.github` directory should not be uploaded to QCT backend, since it contains unrelated files, which can show up in the diff, and can cause the parsing of the patch file to fail. ## Solution Exclude it when zipping. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. Co-authored-by: David Hasani <[email protected]>
1 parent 1c7792d commit 29a73ca

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ function isExcludedSourceFile(path: string): boolean {
275275
return sourceExcludedExtensions.some((extension) => path.endsWith(extension))
276276
}
277277

278-
// zip all dependency files and all source files excluding "target" (contains large JARs) plus ".git" and ".idea" (may appear in diff.patch)
278+
// zip all dependency files and all source files
279+
// excludes "target" (contains large JARs) plus ".git", ".idea", and ".github" (may appear in diff.patch)
279280
export function getFilesRecursively(dir: string, isDependenciesFolder: boolean): string[] {
280281
const entries = nodefs.readdirSync(dir, { withFileTypes: true })
281282
const files = entries.flatMap((entry) => {
@@ -284,7 +285,12 @@ export function getFilesRecursively(dir: string, isDependenciesFolder: boolean):
284285
if (isDependenciesFolder) {
285286
// include all dependency files
286287
return getFilesRecursively(res, isDependenciesFolder)
287-
} else if (entry.name !== 'target' && entry.name !== '.git' && entry.name !== '.idea') {
288+
} else if (
289+
entry.name !== 'target' &&
290+
entry.name !== '.git' &&
291+
entry.name !== '.idea' &&
292+
entry.name !== '.github'
293+
) {
288294
// exclude the above directories when zipping source code
289295
return getFilesRecursively(res, isDependenciesFolder)
290296
} else {

packages/core/src/test/codewhisperer/commands/transformByQ.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,10 @@ dependencyManagement:
503503
await fs.mkdir(gitFolder)
504504
await fs.writeFile(path.join(gitFolder, 'config'), 'sample content for the test file')
505505

506+
const githubFolder = path.join(tempDir, '.github')
507+
await fs.mkdir(githubFolder)
508+
await fs.writeFile(path.join(githubFolder, 'config'), 'more sample content for the test file')
509+
506510
const zippedFiles = getFilesRecursively(tempDir, false)
507511
assert.strictEqual(zippedFiles.length, 1)
508512
})

0 commit comments

Comments
 (0)