Skip to content

Commit 2e94873

Browse files
committed
merge in upstream changes
2 parents db973f5 + 0d7ea7d commit 2e94873

File tree

9 files changed

+71
-11
lines changed

9 files changed

+71
-11
lines changed

.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ module.exports = {
206206
message:
207207
'Avoid child_process, use ChildProcess from `shared/utilities/processUtils.ts` instead.',
208208
},
209+
{
210+
name: '..',
211+
message:
212+
'Avoid importing from index.ts files as it can lead to circular dependencies. Import from the module directly instead.',
213+
},
209214
],
210215
},
211216
],

.github/workflows/filterDuplicates.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* the program exits with an error and logs the filtered report to console.
55
*
66
* Usage:
7-
* node filterDuplicates.js run [path_to_git_diff] [path_to_jscpd_report]
7+
* node filterDuplicates.js run [path_to_git_diff] [path_to_jscpd_report] [commit_hash] [repo_name]
88
*
99
* Tests:
1010
* node filterDuplicates.js test
@@ -84,25 +84,40 @@ function filterDuplicates(report, changes) {
8484
return duplicates
8585
}
8686

87+
function formatDuplicates(duplicates, commitHash, repoName) {
88+
const baseUrl = `https://github.com/${repoName}`
89+
return duplicates.map((dupe) => {
90+
return {
91+
first: formUrl(dupe.firstFile, commitHash),
92+
second: formUrl(dupe.secondFile, commitHash),
93+
numberOfLines: dupe.lines,
94+
}
95+
})
96+
function formUrl(file, commitHash) {
97+
return `${baseUrl}/blob/${commitHash}/${file.name}#L${file.start}-L${file.end}`
98+
}
99+
}
100+
87101
async function run() {
88102
const rawDiffPath = process.argv[3]
89103
const jscpdReportPath = process.argv[4]
104+
const commitHash = process.argv[5]
105+
const repoName = process.argv[6]
90106
const changes = await parseDiff(rawDiffPath)
91107
const jscpdReport = JSON.parse(await fs.readFile(jscpdReportPath, 'utf8'))
92108
const filteredDuplicates = filterDuplicates(jscpdReport, changes)
93109

94110
console.log('%s files changes', changes.size)
95111
console.log('%s duplicates found', filteredDuplicates.length)
96112
if (filteredDuplicates.length > 0) {
97-
console.log(filteredDuplicates)
113+
console.log(formatDuplicates(filteredDuplicates, commitHash, repoName))
98114
process.exit(1)
99115
}
100116
}
101117

102118
/**
103119
* Mini-test Suite
104120
*/
105-
console.log(__dirname)
106121
const testDiffFile = path.resolve(__dirname, 'test/test_diff.txt')
107122
let testCounter = 0
108123
function assertEqual(actual, expected) {

.github/workflows/node.js.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ jobs:
101101
path: ./jscpd-report.json
102102

103103
- name: Check for Duplicates
104-
run: node "$GITHUB_WORKSPACE/.github/workflows/filterDuplicates.js" run diff_output.txt jscpd-report.json
104+
env:
105+
COMMIT_HASH: ${{ github.sha}}
106+
REPO_NAME: ${{ github.repository }}
107+
run: node "$GITHUB_WORKSPACE/.github/workflows/filterDuplicates.js" run diff_output.txt jscpd-report.json $COMMIT_HASH $REPO_NAME
105108

106109
macos:
107110
needs: lint-commits

packages/amazonq/test/e2e/amazonq/doc.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,43 @@ describe('Amazon Q Doc', async function () {
108108
FollowUpTypes.MakeChanges,
109109
FollowUpTypes.RejectChanges,
110110
])
111+
112+
tab.clickButton(FollowUpTypes.AcceptChanges)
113+
114+
await tab.waitForButtons([FollowUpTypes.NewTask, FollowUpTypes.CloseSession])
115+
})
116+
})
117+
118+
describe('Edits a README', () => {
119+
beforeEach(async function () {
120+
tab.addChatMessage({ command: '/doc' })
121+
await tab.waitForChatFinishesLoading()
122+
})
123+
124+
it('Make specific change in README', async () => {
125+
await tab.waitForButtons([FollowUpTypes.UpdateDocumentation])
126+
127+
tab.clickButton(FollowUpTypes.UpdateDocumentation)
128+
129+
await tab.waitForButtons([FollowUpTypes.SynchronizeDocumentation, FollowUpTypes.EditDocumentation])
130+
131+
tab.clickButton(FollowUpTypes.EditDocumentation)
132+
133+
await tab.waitForButtons([FollowUpTypes.ProceedFolderSelection])
134+
135+
tab.clickButton(FollowUpTypes.ProceedFolderSelection)
136+
137+
tab.addChatMessage({ prompt: 'remove the repository structure section' })
138+
139+
await tab.waitForText(
140+
`${i18n('AWS.amazonq.doc.answer.readmeUpdated')} ${i18n('AWS.amazonq.doc.answer.codeResult')}`
141+
)
142+
143+
await tab.waitForButtons([
144+
FollowUpTypes.AcceptChanges,
145+
FollowUpTypes.MakeChanges,
146+
FollowUpTypes.RejectChanges,
147+
])
111148
})
112149
})
113150
})

