From aeea8a3001e0617b1cec3d67d64429f19d70fe63 Mon Sep 17 00:00:00 2001 From: Alexander Paz Date: Thu, 22 Jan 2026 10:13:16 -0500 Subject: [PATCH 1/2] HOTFIX: fix the cody_cd function --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 47a5774..df3acb1 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,5 @@ In order to get the benefit of some features in cody you will need to copy the f ``` function cody_cd() { eval $(cody open $@) - cd $(cat /tmp/cody_result) } ``` From 5d1e70de157dbe0845d672b00d4c0bb52bfc545e Mon Sep 17 00:00:00 2001 From: Alexander Paz Date: Thu, 22 Jan 2026 10:41:30 -0500 Subject: [PATCH 2/2] Improve cody pull: skip existing repos and add colorized output - Add ANSI color constants for terminal output - Skip repos that already exist (fast .git directory check) - Skip unsupported URL formats with informative message - Colorize output: gray for skipped, blue for cloning/success, red for failed --- main.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 5797c92..b1d50f8 100644 --- a/main.go +++ b/main.go @@ -127,6 +127,14 @@ func runAdd(cmd *cobra.Command, args []string) error { return nil } +// ANSI color codes +const ( + colorReset = "\033[0m" + colorGray = "\033[90m" + colorBlue = "\033[34m" + colorRed = "\033[31m" +) + func runPull(cmd *cobra.Command, args []string) error { // filter := args[0] urls, _ := collectAllCodyEntries() @@ -134,12 +142,24 @@ func runPull(cmd *cobra.Command, args []string) error { for _, url := range urls { dest := resolveCodyWorkspaceUrl(url) + if dest == "" { + fmt.Printf("%sSkipped (unsupported URL format): %s%s\n", colorGray, url, colorReset) + continue + } + + // Check if .git directory exists (fast local check) + gitDir := filepath.Join(dest, ".git") + if info, err := os.Stat(gitDir); err == nil && info.IsDir() { + fmt.Printf("%sSkipped (already exists): %s%s\n", colorGray, url, colorReset) + continue + } + + fmt.Printf("%sCloning: %s%s\n", colorBlue, url, colorReset) if _, _, err := executeShellCommand("git", "clone", url, dest); err != nil { - fmt.Printf("Clone failed: %s\n", url) + fmt.Printf("%sClone failed: %s%s\n", colorRed, url, colorReset) } else { - fmt.Println("Clone success: ", url, " to ", dest) + fmt.Printf("%sClone success: %s to %s%s\n", colorBlue, url, dest, colorReset) } - } return nil