Fix lint issues and sparse checkout for empty repos
- Handle empty repos in ConfigureSparseCheckout (skip read-tree when no HEAD) - Fix errcheck: wrap fileLock.Unlock() error in defer - Fix unparam: remove unused *rig.Rig return from getWitnessManager - Fix unparam: mark unused agentType parameter with blank identifier 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"os/exec"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/gastown/internal/rig"
|
||||
"github.com/steveyegge/gastown/internal/style"
|
||||
"github.com/steveyegge/gastown/internal/tmux"
|
||||
"github.com/steveyegge/gastown/internal/witness"
|
||||
@@ -117,20 +116,20 @@ func init() {
|
||||
}
|
||||
|
||||
// getWitnessManager creates a witness manager for a rig.
|
||||
func getWitnessManager(rigName string) (*witness.Manager, *rig.Rig, error) {
|
||||
func getWitnessManager(rigName string) (*witness.Manager, error) {
|
||||
_, r, err := getRig(rigName)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mgr := witness.NewManager(r)
|
||||
return mgr, r, nil
|
||||
return mgr, nil
|
||||
}
|
||||
|
||||
func runWitnessStart(cmd *cobra.Command, args []string) error {
|
||||
rigName := args[0]
|
||||
|
||||
mgr, _, err := getWitnessManager(rigName)
|
||||
mgr, err := getWitnessManager(rigName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -161,7 +160,7 @@ func runWitnessStart(cmd *cobra.Command, args []string) error {
|
||||
func runWitnessStop(cmd *cobra.Command, args []string) error {
|
||||
rigName := args[0]
|
||||
|
||||
mgr, _, err := getWitnessManager(rigName)
|
||||
mgr, err := getWitnessManager(rigName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -195,7 +194,7 @@ func runWitnessStop(cmd *cobra.Command, args []string) error {
|
||||
func runWitnessStatus(cmd *cobra.Command, args []string) error {
|
||||
rigName := args[0]
|
||||
|
||||
mgr, _, err := getWitnessManager(rigName)
|
||||
mgr, err := getWitnessManager(rigName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -282,7 +281,7 @@ func runWitnessAttach(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// Verify rig exists and get manager
|
||||
mgr, _, err := getWitnessManager(rigName)
|
||||
mgr, err := getWitnessManager(rigName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -312,7 +311,7 @@ func runWitnessAttach(cmd *cobra.Command, args []string) error {
|
||||
func runWitnessRestart(cmd *cobra.Command, args []string) error {
|
||||
rigName := args[0]
|
||||
|
||||
mgr, _, err := getWitnessManager(rigName)
|
||||
mgr, err := getWitnessManager(rigName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (d *Daemon) Run() error {
|
||||
if !locked {
|
||||
return fmt.Errorf("daemon already running (lock held by another process)")
|
||||
}
|
||||
defer fileLock.Unlock()
|
||||
defer func() { _ = fileLock.Unlock() }()
|
||||
|
||||
// Write PID file
|
||||
if err := os.WriteFile(d.config.PidFile, []byte(strconv.Itoa(os.Getpid())), 0644); err != nil {
|
||||
|
||||
@@ -216,7 +216,8 @@ func (c *ClaudeSettingsCheck) findSettingsFiles(townRoot string) []staleSettings
|
||||
|
||||
// checkSettings compares a settings file against the expected template.
|
||||
// Returns a list of what's missing.
|
||||
func (c *ClaudeSettingsCheck) checkSettings(path, agentType string) []string {
|
||||
// agentType is reserved for future role-specific validation.
|
||||
func (c *ClaudeSettingsCheck) checkSettings(path, _ string) []string {
|
||||
var missing []string
|
||||
|
||||
// Read the actual settings
|
||||
|
||||
@@ -644,6 +644,14 @@ func ConfigureSparseCheckout(repoPath string) error {
|
||||
return fmt.Errorf("writing sparse-checkout: %w", err)
|
||||
}
|
||||
|
||||
// Check if HEAD exists (repo has commits) before running read-tree
|
||||
// Empty repos (no commits) don't need read-tree and it would fail
|
||||
checkHead := exec.Command("git", "-C", repoPath, "rev-parse", "--verify", "HEAD")
|
||||
if err := checkHead.Run(); err != nil {
|
||||
// No commits yet, sparse checkout config is set up for future use
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reapply to remove excluded files
|
||||
cmd = exec.Command("git", "-C", repoPath, "read-tree", "-mu", "HEAD")
|
||||
stderr.Reset()
|
||||
|
||||
Reference in New Issue
Block a user