Skip to content

Commit f4fdee9

Browse files
committed
blob file read for gitlab (#544)
1 parent 4859e9a commit f4fdee9

File tree

1 file changed

+17
-7
lines changed
  • src/content-script/site-adapters/gitlab

1 file changed

+17
-7
lines changed

src/content-script/site-adapters/gitlab/index.mjs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,24 @@ const getPatchData = async (patchUrl) => {
1818
export default {
1919
inputQuery: async () => {
2020
try {
21-
const patchUrl = await getPatchUrl()
22-
const patchData = await getPatchData(patchUrl)
23-
if (!patchData) return
21+
if (location.pathname.includes('/blob')) {
22+
const fileData = await limitedFetch(location.href.replace('/blob/', '/raw/'), 1024 * 40)
23+
if (!fileData) return
2424

25-
return await cropText(
26-
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
27-
`The patch contents of this commit are as follows:\n${patchData}`,
28-
)
25+
return await cropText(
26+
`Analyze the following file content and explain it. Use markdown syntax to make your answer more readable, such as code blocks, bold, list:` +
27+
`\n\`\`\`\n${fileData}\n\`\`\``,
28+
)
29+
} else {
30+
const patchUrl = await getPatchUrl()
31+
const patchData = await getPatchData(patchUrl)
32+
if (!patchData) return
33+
34+
return await cropText(
35+
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
36+
`The patch contents of this commit are as follows:\n${patchData}`,
37+
)
38+
}
2939
} catch (e) {
3040
console.log(e)
3141
}

0 commit comments

Comments
 (0)