remove_dot_git

package
v0.95.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "remove-dot-git",
	Short: "Remove all .git directories in tree",
	Args:  cobra.NoArgs,
	Run: func(c *cobra.Command, args []string) {
		// Find all .git directories
		var dotGitDirs []string
		err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
			if err != nil {
				return err
			}
			if info.IsDir() && info.Name() == ".git" {
				dotGitDirs = append(dotGitDirs, path)

				return filepath.SkipDir
			}
			return nil
		})
		if err != nil {
			fmt.Fprintf(os.Stderr, "Error walking directory: %v\n", err)
			os.Exit(1)
		}

		if len(dotGitDirs) == 0 {
			fmt.Println("No .git directories found")
			return
		}

		fmt.Println("Found .git directories:")
		for _, dir := range dotGitDirs {
			fmt.Printf("  %s\n", dir)
		}

		fmt.Printf("\nType 'yes' to remove these directories: ")
		reader := bufio.NewReader(os.Stdin)
		response, err := reader.ReadString('\n')
		if err != nil {
			fmt.Fprintf(os.Stderr, "Error reading input: %v\n", err)
			os.Exit(1)
		}

		response = strings.TrimSpace(response)
		if response != "yes" {
			fmt.Println("Aborted")
			return
		}

		for _, dir := range dotGitDirs {
			err := os.RemoveAll(dir)
			if err != nil {
				fmt.Fprintf(os.Stderr, "Error removing %s: %v\n", dir, err)
			} else {
				fmt.Printf("Removed: %s\n", dir)
			}
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL