-
Notifications
You must be signed in to change notification settings - Fork 5
/
branch.sh
executable file
·75 lines (60 loc) · 1.62 KB
/
branch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
## /*
# @usage branch [options] [search-string]
#
# @description
# This is a handy tool to filter local and/or remote branch names in your repository.
# It leverages the __get_branch function to let the user choose a branch. For more
# information on that part of the process, @see functions/5000.get_branch.sh.
# description@
#
# @options
# -l, --local Show only local branches.
# -q, --quiet Do not show the informational message containing search query.
# -r, --remote Show only remote branches.
# options@
#
# @notes
# - Search string CANNOT begin with a hyphen!
# - Passing both options above will result in showing ALL branches as expected.
# notes@
#
# @examples
# 1) branch --local part-of-bran
# # filters local branches that match "part-of-bran"
# 2) branch -r
# # shows ALL remote branches
# examples@
#
# @dependencies
# *checkout.sh
# functions/5000.get_branch.sh
# dependencies@
#
# @file branch.sh
## */
$loadfuncs
echo ${X}
# send params through to __get_branch
echo ${O}${H2HL}
echo "Choose a branch to check out:"
echo ${O}${H2HL}${X}
echo
__get_branch $@
# if no selection was made or no branch could be found, exit.
if [ ! $_branch_selection ]; then
echo ${E}" Unable to acquire a branch name. Aborting... "${X}
exit 1
fi
echo
echo "Will now ${A}checkout${X} ${B}\`${_branch_selection}\` ${X}"
"${gitscripts_path}"checkout.sh "$_branch_selection"
# prompt to checkout branch
# echo
# echo ${Q}" ${A}Checkout${X} ${B}\`${_branch_selection}\`${Q}? y (n) "${X}
# read yn
# if [ "$yn" = "y" ] || [ "$yn" = "Y" ]; then
# echo
# "${gitscripts_path}"checkout.sh "$_branch_selection"
# fi
exit