-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsetup-git-mob.js
More file actions
101 lines (91 loc) · 3.55 KB
/
setup-git-mob.js
File metadata and controls
101 lines (91 loc) · 3.55 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const vscode = require("vscode");
const {
CoAuthorProvider,
} = require("./co-author-tree-provider/co-authors-provider");
const { reloadOnSave } = require("./reload-on-save");
const { reloadCommand } = require("./commands/reload");
const { openGitCoAuthor } = require("./commands/open-git-coauthors");
const { soloCommand } = require("./commands/solo");
const {
addCoAuthor,
removeCoAuthor,
addFromFavourite,
} = require("./commands/co-author-actions");
const { addRepoAuthorToCoauthors } = require("./commands/add-co-author");
const {
searchRepositoryUsers,
} = require("./commands/search-repository-authors");
const { changePrimaryAuthor } = require("./commands/change-primary-author");
const { searchGitEmojis } = require("./commands/search-git-emojis");
const { openSettings } = require("./commands/open-settings");
const { searchGithubAuthors } = require("./commands/github-authors");
const { copyCoAuthor } = require("./commands/copy-co-author");
const { soloAfterCommit } = require("./ext-config/solo-after-commit");
const { logIssue } = require("./errors/log-issue");
const {
CountDecorationProvider,
} = require("./co-author-tree-provider/count-decorator-provider");
const { updateConfig, messageFormatter } = require("git-mob-core");
const { buildCoAuthorGroups } = require("./build-co-author-groups");
const {
InputCompletionProvider,
} = require("./co-author-tree-provider/input-completion-provider");
const { addMainAuthor } = require("./commands/add-main-author");
async function setupGitMob(context, gitExt) {
return bootGitMob(context, gitExt);
}
async function bootGitMob(context, gitExt) {
updateConfig("processCwd", gitExt.rootPath);
try {
const coAuthorProvider = new CoAuthorProvider(await buildCoAuthorGroups());
coAuthorProvider.onDidChangeTreeData(function () {
try {
gitExt.updateSelectedInput((text) =>
messageFormatter(text, coAuthorProvider.coAuthorGroups.getSelected())
);
} catch (err) {
logIssue("Failed to update input: " + err.message);
}
});
const disposables = [
openSettings(),
reloadCommand({ coAuthorProvider }),
addCoAuthor({ coAuthorProvider }),
removeCoAuthor({ coAuthorProvider }),
addFromFavourite({ coAuthorProvider }),
addRepoAuthorToCoauthors({ coAuthorProvider }),
searchRepositoryUsers({ coAuthorProvider }),
openGitCoAuthor({ coAuthorProvider }),
soloCommand({ coAuthorProvider }),
searchGitEmojis(),
changePrimaryAuthor({ coAuthorProvider }),
searchGithubAuthors({ coAuthorProvider }),
new CountDecorationProvider(coAuthorProvider),
new InputCompletionProvider(coAuthorProvider),
copyCoAuthor(),
addMainAuthor({ coAuthorProvider }),
];
disposables.forEach((dispose) => context.subscriptions.push(dispose));
reloadOnSave();
soloAfterCommit(coAuthorProvider);
gitExt.onDidChangeUiState(async function () {
if (gitExt.repositories.length === 1) return;
if (this.ui.selected) {
gitExt.selectedRepositoryPath = this.rootUri.path;
updateConfig("processCwd", gitExt.rootPath);
await vscode.commands.executeCommand("gitmob.reload");
}
});
const mobList = vscode.window.createTreeView("gitmob.CoAuthorsView", {
treeDataProvider: coAuthorProvider,
canSelectMany: true,
});
mobList.onDidChangeSelection(function (evt) {
coAuthorProvider.multiSelected = evt.selection;
});
} catch (error) {
logIssue(error.message);
console.log("SETUP ERROR: ", error);
}
}
exports.setupGitMob = setupGitMob;