File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 "context"
77 _ "embed"
88 "encoding/json"
9- "errors"
109 "fmt"
1110 "io"
1211 "os"
@@ -117,10 +116,15 @@ var (
117116 cobra .CheckErr (fmt .Errorf ("failed to write manifest: %w" , err ))
118117 }
119118
120- // Initialize git repository if not already present.
121- _ , err = os .Stat (".git" )
122- if err != nil && errors .Is (err , os .ErrNotExist ) {
123- // Git directory doesn't exist, try to initialize.
119+ // Check if we're inside an existing git repository.
120+ var gitRepoExists bool
121+ gitRevParseCmd := exec .Command ("git" , "rev-parse" )
122+ if err = gitRevParseCmd .Run (); err == nil {
123+ gitRepoExists = true
124+ }
125+
126+ if ! gitRepoExists {
127+ // Initialize a new git repository in the app directory.
124128 gitInitCmd := exec .Command ("git" , "init" )
125129 if err = gitInitCmd .Run (); err != nil {
126130 fmt .Printf ("Git repository not initialized: %s.\n " , err )
@@ -129,7 +133,7 @@ var (
129133 }
130134 }
131135
132- // Initialize .gitignore.
136+ // Initialize .gitignore in the app directory .
133137 needToAddOrcIgnore := true
134138 gitignore , err := os .Open (".gitignore" )
135139 if err == nil {
You can’t perform that action at this time.
0 commit comments