Movatterモバイル変換


[0]ホーム

URL:


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

Commitd0b85e6

Browse files
committed
resolve git config issue
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parentca3b6aa commitd0b85e6

File tree

7 files changed

+63
-21
lines changed

7 files changed

+63
-21
lines changed

‎.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010
".vscode-test/**":true
1111
},
1212
"git.alwaysSignOff":true,
13-
"typescript.tsdk":"./node_modules/typescript/lib"
13+
"typescript.tsdk":"./node_modules/typescript/lib",
14+
"cSpell.words": [
15+
"coderoad"
16+
]
1417
}

‎src/actions/onTutorialConfigNew.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as TT from 'typings/tutorial'
44
import*asEfrom'typings/error'
55
import{satisfies}from'semver'
66
import{onEvent}from'../services/telemetry'
7-
import{version,compareVersions}from'../services/dependencies'
7+
import{getVersion,compareVersions}from'../services/dependencies'
88
importContextfrom'../services/context/context'
99
importtutorialConfigfrom'./utils/tutorialConfig'
1010
import{send}from'../commands'
@@ -46,8 +46,23 @@ const onTutorialConfigNew = async (action: T.Action, context: Context): Promise<
4646
if(dependencies&&dependencies.length){
4747
for(constdepofdependencies){
4848
// check dependency is installed
49-
constcurrentVersion:string|null=awaitversion(dep.name)
50-
if(!currentVersion){
49+
const{ version,error:gitError}=awaitgetVersion(dep.name)
50+
if(gitError){
51+
// git config issue
52+
consterror:E.ErrorMessage={
53+
type:'GitConfigError',
54+
message:gitError.message,
55+
actions:[
56+
{
57+
label:'Check Again',
58+
transition:'TRY_AGAIN',
59+
},
60+
],
61+
}
62+
send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
63+
return
64+
}
65+
if(!version){
5166
// use a custom error message
5267
consterror:E.ErrorMessage={
5368
type:'MissingTutorialDependency',
@@ -64,12 +79,12 @@ const onTutorialConfigNew = async (action: T.Action, context: Context): Promise<
6479
}
6580

6681
// check dependency version
67-
constsatisfiedDependency=awaitcompareVersions(currentVersion,dep.version)
82+
constsatisfiedDependency=awaitcompareVersions(version,dep.version)
6883

6984
if(!satisfiedDependency){
7085
consterror:E.ErrorMessage={
7186
type:'UnmetTutorialDependency',
72-
message:`Expected${dep.name} to have version${dep.version}, but found version${currentVersion}`,
87+
message:`Expected${dep.name} to have version${dep.version}, but found version${version}`,
7388
actions:[
7489
{
7590
label:'Check Again',
@@ -116,7 +131,7 @@ const onTutorialConfigNew = async (action: T.Action, context: Context): Promise<
116131

117132
// report back to the webview that setup is complete
118133
send({type:'TUTORIAL_CONFIGURED'})
119-
}catch(e){
134+
}catch(e:any){
120135
consterror={
121136
type:'UnknownError',
122137
message:`Location: EditorTutorialConfig.\n\n${e.message}`,

‎src/actions/onValidateSetup.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asEfrom'typings/error'
2-
import{version}from'../services/dependencies'
2+
import{getVersion}from'../services/dependencies'
33
import{checkWorkspaceEmpty}from'../services/workspace'
44
import{send}from'../commands'
55
import{validateGitConfig}from'../services/git'
@@ -28,8 +28,23 @@ const onValidateSetup = async (): Promise<void> => {
2828
}
2929
// check Git is installed.
3030
// Should wait for workspace before running otherwise requires access to root folder
31-
constisGitInstalled=awaitversion('git')
32-
if(!isGitInstalled){
31+
const{ version,error:gitError}=awaitgetVersion('git')
32+
if(gitError){
33+
// git config issue
34+
consterror:E.ErrorMessage={
35+
type:'GitConfigError',
36+
message:gitError.message,
37+
actions:[
38+
{
39+
label:'Check Again',
40+
transition:'TRY_AGAIN',
41+
},
42+
],
43+
}
44+
send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
45+
return
46+
}
47+
if(!version){
3348
consterror:E.ErrorMessage={
3449
type:'GitNotFound',
3550
message:'',
@@ -46,6 +61,9 @@ const onValidateSetup = async (): Promise<void> => {
4661

4762
constisGitUserNameConfigured=awaitvalidateGitConfig('user.name')
4863
constisGitUserEmailConfigured=awaitvalidateGitConfig('user.email')
64+
console.log(`isGitUserNameConf:${isGitUserNameConfigured}`)
65+
console.log(`isGitUserEmailConf:${isGitUserEmailConfigured}`)
66+
4967
if(!isGitUserNameConfigured||!isGitUserEmailConfigured){
5068
letmessage=''
5169
if(!isGitUserNameConfigured)message+='Git user not configured.\n'
@@ -65,9 +83,9 @@ const onValidateSetup = async (): Promise<void> => {
6583
}
6684

6785
send({type:'SETUP_VALIDATED'})
68-
}catch(e){
86+
}catch(e:any){
6987
consterror={
70-
type:'UknownError',
88+
type:'UnknownError',
7189
message:e.message,
7290
}
7391
send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})

‎src/services/dependencies/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import{satisfies}from'semver'
22
import{exec}from'../node'
33

4-
constsemverRegex=/(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(\.windows.[0-9]+)?(?=$|\s)/gi
4+
constsemverRegex=
5+
/(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(\.windows.[0-9]+)?(?=$|\s)/gi
56

6-
exportconstversion=async(name:string):Promise<string|null>=>{
7+
exportconstgetVersion=async(name:string):Promise<{version:string|null;error:Error|null}>=>{
78
try{
89
const{ stdout, stderr}=awaitexec({command:`${name} --version`})
910
if(!stderr){
1011
constmatch=stdout.match(semverRegex)
1112
if(match){
1213
constparsedVersion=match[0].split('.').slice(0,3).join('.')
13-
returnparsedVersion
14+
return{version:parsedVersion,error:null}
1415
}
1516
}
16-
returnnull
17-
}catch(error){
18-
returnnull
17+
return{version:null,error:null}
18+
}catch(error:any){
19+
return{version:null, error}
1920
}
2021
}
2122

‎src/services/git/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import*asTTfrom'typings/tutorial'
22
import{exec,exists}from'../node'
3-
import{version,compareVersions}from'../dependencies'
3+
import{getVersion,compareVersions}from'../dependencies'
44
importloggerfrom'../logger'
55

66
exportconstgitOrigin='coderoad'
77

88
conststashAllFiles=async():Promise<never|void>=>{
99
// stash files including untracked (eg. newly created file)
10-
const{stdout,stderr}=awaitexec({command:`git stash --include-untracked`})
10+
const{ stderr}=awaitexec({command:`git stash --include-untracked`})
1111
if(stderr){
1212
console.error(stderr)
1313
thrownewError('Error stashing files')
@@ -71,7 +71,10 @@ export async function clear(): Promise<Error | void> {
7171
}
7272

7373
asyncfunctioninit():Promise<Error|void>{
74-
constgitVersion=awaitversion('git')
74+
const{version:gitVersion,error:gitError}=awaitgetVersion('git')
75+
if(gitError){
76+
thrownewError(`Error: Git config error:${gitError.message}`)
77+
}
7578
if(!gitVersion){
7679
thrownewError('Error: No git version found')
7780
}

‎typings/error.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export type ErrorMessageView = 'FULL_PAGE' | 'NOTIFY' | 'NONE'
33
exporttypeErrorMessageType=
44
|'FailedToConnectToGitRepo'
55
|'GitNotFound'
6+
|'GitConfigError'
67
|'GitUserNotConfigured'
78
|'GitProjectAlreadyExists'
89
|'GitRemoteAlreadyExists'

‎web-app/src/services/errors/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"FailedToConnectToGitRepo":"### Failed to Connect to Git Repo\n\nThere are several possible causes:\n\n- you may not be connected to the internet or have an unstable connection.\n- you may not have access permission to the remote tutorial repo.\n- the remote tutorial repo may not exist at the provided location",
33
"GitNotFound":"### Git Not Found\n\nMake sure you have Git installed.\n\nSee the [Git docs](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) for help.",
4+
"GitConfigError":"### Git Config Error\n\n There may be an issue with your git configuration. Examine your config in ~/.gitconfig",
45
"GitUserNotConfigured":"### Git User Not Configured\n\nThe first thing you should do when you install Git is to set your user name and email address. This is important because every Git commit uses this information, and it’s immutably baked into the commits you start creating:\n```shell\ngit config --global user.name\"John Doe\"\ngit config --global user.email johndoe@example.com\n```",
56
"GitProjectAlreadyExists":"### Git Remote Already Exists\n\nHave you started this tutorial before in this workspace? The Git remote already exists.\n\nConsider deleting your `.git` folder and restarting.",
67
"GitRemoteAlreadyExists":"### Git Project Already Exists\n\nCodeRoad requires an empty Git project.\n\nOpen a new workspace to start a tutorial.",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp