Private by default (#18)

This commit is contained in:
Madison Bullard
2026-01-02 14:52:23 -05:00
committed by GitHub
parent 17c349c965
commit 6717dad32b
2 changed files with 27 additions and 21 deletions

View File

@@ -14,7 +14,7 @@ import (
var ( var (
gitInitGitHub string gitInitGitHub string
gitInitPrivate bool gitInitPublic bool
) )
var gitInitCmd = &cobra.Command{ var gitInitCmd = &cobra.Command{
@@ -26,7 +26,7 @@ var gitInitCmd = &cobra.Command{
This command: This command:
1. Creates a comprehensive .gitignore for Gas Town 1. Creates a comprehensive .gitignore for Gas Town
2. Initializes a git repository if not already present 2. Initializes a git repository if not already present
3. Optionally creates a GitHub repository 3. Optionally creates a GitHub repository (private by default)
The .gitignore excludes: The .gitignore excludes:
- Polecat worktrees and rig clones (recreated with 'gt sling' or 'gt rig add') - Polecat worktrees and rig clones (recreated with 'gt sling' or 'gt rig add')
@@ -39,15 +39,15 @@ And tracks:
- Rig configs and hop/ directory - Rig configs and hop/ directory
Examples: Examples:
gt git-init # Init git with .gitignore gt git-init # Init git with .gitignore
gt git-init --github=user/repo # Also create public GitHub repo gt git-init --github=user/repo # Create private GitHub repo (default)
gt git-init --github=user/repo --private # Create private GitHub repo`, gt git-init --github=user/repo --public # Create public GitHub repo`,
RunE: runGitInit, RunE: runGitInit,
} }
func init() { func init() {
gitInitCmd.Flags().StringVar(&gitInitGitHub, "github", "", "Create GitHub repo (format: owner/repo)") gitInitCmd.Flags().StringVar(&gitInitGitHub, "github", "", "Create GitHub repo (format: owner/repo, private by default)")
gitInitCmd.Flags().BoolVar(&gitInitPrivate, "private", false, "Make GitHub repo private") gitInitCmd.Flags().BoolVar(&gitInitPublic, "public", false, "Make GitHub repo public (repos are private by default)")
rootCmd.AddCommand(gitInitCmd) rootCmd.AddCommand(gitInitCmd)
} }
@@ -145,7 +145,7 @@ func runGitInit(cmd *cobra.Command, args []string) error {
// Create GitHub repo if requested // Create GitHub repo if requested
if gitInitGitHub != "" { if gitInitGitHub != "" {
if err := createGitHubRepo(hqRoot, gitInitGitHub, gitInitPrivate); err != nil { if err := createGitHubRepo(hqRoot, gitInitGitHub, !gitInitPublic); err != nil {
return err return err
} }
} }
@@ -222,7 +222,11 @@ func createGitHubRepo(hqRoot, repo string, private bool) error {
return fmt.Errorf("invalid GitHub repo format (expected owner/repo): %s", repo) return fmt.Errorf("invalid GitHub repo format (expected owner/repo): %s", repo)
} }
fmt.Printf(" → Creating GitHub repository %s...\n", repo) visibility := "private"
if !private {
visibility = "public"
}
fmt.Printf(" → Creating %s GitHub repository %s...\n", visibility, repo)
// Build gh repo create command // Build gh repo create command
args := []string{"repo", "create", repo, "--source", hqRoot} args := []string{"repo", "create", repo, "--source", hqRoot}
@@ -241,7 +245,10 @@ func createGitHubRepo(hqRoot, repo string, private bool) error {
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
return fmt.Errorf("gh repo create failed: %w", err) return fmt.Errorf("gh repo create failed: %w", err)
} }
fmt.Printf(" ✓ Created and pushed to GitHub: %s\n", repo) fmt.Printf(" ✓ Created and pushed to GitHub: %s (%s)\n", repo, visibility)
if private {
fmt.Printf(" To make this repo public: %s\n", style.Dim.Render("gh repo edit "+repo+" --visibility public"))
}
return nil return nil
} }

View File

@@ -24,7 +24,7 @@ var (
installNoBeads bool installNoBeads bool
installGit bool installGit bool
installGitHub string installGitHub string
installPrivate bool installPublic bool
) )
var installCmd = &cobra.Command{ var installCmd = &cobra.Command{
@@ -46,11 +46,12 @@ See docs/hq.md for advanced HQ configurations including beads
redirects, multi-system setups, and HQ templates. redirects, multi-system setups, and HQ templates.
Examples: Examples:
gt install ~/gt # Create HQ at ~/gt gt install ~/gt # Create HQ at ~/gt
gt install . --name my-workspace # Initialize current dir gt install . --name my-workspace # Initialize current dir
gt install ~/gt --no-beads # Skip .beads/ initialization gt install ~/gt --no-beads # Skip .beads/ initialization
gt install ~/gt --git # Also init git with .gitignore gt install ~/gt --git # Also init git with .gitignore
gt install ~/gt --github=user/repo # Also create GitHub repo`, gt install ~/gt --github=user/repo # Create private GitHub repo (default)
gt install ~/gt --github=user/repo --public # Create public GitHub repo`,
Args: cobra.MaximumNArgs(1), Args: cobra.MaximumNArgs(1),
RunE: runInstall, RunE: runInstall,
} }
@@ -62,8 +63,8 @@ func init() {
installCmd.Flags().StringVar(&installPublicName, "public-name", "", "Public display name (defaults to town name)") installCmd.Flags().StringVar(&installPublicName, "public-name", "", "Public display name (defaults to town name)")
installCmd.Flags().BoolVar(&installNoBeads, "no-beads", false, "Skip town beads initialization") installCmd.Flags().BoolVar(&installNoBeads, "no-beads", false, "Skip town beads initialization")
installCmd.Flags().BoolVar(&installGit, "git", false, "Initialize git with .gitignore") installCmd.Flags().BoolVar(&installGit, "git", false, "Initialize git with .gitignore")
installCmd.Flags().StringVar(&installGitHub, "github", "", "Create GitHub repo (format: owner/repo)") installCmd.Flags().StringVar(&installGitHub, "github", "", "Create GitHub repo (format: owner/repo, private by default)")
installCmd.Flags().BoolVar(&installPrivate, "private", false, "Make GitHub repo private (use with --github)") installCmd.Flags().BoolVar(&installPublic, "public", false, "Make GitHub repo public (use with --github)")
rootCmd.AddCommand(installCmd) rootCmd.AddCommand(installCmd)
} }
@@ -217,7 +218,7 @@ func runInstall(cmd *cobra.Command, args []string) error {
// Initialize git if requested (--git or --github implies --git) // Initialize git if requested (--git or --github implies --git)
if installGit || installGitHub != "" { if installGit || installGitHub != "" {
fmt.Println() fmt.Println()
if err := InitGitForHarness(absPath, installGitHub, installPrivate); err != nil { if err := InitGitForHarness(absPath, installGitHub, !installPublic); err != nil {
return fmt.Errorf("git initialization failed: %w", err) return fmt.Errorf("git initialization failed: %w", err)
} }
} }
@@ -283,5 +284,3 @@ func initTownBeads(townPath string) error {
} }
return nil return nil
} }