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

Commitf287d5d

Browse files
authored
Merge pull request#496 from coderoad/fix/early-git-version
fix git issue pre-v2.28 due to master->main change
2 parentsdf5c95e +34714a3 commitf287d5d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

‎src/services/git/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import*asTTfrom'typings/tutorial'
22
import{exec,exists}from'../node'
3+
import{version,compareVersions}from'../dependencies'
34
importloggerfrom'../logger'
45

56
exportconstgitOrigin='coderoad'
@@ -70,8 +71,22 @@ export async function clear(): Promise<Error | void> {
7071
}
7172

7273
asyncfunctioninit():Promise<Error|void>{
74+
constgitVersion=awaitversion('git')
75+
if(!gitVersion){
76+
thrownewError('Error: No git version found')
77+
}
78+
consthasInitialBranch=awaitcompareVersions(gitVersion,'>=2.28.0')
79+
letstderr
80+
if(hasInitialBranch){
81+
// --initial-branch is introduced in git v2.28 when git changed the default master -> main
82+
constinitResult=awaitexec({command:'git init --initial-branch=master'})
83+
stderr=initResult.stderr
84+
}else{
85+
// pre git v2.28, master is default branch
86+
constinitResult=awaitexec({command:'git init'})
87+
stderr=initResult.stderr
88+
}
7389
// note: prevents stderr warning concerning default init branch
74-
const{ stderr}=awaitexec({command:'git init --initial-branch=master'})
7590
if(stderr){
7691
thrownewError(`Error initializing Git:${stderr}`)
7792
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp