Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmd/entire/cli/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,20 @@ If Entire is already configured but disabled, this re-enables it.`,
// Check if we're in a git repository first - this is a prerequisite error,
// not a usage error, so we silence Cobra's output and use SilentError
// to prevent duplicate error output in main.go
if _, err := paths.WorktreeRoot(ctx); err != nil {
repoRoot, err := paths.WorktreeRoot(ctx)
if err != nil {
fmt.Fprintln(cmd.ErrOrStderr(), "Not a git repository. Please run 'entire enable' from within a git repository.")
return NewSilentError(errors.New("not a git repository"))
}

// Notify the user when running from a subdirectory.
// All path resolution uses paths.WorktreeRoot(ctx) which returns the
// correct repo root regardless of CWD, so no directory change is needed.
cwd, err := os.Getwd() //nolint:forbidigo // Need CWD to detect subdirectory
if err == nil && cwd != repoRoot {
fmt.Fprintf(cmd.ErrOrStderr(), "Note: Running from repository root (%s)\n\n", repoRoot)
}

if err := validateSetupFlags(opts.UseLocalSettings, opts.UseProjectSettings); err != nil {
return err
}
Expand Down