forked from continuedev/continue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiffContextProvider.ts
More file actions
36 lines (33 loc) · 897 Bytes
/
DiffContextProvider.ts
File metadata and controls
36 lines (33 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {
ContextItem,
ContextProviderDescription,
ContextProviderExtras,
} from "../../index.js";
import { BaseContextProvider } from "../index.js";
class DiffContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
title: "diff",
displayTitle: "Git Diff",
description: "Reference the current git diff",
type: "normal",
};
async getContextItems(
query: string,
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
const diff = await extras.ide.getDiff(
this.options?.includeUnstaged ?? true,
);
return [
{
description: "The current git diff",
content:
diff.length === 0
? "Git shows no current changes."
: `\`\`\`git diff\n${diff.join("\n")}\n\`\`\``,
name: "Git Diff",
},
];
}
}
export default DiffContextProvider;