Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a8df244

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
ATL-1145: Suppress error if Git is not on $PATH.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent d45dd6b commit a8df244

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

‎arduino-ide-extension/src/node/arduino-ide-backend-module.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import { NotificationServiceServerImpl } from './notification-service-server';
3434
import { NotificationServiceServer, NotificationServiceClient, NotificationServicePath } from '../common/protocol';
3535
import { BackendApplication } from './theia/core/backend-application';
3636
import { BoardDiscovery } from './board-discovery';
37+
import { DefaultGitInit } from './theia/git/git-init';
38+
import { GitInit } from '@theia/git/lib/node/init/git-init';
3739

3840
export default new ContainerModule((bind, unbind, isBound, rebind) => {
3941
bind(BackendApplication).toSelf().inSingletonScope();
@@ -164,4 +166,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
164166
return parentLogger.child('monitor-service');
165167
}).inSingletonScope().whenTargetNamed('monitor-service');
166168

169+
bind(DefaultGitInit).toSelf();
170+
rebind(GitInit).toService(DefaultGitInit);
171+
167172
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { injectable } from 'inversify';
2+
import findGit from 'find-git-exec';
3+
import { dirname } from 'path';
4+
import { pathExists } from 'fs-extra';
5+
import { GitInit } from '@theia/git/lib/node/init/git-init';
6+
import { DisposableCollection } from '@theia/core/lib/common/disposable';
7+
8+
@injectable()
9+
export class DefaultGitInit implements GitInit {
10+
11+
protected readonly toDispose = new DisposableCollection();
12+
13+
async init(): Promise<void> {
14+
const { env } = process;
15+
try {
16+
const { execPath, path, version } = await findGit();
17+
if (!!execPath && !!path && !!version) {
18+
const dir = dirname(dirname(path));
19+
const [execPathOk, pathOk, dirOk] = await Promise.all([pathExists(execPath), pathExists(path), pathExists(dir)]);
20+
if (execPathOk && pathOk && dirOk) {
21+
if (typeof env.LOCAL_GIT_DIRECTORY !== 'undefined' && env.LOCAL_GIT_DIRECTORY !== dir) {
22+
console.error(`Misconfigured env.LOCAL_GIT_DIRECTORY: ${env.LOCAL_GIT_DIRECTORY}. dir was: ${dir}`);
23+
return;
24+
}
25+
if (typeof env.GIT_EXEC_PATH !== 'undefined' && env.GIT_EXEC_PATH !== execPath) {
26+
console.error(`Misconfigured env.GIT_EXEC_PATH: ${env.GIT_EXEC_PATH}. execPath was: ${execPath}`);
27+
return;
28+
}
29+
process.env.LOCAL_GIT_DIRECTORY = dir;
30+
process.env.GIT_EXEC_PATH = execPath;
31+
console.info(`Using Git [${version}] from the PATH. (${path})`);
32+
return;
33+
}
34+
}
35+
} catch (err) {
36+
console.error(err);
37+
}
38+
}
39+
40+
dispose(): void {
41+
this.toDispose.dispose();
42+
}
43+
44+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /