Skip to content

Commit 27e757b

Browse files
Merge master into feature/amazonqLSP
2 parents c47782a + dd1d8e1 commit 27e757b

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

.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
})

0 commit comments

Comments
 (0)