@@ -40,10 +40,10 @@ gdel() {
40
40
41
41
__gdi_usage () {
42
42
echo " Git Delete Interactive -- SimGus 2020"
43
- echo " Usage: git_delete_interactive [-r] [<PARTIAL-BRANCH-NAME>]"
43
+ echo " Usage: git_delete_interactive [-l|- r] [<PARTIAL-BRANCH-NAME>]"
44
44
echo " \t<PARTIAL-BRANCH-NAME>\t\tA pattern to look for in the branches names (filters out other branches)"
45
- echo " \t-r , --include-remote-branches\tIf the command runs interactively, only takes into account the remote branches "
46
- echo " \t-a , --all\t\t\tIf the command runs interactively, take into account both the local and remote branches "
45
+ echo " \t-l , --local-only\tOnly allows to select and delete a local branch "
46
+ echo " \t-r , --remote-only\tOnly allows to select and delete a remote branch "
47
47
}
48
48
git_delete_interactive () {
49
49
echo " git delete interactive called with params $@ "
@@ -54,20 +54,28 @@ git_delete_interactive() {
54
54
else
55
55
__gi_check_dependencies
56
56
57
- branches=$( __gi_fetch_branches $@ )
58
- branch_selection_return_value=" $? "
59
-
60
- delete_remote_branch=false
57
+ only_remote_branch=false
58
+ only_local_branch=false
59
+ branch_list_arg=" "
61
60
for arg in " $@ "
62
61
do
63
62
shift
64
- if [ " $arg " = " -r" ] || [ " $arg " = " --remote-branch" ]
63
+ if [ " $arg " = " -r" ] || [ " $arg " = " --remote-only" ]
64
+ then
65
+ only_remote_branch=true
66
+ branch_list_arg=" -r"
67
+ continue
68
+ elif [ " $arg " = " -l" ] || [ " $arg " = " --local-only" ]
65
69
then
66
- delete_remote_branch=true
70
+ only_local_branch=true
71
+ continue
67
72
fi
68
73
set -- " $@ " " $arg "
69
74
done
70
75
76
+ branches=$( __gi_fetch_branches " $branch_list_arg " )
77
+ branch_selection_return_value=" $? "
78
+
71
79
if [ " $# " -gt 1 ]
72
80
then
73
81
echo " Too many arguments."
@@ -99,7 +107,7 @@ git_delete_interactive() {
99
107
echo " Selected branch: $selected_branch "
100
108
101
109
remote_branch_info=" $( __gdi_get_info_remote_branch $selected_branch ) "
102
- if [ -n " $remote_branch_info " ]
110
+ if [ -n " $remote_branch_info " ] && [ $only_local_branch = false ]
103
111
then
104
112
remote_branch_name=" $( echo $remote_branch_info | cut -d' ' -f1) "
105
113
up_to_date_with_remote=" $( echo $remote_branch_info | cut -d' ' -f2) "
0 commit comments