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

Commit59ec0d2

Browse files
committed
setup git cherry-pick fallback
1 parent9edf80c commit59ec0d2

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

‎src/services/git/index.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,41 @@ const stashAllFiles = async () => {
1313
}
1414
}
1515

16+
constcherryPickCommit=async(commit:string,count=0):Promise<void>=>{
17+
if(count>1){
18+
console.warn('cherry-pick failed')
19+
return
20+
}
21+
try{
22+
const{ stdout}=awaitexec(`git cherry-pick${commit}`)
23+
if(!stdout){
24+
thrownewError('No cherry-pick output')
25+
}
26+
}catch(error){
27+
console.log('cherry-pick-commit failed')
28+
// stash all files if cherry-pick fails
29+
awaitstashAllFiles()
30+
returncherryPickCommit(commit,++count)
31+
}
32+
}
33+
34+
consterrorMessages={
35+
js:{
36+
'node-gyp':'Error running npm setup command'
37+
}
38+
}
39+
1640
/*
1741
SINGLE git cherry-pick %COMMIT%
18-
MULTIPLE git cherry-pick %COMMIT_START%..%COMMIT_END%
19-
if shell, run shell
20-
21-
if fails, will stash all
42+
if fails, will stash all and retry
2243
*/
2344
exportasyncfunctiongitLoadCommits(actions:CR.TutorialAction,dispatch:CR.EditorDispatch):Promise<void>{
2445
const{ commits, commands, files}=actions
2546

2647
for(constcommitofcommits){
2748
// pull a commit from tutorial repo
28-
const{ stdout, stderr}=awaitexec(`git cherry-pick${commit}`)
29-
if(stderr){
30-
console.warn('cherry-pick failed')
31-
// likely merge conflict with cherry-pick
32-
awaitstashAllFiles()
33-
const{stderr:secondFailure}=awaitexec(`git cherry-pick${commit}`)
34-
if(secondFailure){
35-
thrownewError('Error loading commit')
36-
}
37-
}
49+
console.log(`try cherry-pick${commit}`)
50+
awaitcherryPickCommit(commit)
3851
}
3952

4053
if(commands){
@@ -43,9 +56,12 @@ export async function gitLoadCommits(actions: CR.TutorialAction, dispatch: CR.Ed
4356
const{ stdout, stderr}=awaitexec(command)
4457
if(stderr){
4558
console.error(stderr)
46-
if(stderr.match(/node-gyp/)){
47-
// ignored error
48-
thrownewError('Error running setup command')
59+
// langauge specific error messages from running commands
60+
for(constmessageofObject.keys(errorMessages.js)){
61+
if(stderr.match(message)){
62+
// ignored error
63+
thrownewError('Error running setup command')
64+
}
4965
}
5066
}
5167
console.log(`run command:${command}`,stdout)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp