blob file read for gitlab (#544)

This commit is contained in:
josc146
2023-10-30 18:11:04 +08:00
parent 4859e9a905
commit f4fdee9150
@@ -18,14 +18,24 @@ const getPatchData = async (patchUrl) => {
export default {
inputQuery: async () => {
try {
const patchUrl = await getPatchUrl()
const patchData = await getPatchData(patchUrl)
if (!patchData) return
if (location.pathname.includes('/blob')) {
const fileData = await limitedFetch(location.href.replace('/blob/', '/raw/'), 1024 * 40)
if (!fileData) return
return await cropText(
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
`The patch contents of this commit are as follows:\n${patchData}`,
)
return await cropText(
`Analyze the following file content and explain it. Use markdown syntax to make your answer more readable, such as code blocks, bold, list:` +
`\n\`\`\`\n${fileData}\n\`\`\``,
)
} else {
const patchUrl = await getPatchUrl()
const patchData = await getPatchData(patchUrl)
if (!patchData) return
return await cropText(
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
`The patch contents of this commit are as follows:\n${patchData}`,
)
}
} catch (e) {
console.log(e)
}