-
Notifications
You must be signed in to change notification settings - Fork 5
/
contains.sh
executable file
·74 lines (62 loc) · 1.69 KB
/
contains.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
#!/bin/bash
## /*
# @usage contains [--not] <branch-name>
#
# @description
# Checks to see which other branches the branch you specify has merged into it. If
# no branch is specified, the current branch is used.
# description@
#
# @options
# --not Pass this option to view a list of all branches which do NOT contain
# the specified (or current) branch.
# options@
#
# @examples
# 1) contains --not my-branch
# # will display all branches that don't contain my-branch
# 2) contains
# # will display all branches which contain the current branch
# examples@
#
# @dependencies
# functions/5000.branch_exists_local.sh
# functions/5000.parse_git_branch.sh
# dependencies@
#
# @file contains.sh
## */
$loadfuncs
echo ${X}
# parse args
until [ -z "$1" ]; do
[ "$1" = "--not" ] && isNot=true && frag=" do NOT"
[ "$1" != "--not" ] && branch="$1"
shift 1
done
if [ -z "$branch" ]; then
#use current branch if none specified
branch=$(__parse_git_branch)
elif ! __branch_exists_local "$branch"; then
echo ${E}" The branch \`${branch}\` does not exist locally. Aborting... "${X}
exit 1
fi
echo ${H1}${H1HL}
echo " Searching for branches which${frag} contain: ${H1B}\`${branch}\`${H1} "
echo ${H1HL}${X}
echo
echo
if [ $isNot ]; then
echo "The following branches ${COL_RED}DO NOT${COL_NORM} contain the latest version of ${B}\`${branch}\`${X}:"
echo ${O}${H2HL}${X}
for br in `git branch | sed 's/\*//'`; do
git branch --contains "${branch}" | grep -q "$br" || echo "${COL_RED}${br}${COL_NORM}"
done
echo ${O}${H2HL}${X}
else
echo "The following branches contain the latest version of ${B}\`${branch}\`${X}:"
echo ${O}${H2HL}${X}
git branch --contains "$branch"
echo ${O}${H2HL}${X}
fi
exit