packages/core/src/codewhisperer/commands/startTestGeneration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
throwIfCancelled,
1616
} from '../service/testGenHandler'
1717
import path from 'path'
18-
import { testGenState } from '..'
18+
import { testGenState } from '../models/model'
1919
import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
2020
import { ChildProcess, spawn } from 'child_process' // eslint-disable-line no-restricted-imports
2121
import { BuildStatus } from '../../amazonqTest/chat/session/session'

packages/core/src/codewhisperer/service/testGenHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import CodeWhispererUserClient, {
1616
import { CreateUploadUrlError, InvalidSourceZipError, TestGenFailedError, TestGenTimedOutError } from '../models/errors'
1717
import { getMd5, uploadArtifactToS3 } from './securityScanHandler'
1818
import { fs, randomUUID, sleep, tempDirPath } from '../../shared'
19-
import { ShortAnswer, TestGenerationJobStatus, testGenState } from '..'
19+
import { ShortAnswer, testGenState } from '../models/model'
2020
import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
2121
import { createCodeWhispererChatStreamingClient } from '../../shared/clients/codewhispererChatClient'
2222
import { downloadExportResultArchive } from '../../shared/utilities/download'
@@ -182,9 +182,9 @@ export async function pollTestJobStatus(
182182
}
183183
ChatSessionManager.Instance.getSession().shortAnswer = shortAnswer
184184
}
185-
if (resp.testGenerationJob?.status !== TestGenerationJobStatus.IN_PROGRESS) {
185+
if (resp.testGenerationJob?.status !== CodeWhispererConstants.TestGenerationJobStatus.IN_PROGRESS) {
186186
// This can be FAILED or COMPLETED
187-
status = resp.testGenerationJob?.status as TestGenerationJobStatus
187+
status = resp.testGenerationJob?.status as CodeWhispererConstants.TestGenerationJobStatus
188188
logger.verbose(`testgen job status: ${status}`)
189189
logger.verbose(`Complete polling test job status.`)
190190
break

packages/core/src/shared/env/resolveEnv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import * as crypto from 'crypto'
1212
import { DevSettings } from '../settings'
13-
import { getLogger } from '..'
13+
import { getLogger } from '../logger/logger'
1414
import { ToolkitError } from '../errors'
1515
import { userInfo } from 'os'
1616
import path from 'path'

packages/core/src/shared/utilities/downloadPatterns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import AdmZip from 'adm-zip'
88
import { getLogger } from '../logger/logger'
99
import * as vscode from 'vscode'
1010
import * as path from 'path'
11-
import { ToolkitError } from '..'
11+
import { ToolkitError } from '../errors'
1212

1313
// Get pattern code and save it in temporary folder
1414
async function fetchUrl(owner: string, repoName: string, assetName: string): Promise<Buffer> {

packages/core/src/shared/utilities/pollingSet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import globals from '../extensionGlobals'
6+
import globals from '../../shared/extensionGlobals'
77

88
/**
99
* A useful abstraction that does the following:

0 commit comments

Comments
 (0)