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

Commit98932e0

Browse files
committed
add git remote check
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parentd7a5e42 commit98932e0

File tree

5 files changed

+89
-4
lines changed

5 files changed

+89
-4
lines changed

‎src/services/git/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import*asTTfrom'typings/tutorial'
12
importnodefrom'../node'
23
importloggerfrom'../logger'
34
importonErrorfrom'../sentry/onError'
@@ -98,6 +99,24 @@ export async function initIfNotExists(): Promise<void> {
9899
}
99100
}
100101

102+
exportasyncfunctioncheckRemoteConnects(repo:TT.TutorialRepo):Promise<boolean|Error>{
103+
// check for git repo
104+
constexternalRepoExists=awaitnode.exec(`git ls-remote --exit-code --heads${repo.uri}`)
105+
if(externalRepoExists.stderr){
106+
// no repo found or no internet connection
107+
thrownewError(externalRepoExists.stderr)
108+
}
109+
// check for git repo branch
110+
const{ stderr, stdout}=awaitnode.exec(`git ls-remote --exit-code --heads${repo.uri}${repo.branch}`)
111+
if(stderr){
112+
thrownewError(stderr)
113+
}
114+
if(!stdout||!stdout.length){
115+
thrownewError('Tutorial branch does not exist')
116+
}
117+
returntrue
118+
}
119+
101120
exportasyncfunctionaddRemote(repo:string):Promise<void>{
102121
const{ stderr}=awaitnode.exec(`git remote add${gitOrigin}${repo} && git fetch${gitOrigin}`)
103122
if(stderr){

‎typings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ export interface MachineStateSchema {
7575
ValidateSetup:{}
7676
NonEmptyWorkspace:{}
7777
GitNotInstalled:{}
78+
GitRemoteFailed:{}
7879
SelectTutorial:{}
7980
SetupNewTutorial:{}
81+
StartNewTutorial:{}
8082
}
8183
}
8284
Tutorial:{

‎web-app/src/Routes.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import CompletedPage from './containers/Tutorial/CompletedPage'
88
importLevelSummaryPagefrom'./containers/Tutorial/LevelPage'
99
importSelectEmptyWorkspacefrom'./containers/Check/SelectWorkspace'
1010
importGitInstalledfrom'./containers/Check/GitInstalled'
11+
importGitRemoteFailedfrom'./containers/Check/GitRemoteFailed'
1112

1213
constRoutes=()=>{
1314
const{ context, send, Router, Route}=useRouter()
1415
return(
1516
<Workspace>
1617
<Router>
1718
{/* Setup */}
18-
<Routepath={['Setup.Startup','Setup.Authenticate','Setup.LoadStoredTutorial','Setup.CheckEmptyWorkspace']}>
19+
<Routepath={['Setup.Startup','Setup.LoadStoredTutorial','Setup.ValidateSetup']}>
1920
<LoadingPagetext="Launching..."context={context}/>
2021
</Route>
2122
<Routepath="Setup.Start">
@@ -36,9 +37,12 @@ const Routes = () => {
3637
<Routepath="Setup.SelectTutorial">
3738
<SelectTutorialPagesend={send}context={context}/>
3839
</Route>
39-
<Routepath="Setup.SetupNewTutorial">
40+
<Routepath={['Setup.SetupNewTutorial','Setup.StartNewTutorial']}>
4041
<LoadingPagetext="Configuring tutorial..."context={context}/>
4142
</Route>
43+
<Routepath="Setup.GitRemoteFailed">
44+
<GitRemoteFailedsend={send}error={context.error}/>
45+
</Route>
4246
{/* Tutorial */}
4347
<Routepath={['Tutorial.LoadNext','Tutorial.Level.Load']}>
4448
<LoadingPagetext="Loading Level..."context={context}/>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import*asReactfrom'react'
2+
import*asTfrom'typings'
3+
import{css,jsx}from'@emotion/core'
4+
importButtonfrom'../../components/Button'
5+
6+
conststyles={
7+
container:{
8+
padding:'1rem',
9+
},
10+
}
11+
12+
typeProps={
13+
error:T.ErrorMessage|null
14+
send:(action:T.Action)=>void
15+
}
16+
17+
constGitRemoteFailed=(props:Props)=>{
18+
constonTryAgain=()=>props.send({type:'TRY_AGAIN'})
19+
return(
20+
<divcss={styles.container}>
21+
<h3>Git Remote Failed</h3>
22+
<p>Something went wrong when connecting to the Git repo.</p>
23+
<p>
24+
There may be a problem with: (1) your internet, (2) your access to a private repo, or (3) the tutorial may not
25+
have the correct repo name or branch.
26+
</p>
27+
28+
{props.error&&(
29+
<div>
30+
<p>See the following error below for help:</p>
31+
<pre>
32+
<code>
33+
{props.error.title}
34+
{props.error.description}
35+
</code>
36+
</pre>
37+
</div>
38+
)}
39+
40+
<br/>
41+
<Buttontype="secondary"onClick={onTryAgain}>
42+
Check Again
43+
</Button>
44+
</div>
45+
)
46+
}
47+
48+
exportdefaultGitRemoteFailed

‎web-app/src/services/state/machine.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ export const createMachine = (options: any) => {
8585
TRY_AGAIN:'ValidateSetup',
8686
},
8787
},
88+
GitRemoteFailed:{
89+
on:{
90+
TRY_AGAIN:'SetupNewTutorial',
91+
},
92+
},
8893
SelectTutorial:{
8994
onEntry:['clearStorage'],
9095
id:'select-new-tutorial',
@@ -96,9 +101,16 @@ export const createMachine = (options: any) => {
96101
},
97102
},
98103
SetupNewTutorial:{
99-
onEntry:['configureNewTutorial','startNewTutorial'],
104+
onEntry:['configureNewTutorial'],
100105
on:{
101-
TUTORIAL_CONFIGURED:'#tutorial',
106+
GIT_REMOTE_FAILED:'GitRemoteFailed',
107+
TUTORIAL_CONFIGURED:'StartNewTutorial',
108+
},
109+
},
110+
StartNewTutorial:{
111+
onEntry:['startNewTutorial'],
112+
after:{
113+
0:'#tutorial',
102114
},
103115
},
104116
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp