@@ -24,8 +24,9 @@ var initCmd = &cobra.Command{
24241. Run 'git init'
25252. Configure git user (name/email)
26263. Add child GitHub repos as git submodules
27- 4. Create a GitHub remote repository via 'gh repo create'
28- 5. Generate a .gitignore with common patterns
27+ 4. Generate a .gitignore with common patterns
28+ 5. Create an initial commit
29+ 6. Create a GitHub remote repository via 'gh repo create --push'
2930
3031The repo name defaults to the current directory name.
3132Owner defaults to the 'github-owner' config value in ~/.spark.yaml.` ,
@@ -52,12 +53,12 @@ Owner defaults to the 'github-owner' config value in ~/.spark.yaml.`,
5253 fmt .Printf ("Initializing git repository: %s/%s\n " , owner , repoName )
5354 fmt .Println ()
5455
55- fmt .Println ("Step 1/5 : Running git init..." )
56+ fmt .Println ("Step 1/6 : Running git init..." )
5657 if err := git .InitRepo (repoPath ); err != nil {
5758 return fmt .Errorf ("git init failed: %w" , err )
5859 }
5960
60- fmt .Println ("Step 2/5 : Configuring git user..." )
61+ fmt .Println ("Step 2/6 : Configuring git user..." )
6162 username := viper .GetString ("git.username" )
6263 email := viper .GetString ("git.email" )
6364 if username != "" && email != "" {
@@ -71,25 +72,30 @@ Owner defaults to the 'github-owner' config value in ~/.spark.yaml.`,
7172 fmt .Println (" No git user configured in ~/.spark.yaml. Skipping." )
7273 }
7374
74- fmt .Println ("Step 3/5 : Scanning for child GitHub repos to add as submodules..." )
75+ fmt .Println ("Step 3/6 : Scanning for child GitHub repos to add as submodules..." )
7576 if err := git .AddChildReposAsSubmodules (repoPath ); err != nil {
7677 fmt .Printf ("Warning: %v\n " , err )
7778 }
7879
80+ fmt .Println ("Step 4/6: Generating .gitignore..." )
81+ if err := git .WriteGitIgnore (repoPath ); err != nil {
82+ fmt .Printf ("Warning: failed to write .gitignore: %v\n " , err )
83+ } else {
84+ fmt .Println (" .gitignore created" )
85+ }
86+
87+ fmt .Println ("Step 5/6: Creating initial commit..." )
88+ if err := git .InitialCommit (repoPath , "chore: initial commit via spark git init" ); err != nil {
89+ fmt .Printf ("Warning: initial commit failed: %v\n " , err )
90+ }
91+
7992 if ! initSkipGh {
80- fmt .Printf ("Step 4/5 : Creating GitHub remote repository (%s/%s)...\n " , owner , repoName )
93+ fmt .Printf ("Step 6/6 : Creating GitHub remote repository (%s/%s)...\n " , owner , repoName )
8194 if err := git .CreateGitHubRepo (repoPath , owner , repoName , initPrivate ); err != nil {
8295 return fmt .Errorf ("creating GitHub repository failed: %w" , err )
8396 }
8497 } else {
85- fmt .Println ("Step 4/5: Skipping GitHub remote creation (--skip-gh)" )
86- }
87-
88- fmt .Println ("Step 5/5: Generating .gitignore..." )
89- if err := git .WriteGitIgnore (repoPath ); err != nil {
90- fmt .Printf ("Warning: failed to write .gitignore: %v\n " , err )
91- } else {
92- fmt .Println (" .gitignore created" )
98+ fmt .Println ("Step 6/6: Skipping GitHub remote creation (--skip-gh)" )
9399 }
94100
95101 fmt .Println ()
0 commit comments