Skip to content

Commit 06352f3

Browse files
committed
fix: handle failed git clone operation
- Add error handling for git clone command - Display error message if clone fails - Ensure consistent behavior when cloning fails
1 parent 4c08bc0 commit 06352f3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gitcd.plugin.zsh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ gitcd() {
2727
return
2828
}
2929

30-
git clone $url $target && cd $target
30+
if ! git clone $url $target; then
31+
print -P "%B%F{red}[gitcd] Failed to clone the repository. Please check your URL and try again."
32+
return
33+
fi
34+
cd $target
3135
# Display in green and bold
3236
print -P "%B%F{green}[gitcd] Done. Have a great day!"
3337
}

0 commit comments

Comments
 (0)