@san-siva/gitsy 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/g-cb +47 -0
  4. package/g-co +106 -0
  5. package/g-db +122 -0
  6. package/g-diff +228 -0
  7. package/g-dlc +109 -0
  8. package/g-pull +72 -0
  9. package/g-push +67 -0
  10. package/g-rmf +57 -0
  11. package/g-rto +50 -0
  12. package/g-s +50 -0
  13. package/g-wa +155 -0
  14. package/g-wr +260 -0
  15. package/package.json +70 -0
  16. package/utils +464 -0
package/g-pull ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Author: Santhosh Siva
4
+ # Date Created: 03-08-2025
5
+
6
+ # Description:
7
+ # A script to checkout branches, optionally stash changes, and manage git workflow efficiently.
8
+
9
+ source "$(dirname "${BASH_SOURCE[0]}")/utils"
10
+
11
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+
13
+ target_branch=
14
+ do_fetch=false
15
+
16
+ set_flags() {
17
+ while [ $# -gt 0 ]; do
18
+ case "$1" in
19
+ -h | --help)
20
+ echo "g-pull - pull changes from remote branch"
21
+ echo " "
22
+ echo "g-pull [options]"
23
+ echo " "
24
+ echo "options:"
25
+ echo "-h, --help show brief help"
26
+ echo "--target-branch BRANCH, --target-branch=BRANCH, -t=BRANCH, -t BRANCH specify the target branch"
27
+ echo "--stash-changes stash changes before proceeding"
28
+ echo "-f, --fetch fetch changes before pulling"
29
+ exit 0
30
+ ;;
31
+ -t=* | --target-branch=*)
32
+ target_branch="${1#*=}"
33
+ if [ -z "$target_branch" ]; then
34
+ echo "${RED}Error: No target branch specified.$NC"
35
+ exit 1
36
+ fi
37
+ ;;
38
+ -t | --target-branch)
39
+ shift
40
+ if [ $# -gt 0 ]; then
41
+ target_branch="$1"
42
+ else
43
+ echo "${RED}Error: No target branch specified.$NC"
44
+ exit 1
45
+ fi
46
+ ;;
47
+ -f | --fetch)
48
+ do_fetch=true
49
+ ;;
50
+ esac
51
+ shift
52
+ done
53
+ }
54
+
55
+ main() {
56
+ set_flags "$@"
57
+ validate_dependencies
58
+ print_banner
59
+ if [ -z "$target_branch" ]; then
60
+ target_branch=$(fetch_current_branch)
61
+ fi
62
+ if [ "$do_fetch" = "true" ]; then
63
+ print_message "${BLUE}Fetching changes...${NC}" 1
64
+ fetch_changes "$target_branch"
65
+ pull_changes "$target_branch" 2
66
+ exit 0
67
+ fi
68
+ pull_changes "$target_branch" 1
69
+ }
70
+
71
+ main "$@"
72
+ exit 0
package/g-push ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Author: Santhosh Siva
4
+ # Date Created: 03-08-2025
5
+
6
+ # Description:
7
+ # A script to checkout branches, optionally stash changes, and manage git workflow efficiently.
8
+
9
+ source "$(dirname "${BASH_SOURCE[0]}")/utils"
10
+
11
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+
13
+ target_branch=
14
+ should_force_push=false
15
+
16
+ set_flags() {
17
+ while [ $# -gt 0 ]; do
18
+ case "$1" in
19
+ -h | --help)
20
+ echo "g-push - push changes to remote branch"
21
+ echo " "
22
+ echo "g-push [options]"
23
+ echo " "
24
+ echo "options:"
25
+ echo "-h, --help show brief help"
26
+ echo "--target-branch BRANCH, --target-branch=BRANCH, -t=BRANCH, -t BRANCH specify the target branch"
27
+ echo "--stash-changes stash changes before proceeding"
28
+ echo "--force force push changes to the target branch"
29
+ exit 0
30
+ ;;
31
+ -t=* | --target-branch=*)
32
+ target_branch="${1#*=}"
33
+ if [ -z "$target_branch" ]; then
34
+ echo "${RED}Error: No target branch specified.$NC"
35
+ exit 1
36
+ fi
37
+ ;;
38
+ -t | --target-branch)
39
+ shift
40
+ if [ $# -gt 0 ]; then
41
+ target_branch="$1"
42
+ else
43
+ echo "${RED}Error: No target branch specified.$NC"
44
+ exit 1
45
+ fi
46
+ ;;
47
+ -f | --force)
48
+ should_force_push=true
49
+ ;;
50
+ esac
51
+ shift
52
+ done
53
+ }
54
+
55
+ main() {
56
+ set_flags "$@"
57
+ validate_dependencies
58
+ print_banner
59
+ if [ -z "$target_branch" ]; then
60
+ push_changes $(fetch_current_branch) $should_force_push 1
61
+ exit 0
62
+ fi
63
+ push_changes "$target_branch" $should_force_push 1
64
+ }
65
+
66
+ main "$@"
67
+ exit 0
package/g-rmf ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Author: Santhosh Siva
4
+ # Date Created: 03-08-2025
5
+
6
+ # Description:
7
+ # A script to clear your working directory by stashing changes.
8
+ # The stashed changes is tagged with the current date and time.
9
+
10
+ source "$(dirname "${BASH_SOURCE[0]}")/utils"
11
+
12
+ # Default Values
13
+ tag_message=
14
+
15
+ set_flags() {
16
+ while [ $# -gt 0 ]; do
17
+ case "$1" in
18
+ -h | --help)
19
+ echo "g-rmf - clear your working directory by stashing changes"
20
+ echo " "
21
+ echo "g-rmf [options]"
22
+ echo " "
23
+ echo "options:"
24
+ echo "-h, --help show brief help"
25
+ echo "--message MESSAGE, --message=MESSAGE, -m=MESSAGE, -m MESSAGE specify custom message for stash"
26
+ exit 0
27
+ ;;
28
+ -m=* | --message=*)
29
+ tag_message="${1#*=}"
30
+ ;;
31
+ -m | --message)
32
+ shift
33
+ if [ $# -gt 0 ]; then
34
+ tag_message="$1"
35
+ else
36
+ echo "${RED}Error: No message specified.$NC"
37
+ exit 1
38
+ fi
39
+ ;;
40
+ *)
41
+ echo "${RED}Unknown option:${NC} $1"
42
+ exit
43
+ ;;
44
+ esac
45
+ shift
46
+ done
47
+ }
48
+
49
+ main() {
50
+ set_flags "$@"
51
+ validate_dependencies git figlet lolcat
52
+ print_banner
53
+ stash_changes true 1 "$tag_message"
54
+ }
55
+
56
+ main "$@"
57
+ exit 0
package/g-rto ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Author: Santhosh Siva
4
+ # Date Created: 03-08-2025
5
+
6
+ # Description:
7
+ # A script to quickly reset your working directory to the latest changes from the remote branch.
8
+ # In case you ran this command by mistake, you can use the `git stash apply` command to restore your changes.
9
+
10
+ source "$(dirname "${BASH_SOURCE[0]}")/utils"
11
+
12
+ set_flags() {
13
+ while [ $# -gt 0 ]; do
14
+ case "$1" in
15
+ -h | --help)
16
+ echo "g-rto - reset to remote branch"
17
+ echo " "
18
+ echo "g-rto [options]"
19
+ echo " "
20
+ echo "options:"
21
+ echo "-h, --help show brief help"
22
+ exit 0
23
+ ;;
24
+ *)
25
+ echo "${RED}Unknown option:${NC} $1"
26
+ exit 1
27
+ ;;
28
+ esac
29
+ shift
30
+ done
31
+ }
32
+
33
+ main() {
34
+ set_flags "$@"
35
+ validate_dependencies git figlet lolcat
36
+ print_banner
37
+ target_branch=$(fetch_current_branch)
38
+ stash_changes true 1
39
+ print_message ""
40
+
41
+ print_message "${BLUE}Fetching changes from remote/${target_branch}...${NC}" 2
42
+ fetch_changes "$target_branch"
43
+ print_message ""
44
+
45
+ reset_to_target_branch "$target_branch" 3
46
+ pull_changes "$target_branch" 4
47
+ }
48
+
49
+ main "$@"
50
+ exit 0
package/g-s ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Author: Santhosh Siva
4
+ # Date Created: 03-08-2025
5
+
6
+ # Description:
7
+ # This script returns the current status of the git repository.
8
+
9
+ source "$(dirname "${BASH_SOURCE[0]}")/utils"
10
+
11
+ set_flags() {
12
+ while [ $# -gt 0 ]; do
13
+ case "$1" in
14
+ -h | --help)
15
+ echo "g-s - show git status"
16
+ echo " "
17
+ echo "g-s [options]"
18
+ echo " "
19
+ echo "options:"
20
+ echo "-h, --help show brief help"
21
+ exit 0
22
+ ;;
23
+ *)
24
+ echo "${RED}Unknown option:${NC} $1"
25
+ exit 1
26
+ ;;
27
+ esac
28
+ shift
29
+ done
30
+ }
31
+
32
+ main() {
33
+ set_flags "$@"
34
+ validate_dependencies git figlet lolcat
35
+ print_banner
36
+ print_message "${BLUE}Fetching git status...${NC}" 1
37
+
38
+ current_branch=$(fetch_current_branch)
39
+
40
+ if ! git -c color.ui=always status 2>&1 | indent; then
41
+ print_message "${PROMPT}Failed to get git status. Are you in a git repository?${NC}"
42
+ return 1
43
+ else
44
+ print_message "${GREEN}Git status fetched successfully.${NC}" 0
45
+ return 0
46
+ fi
47
+ }
48
+
49
+ main "$@"
50
+ exit 0
package/g-wa ADDED
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Author: Santhosh Siva
4
+ # Date Created: 03-08-2025
5
+
6
+ # Description:
7
+ # This script creates a new git worktree for a specified branch.
8
+ # If the branch does not exist, it prompts the user to create it.
9
+
10
+ source "$(dirname "${BASH_SOURCE[0]}")/utils"
11
+
12
+ # Default Values
13
+ stash=false
14
+ target_branch=
15
+
16
+ set_flags() {
17
+ while [ $# -gt 0 ]; do
18
+ case "$1" in
19
+ -h | --help)
20
+ echo "g-wa - create git worktree for branch"
21
+ echo " "
22
+ echo "g-wa [options]"
23
+ echo " "
24
+ echo "options:"
25
+ echo "-h, --help show brief help"
26
+ echo "--target-branch BRANCH, --target-branch=BRANCH, -t=BRANCH, -t BRANCH specify the target branch"
27
+ echo "--stash-changes stash changes before proceeding"
28
+ exit 0
29
+ ;;
30
+ -t=* | --target-branch=*)
31
+ target_branch="${1#*=}"
32
+ if [ -z "$target_branch" ]; then
33
+ echo "${RED}Error: No target branch specified.$NC"
34
+ exit 1
35
+ fi
36
+ ;;
37
+ -t | --target-branch)
38
+ shift
39
+ if [ $# -gt 0 ]; then
40
+ target_branch="$1"
41
+ else
42
+ echo "${RED}Error: No target branch specified.$NC"
43
+ exit 1
44
+ fi
45
+ ;;
46
+ -s | --stash-changes)
47
+ stash=true
48
+ ;;
49
+ *)
50
+ echo "${RED}Unknown option:${NC} $1"
51
+ exit
52
+ ;;
53
+ esac
54
+ shift
55
+ done
56
+ }
57
+
58
+ try_fetching_branch() {
59
+ fetch_success=$(fetch_changes "${target_branch}")
60
+ if [ "${fetch_success}" = "false" ]; then
61
+ print_message "${RED}Failed to fetch changes for branch ${target_branch}. [Fail]${NC}" exit 1
62
+ fi
63
+ }
64
+
65
+ checkout_or_create_branch() {
66
+ local step_number=2
67
+ if [ "${stash}" = true ]; then
68
+ step_number=3
69
+ fi
70
+
71
+ # Check if branch is already checked out in another worktree
72
+ local existing_worktree=$(git worktree list | grep "\[${target_branch}\]" | awk '{print $1}')
73
+ if [ -n "$existing_worktree" ]; then
74
+ print_message "${RED}Branch ${NC}${target_branch}${RED} is already checked out in worktree:${NC}" $step_number
75
+ print_message "${GREEN}${existing_worktree}${NC}"
76
+ print_message "${BLUE}Navigate to it with:${NC} ${GREEN}cd ${existing_worktree}${NC}"
77
+ exit 0
78
+ fi
79
+
80
+ # Determine worktree directory based on current location
81
+ local worktree_dir
82
+ local current_dir=$(basename "$PWD")
83
+ local parent_dir=$(basename "$(dirname "$PWD")")
84
+
85
+ # Check if we're already in a worktree (parent directory contains worktrees)
86
+ if [ "$parent_dir" = "worktrees" ]; then
87
+ # We're in a worktree, use parent of parent for new worktrees
88
+ worktree_dir="../"
89
+ else
90
+ # We're in main repo, create worktrees subdirectory
91
+ if [ ! -d "../worktrees" ]; then
92
+ mkdir ../worktrees
93
+ fi
94
+ worktree_dir="../worktrees/"
95
+ fi
96
+
97
+ # if target_branch length is more than 20 characters, truncate it to 20 characters
98
+ local worktree_name=$(echo $target_branch | sed -E 's/[^[:alnum:]]/_/g' | tr '[:upper:]' '[:lower:]')
99
+
100
+ if [ ${#target_branch} -gt 30 ]; then
101
+ worktree_name="${worktree_name:0:30}.."
102
+ fi
103
+
104
+ local path="${worktree_dir}${worktree_name}"
105
+
106
+ print_message "${BLUE}Creating worktree for branch ${NC}origin/${target_branch} ${BLUE}at${NC} ${path} ${BLUE}${NC}" $step_number
107
+
108
+ if [ -d "$path" ]; then
109
+ print_message "${RED}Worktree path already exists. [Fail]${NC}"
110
+ no_of_identical_dirs=$(find "${worktree_dir}" -maxdepth 1 -type d -name "${worktree_name}*" 2>/dev/null | wc -l)
111
+ path="${worktree_dir}${worktree_name}_$(($no_of_identical_dirs + 1))"
112
+ print_message "${BLUE}Using new path: ${NC}${path}${BLUE}${NC}"
113
+ fi
114
+
115
+ # Check if branch exists locally
116
+ if git show-ref --verify --quiet "refs/heads/${target_branch}"; then
117
+ try_fetching_branch
118
+ create_worktree "${target_branch}" "${path}"
119
+ return
120
+ fi
121
+
122
+ print_message "${RED}Branch not found locally.${NC}"
123
+ print_message "${BLUE}Checking if branch exists on remote...${NC}" $((step_number + 1))
124
+
125
+ if git ls-remote --heads origin "${target_branch}" | grep -q "${target_branch}"; then
126
+ print_message "${GREEN}Branch available on remote.${NC}"
127
+ try_fetching_branch
128
+ create_worktree "${target_branch}" "${path}"
129
+ return
130
+ fi
131
+
132
+ print_message "${RED}Branch not found on remote.${NC}"
133
+
134
+ create_new_branch=$(prompt_user true "Create new branch?" $((step_number + 1)))
135
+ if [ "${create_new_branch}" = "y" ]; then
136
+ create_worktree "${target_branch}" "${path}" true
137
+ return
138
+ fi
139
+
140
+ print_message "${RED}Aborted.${NC}"
141
+ exit 1
142
+ }
143
+
144
+ main() {
145
+ set_flags "$@"
146
+ validate_dependencies git figlet lolcat
147
+ print_banner
148
+ check_if_target_branch_is_set $target_branch
149
+ already_on_branch $target_branch
150
+ stash_changes $stash 2
151
+ checkout_or_create_branch
152
+ }
153
+
154
+ main "$@"
155
+ exit 0
package/g-wr ADDED
@@ -0,0 +1,260 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Author: Santhosh Siva
4
+ # Date Created: 12-02-2025
5
+
6
+ # Description:
7
+ # This script removes a git worktree for a specified branch.
8
+ # It searches through the worktrees directory and removes matching worktrees.
9
+
10
+ source "$(dirname "${BASH_SOURCE[0]}")/utils"
11
+
12
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
+
14
+ # Default Values
15
+ target_branch=
16
+ worktree_name=
17
+
18
+ set_flags() {
19
+ while [ $# -gt 0 ]; do
20
+ case "$1" in
21
+ -h | --help)
22
+ echo "g-wr - remove a git worktree for a specified branch or name"
23
+ echo " "
24
+ echo "g-wr [options]"
25
+ echo " "
26
+ echo "options:"
27
+ echo "-h, --help show brief help"
28
+ echo "--target-branch BRANCH, --target-branch=BRANCH, -t=BRANCH, -t BRANCH specify the target branch"
29
+ echo "--worktree-name NAME, --worktree-name=NAME, -w=NAME, -w NAME specify the worktree directory name"
30
+ exit 0
31
+ ;;
32
+ -t=* | --target-branch=*)
33
+ target_branch="${1#*=}"
34
+ if [ -z "$target_branch" ]; then
35
+ echo "${RED}Error: No target branch specified.$NC"
36
+ exit 1
37
+ fi
38
+ ;;
39
+ -t | --target-branch)
40
+ shift
41
+ if [ $# -gt 0 ]; then
42
+ target_branch="$1"
43
+ else
44
+ echo "${RED}Error: No target branch specified.$NC"
45
+ exit 1
46
+ fi
47
+ ;;
48
+ -w=* | --worktree-name=*)
49
+ worktree_name="${1#*=}"
50
+ if [ -z "$worktree_name" ]; then
51
+ echo "${RED}Error: No worktree name specified.$NC"
52
+ exit 1
53
+ fi
54
+ ;;
55
+ -w | --worktree-name)
56
+ shift
57
+ if [ $# -gt 0 ]; then
58
+ worktree_name="$1"
59
+ else
60
+ echo "${RED}Error: No worktree name specified.$NC"
61
+ exit 1
62
+ fi
63
+ ;;
64
+ *)
65
+ echo "${RED}Unknown option:${NC} $1"
66
+ exit 1
67
+ ;;
68
+ esac
69
+ shift
70
+ done
71
+ }
72
+
73
+ cd_to_main_dir() {
74
+ local current_dirname=$(basename "$current_dir")
75
+ if [ "$current_dirname" = "main" ]; then
76
+ return 0
77
+ fi
78
+
79
+ if [ -d "../main" ]; then
80
+ if navigate_to_dir "../main"; then
81
+ return 0
82
+ fi
83
+ fi
84
+
85
+ if [ -d "../../main" ]; then
86
+ if navigate_to_dir "../../main"; then
87
+ return 0
88
+ fi
89
+ fi
90
+
91
+ exit 1
92
+ }
93
+
94
+ cd_to_worktrees_dir() {
95
+ local current_dirname=$(basename "$current_dir")
96
+ if [ "$current_dirname" = "worktrees" ]; then
97
+ return 0
98
+ fi
99
+
100
+ if [ -d "../worktrees" ]; then
101
+ if navigate_to_dir "../worktrees"; then
102
+ return 0
103
+ fi
104
+ fi
105
+
106
+ if [ -d "../../worktrees" ]; then
107
+ if navigate_to_dir "../../worktrees"; then
108
+ return 0
109
+ fi
110
+ fi
111
+
112
+ print_message "${RED}Worktrees directory not found. [Fail]${NC}" 0 >&2
113
+ exit 1
114
+ }
115
+
116
+ find_dir_to_remove() {
117
+ local current_dir=$(pwd)
118
+
119
+ cd_to_worktrees_dir
120
+ local worktrees_dir=$(pwd)
121
+
122
+ worktree_path=""
123
+
124
+ if [ -n "$worktree_name" ]; then
125
+ for dir in *; do
126
+ if [ ! -d "$dir" ]; then
127
+ continue
128
+ fi
129
+
130
+ if [ "$dir" = "$worktree_name" ]; then
131
+ worktree_path="$worktrees_dir/$dir"
132
+ break
133
+ fi
134
+ done
135
+ cd_to_main_dir
136
+ if [ -z "$worktree_path" ]; then
137
+ return 1
138
+ fi
139
+ echo "$worktree_path"
140
+ return 0
141
+ fi
142
+
143
+ check_if_target_branch_is_set "$target_branch"
144
+
145
+ for dir in *; do
146
+ if [ ! -d "$dir" ]; then
147
+ continue
148
+ fi
149
+
150
+ if ! navigate_to_dir "$dir"; then
151
+ continue
152
+ fi
153
+
154
+ local branch=$(fetch_current_branch 2>/dev/null)
155
+ if [ -z "$branch" ]; then
156
+ navigate_to_dir "$worktrees_dir"
157
+ continue
158
+ fi
159
+
160
+ if [ "$branch" = "$target_branch" ]; then
161
+ worktree_path="$worktrees_dir/$dir"
162
+ break
163
+ fi
164
+
165
+ navigate_to_dir "$worktrees_dir"
166
+ done
167
+
168
+ cd_to_main_dir
169
+
170
+ if [ -z "$worktree_path" ]; then
171
+ return 1
172
+ fi
173
+
174
+ echo "$worktree_path"
175
+ }
176
+
177
+ check_if_worktree_is_clean() {
178
+ local worktree_path=$1
179
+
180
+ if ! has_uncommitted_changes "$worktree_path"; then
181
+ return 0
182
+ fi
183
+
184
+ response=$(prompt_user "false" "Your worktree has uncommitted changes. Do you want to discard them?" 3)
185
+ if [ "$response" = "n" ]; then
186
+ print_message "${RED}Skipping worktree removal.${NC}" 0
187
+ exit 0
188
+ fi
189
+ }
190
+
191
+ remove_worktree() {
192
+ local worktree_path=$1
193
+
194
+ print_message "${BLUE}Removing worktree at ${NC}${worktree_path}${BLUE}...${NC}" 4
195
+
196
+ if ! [ -n "$worktree_name" ]; then
197
+ # Try using git worktree remove first with --force flag
198
+ if git -c color.ui=always worktree remove --force "$worktree_path" 2>&1 | indent; then
199
+ # Verify the directory was actually removed
200
+ if [ ! -d "$worktree_path" ]; then
201
+ print_message "${GREEN}Worktree removed successfully using git.${NC}" 0
202
+ return 0
203
+ fi
204
+ fi
205
+ print_message "${PROMPT}Git worktree remove incomplete. Attempting manual removal...${NC}" 0
206
+ fi
207
+
208
+ # Fallback to rm -rf
209
+ if rm -rf "$worktree_path" 2>&1 | indent; then
210
+ if ! [ -n "$worktree_name" ]; then
211
+ # Also need to prune the worktree from git's records
212
+ git -c color.ui=always worktree prune 2>&1 | indent
213
+ fi
214
+ # Verify the directory was actually removed
215
+ if [ ! -d "$worktree_path" ]; then
216
+ print_message "${GREEN}Worktree removed successfully using rm -rf.${NC}" 0
217
+ return 0
218
+ fi
219
+ fi
220
+
221
+ print_message "${RED}Failed to remove worktree. [Fail]${NC}" 0
222
+ return 1
223
+ }
224
+
225
+ main() {
226
+ set_flags "$@"
227
+ validate_dependencies git figlet lolcat
228
+ print_banner
229
+
230
+ if [ -n "$worktree_name" ]; then
231
+ print_message "${BLUE}Searching for worktree with name ${NC}${worktree_name}${BLUE}...${NC}" 1
232
+ else
233
+ print_message "${BLUE}Searching for worktree with branch ${NC}${target_branch}${BLUE}...${NC}" 1
234
+ fi
235
+
236
+ worktree_path=$(find_dir_to_remove)
237
+ if [ -z "$worktree_path" ]; then
238
+ if [ -n "$worktree_name" ]; then
239
+ print_message "${RED}No worktree found with name ${NC}${worktree_name}${RED}. [Fail]${NC}" 0
240
+ else
241
+ print_message "${RED}No worktree found for branch ${NC}${target_branch}${RED}. [Fail]${NC}" 0
242
+ fi
243
+ exit 1
244
+ fi
245
+
246
+ worktree_dirname=$(basename "$worktree_path")
247
+ if [ -n "$worktree_name" ]; then
248
+ print_message "${GREEN}Found worktree: ${NC}${worktree_dirname}${NC}" 2
249
+ else
250
+ print_message "${GREEN}Found worktree: ${NC}${worktree_dirname}${GREEN} at ${NC}${worktree_path}${NC}" 2
251
+ fi
252
+
253
+ print_message "${BLUE}Checking for uncommitted changes...${NC}" 3
254
+ check_if_worktree_is_clean "$worktree_path"
255
+
256
+ remove_worktree "$worktree_path"
257
+ }
258
+
259
+ main "$@"
260
+ exit 0