Files
wehub-resource-sync 26f897c1ec
release / release-please (push) Failing after 1m49s
docs / build (push) Failing after 6m34s
release / build-and-upload (arm64, linux) (push) Has been cancelled
release / build-and-upload (arm64, windows) (push) Has been cancelled
release / build-darwin (amd64, darwin) (push) Has been cancelled
release / checksums (push) Has been cancelled
release / finalize (push) Has been cancelled
release / build-darwin (arm64, darwin) (push) Has been cancelled
release / build-and-upload (amd64, linux) (push) Has been cancelled
release / build-and-upload (amd64, windows) (push) Has been cancelled
docs / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:34:16 +08:00

48 lines
1.3 KiB
Go

package cli
import (
"fmt"
"github.com/kunchenguid/no-mistakes/internal/gate"
"github.com/kunchenguid/no-mistakes/internal/safeurl"
"github.com/spf13/cobra"
)
func newEjectCmd() *cobra.Command {
return &cobra.Command{
Use: "eject",
Short: "Remove no-mistakes gate from the current repository",
Long: `Removes the "no-mistakes" git remote, deletes the bare repo and worktrees,
and removes the repo record from the database.`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return trackCommand("eject", func() error {
p, d, err := openResources()
if err != nil {
return err
}
defer d.Close()
repo, err := gate.Eject(cmd.Context(), d, p, ".")
if err != nil {
return fmt.Errorf("eject: %w", err)
}
w := cmd.OutOrStdout()
fmt.Fprintf(w, " %s Gate removed\n", sGreen.Render("✓"))
fmt.Fprintln(w)
fmt.Fprintf(w, " %s %s\n", sDim.Render(" repo"), repo.WorkingPath)
remoteURL := repo.UpstreamURL
if repo.ForkURL != "" {
remoteURL = safeurl.Redact(remoteURL)
}
fmt.Fprintf(w, " %s %s\n", sDim.Render("remote"), remoteURL)
if repo.ForkURL != "" {
fmt.Fprintf(w, " %s %s\n", sDim.Render(" fork"), safeurl.Redact(repo.ForkURL))
}
return nil
})
},
}
}