Skip to content

Commit 5f05d97

Browse files
authored
Merge pull request #4 from SangwoonYun/feat/auto-update
fix: Remove the duplicated code
2 parents 897b27c + 4ec5fe6 commit 5f05d97

File tree

1 file changed

+0
-39
lines changed

1 file changed

+0
-39
lines changed

zsh-auto-venv.plugin.zsh

-39
Original file line numberDiff line numberDiff line change
@@ -44,45 +44,6 @@ auto_venv_update_check() {
4444
# Call the update check function when the plugin loads
4545
auto_venv_update_check
4646

47-
# Plugin update check function
48-
auto_venv_update_check() {
49-
local remote_tag local_tag repo_path user_input
50-
repo_path="${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/auto-venv"
51-
52-
# Ensure git is available
53-
if ! command -v git &> /dev/null; then
54-
echo "Git is not installed. Cannot check for plugin updates."
55-
return
56-
fi
57-
58-
# Fetch the latest tags from the remote
59-
git -C "$repo_path" fetch --tags
60-
61-
# Get the latest tag name from the remote and local
62-
remote_tag=$(git -C "$repo_path" describe --tags `git -C "$repo_path" rev-list --tags --max-count=1`)
63-
local_tag=$(git -C "$repo_path" describe --tags)
64-
65-
# Check if the latest tag matches the currently checked-out version
66-
if [ "$remote_tag" != "$local_tag" ]; then
67-
echo "New version available for auto-venv: $remote_tag (current version: $local_tag)"
68-
echo -n "Do you want to update the plugin now? [Y/n] "
69-
read user_input
70-
71-
if [[ "$user_input" = "Y" || "$user_input" = "y" || "$user_input" = "" ]]; then
72-
echo "Updating auto-venv plugin from $local_tag to $remote_tag..."
73-
git -C "$repo_path" checkout "$remote_tag"
74-
else
75-
echo "Update aborted. You can manually update later by running:"
76-
echo "git -C $repo_path checkout $remote_tag"
77-
fi
78-
else
79-
echo "auto-venv plugin is up to date."
80-
fi
81-
}
82-
83-
# Call the update check function when the plugin loads
84-
auto_venv_update_check
85-
8647
# autoload is used to load the add-zsh-hook function.
8748
autoload -U add-zsh-hook
8849

0 commit comments

Comments
 (0)