Repository navigation
Expand file tree
/
Copy pathindex.ts
More file actions
43 lines (38 loc) · 1.47 KB
/
Copy pathindex.ts
File metadata and controls
43 lines (38 loc) · 1.47 KB
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
37
38
39
40
41
42
43
/**
* @file Source Control Changed Files
* @author netcon
*/
import * as vscode from 'vscode';
import * as adapterTypes from '@/adapters/types';
import { supportsCommitFeatures } from '@/adapters';
import { getExtensionContext } from '@/helpers/context';
import { GitHub1sQuickDiffProvider } from './quick-diff';
import { getChangedFileDiffCommand, getChangedFiles } from './files';
import { GitHub1sHistoryProvider } from './history';
const sourceControl = vscode.scm.createSourceControl('github1s', 'GitHub1s');
const changesGroup = sourceControl.createResourceGroup('changes', 'Changes');
sourceControl.quickDiffProvider = new GitHub1sQuickDiffProvider();
export const registerSourceControlHistory = async () => {
const context = getExtensionContext();
context.subscriptions.push(sourceControl);
if (!(await supportsCommitFeatures())) {
return;
}
const historyProvider = GitHub1sHistoryProvider.getInstance();
sourceControl.historyProvider = historyProvider;
context.subscriptions.push(historyProvider);
historyProvider.refresh();
};
export const updateSourceControlChanges = async () => {
const changedFiles = await getChangedFiles();
changesGroup.resourceStates = changedFiles.map((changedFile) => {
return {
resourceUri: changedFile.headFileUri.with({ authority: '' }),
decorations: {
strikeThrough: changedFile.status === adapterTypes.FileChangeStatus.Removed,
tooltip: changedFile.status,
},
command: getChangedFileDiffCommand(changedFile),
};
});
};