-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-bpf
More file actions
executable file
·119 lines (103 loc) · 3.72 KB
/
git-bpf
File metadata and controls
executable file
·119 lines (103 loc) · 3.72 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh
#
# git-bpf -- A collection of Git extensions to provide high-level
# repository operations for Git Branch Per Feature (BPF) workflow.
#
# This project is an implementation of the Git BPF workflow
# described by Adam Dymitruk:
# http://dymitruk.com/blog/2012/02/05/branch-per-feature/
# And its source code is wildly inspired by gitflow tools source code:
# https://github.com/nvie/gitflow
#
# Feel free to contribute to this project at:
# https://github.com/cdue/gitbpf
#
# Copyright (c) 2015 Cédric Dué
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE
#
# set this to workaround expr problems in shFlags on freebsd
if uname -s | egrep -iq 'bsd'; then export EXPR_COMPAT=1; fi
# enable debug mode
if [ "$DEBUG" = "yes" ]; then
set -x
fi
# The sed expression here replaces all backslashes by forward slashes.
# This helps our Windows users, while not bothering our Unix users.
export GITBPF_DIR=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
usage() {
echo "usage: git bpf <subcommand>"
echo
echo "Available subcommands are:"
echo " init Initialize a new git repo with support for the BPF branching model."
echo " feature Manage your feature branches."
echo " release Manage your release branches."
echo " hotfix Manage your hotfix branches."
echo " version Shows version information."
echo " rerere Manage rerere sharing (for conflicts auto-resolution)."
echo
echo "Try 'git bpf <subcommand> help' for details."
}
main() {
if [ $# -lt 1 ]; then
usage
exit 1
fi
# load common functionality
. "$GITBPF_DIR/gitbpf-common"
# This environmental variable fixes non-POSIX getopt style argument
# parsing, effectively breaking git-bpf subcommand parsing on several
# Linux platforms.
export POSIXLY_CORRECT=1
# use the shFlags project to parse the command line arguments
. "$GITBPF_DIR/gitbpf-shFlags"
FLAGS_PARENT="git bpf"
# allow user to request git action logging
DEFINE_boolean show_commands false 'show actions taken (git commands)' g
# do actual parsing
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"
# sanity checks
SUBCOMMAND="$1"; shift
if [ ! -e "$GITBPF_DIR/git-bpf-$SUBCOMMAND" ]; then
usage
exit 1
fi
# run command
. "$GITBPF_DIR/git-bpf-$SUBCOMMAND"
FLAGS_PARENT="git bpf $SUBCOMMAND"
# test if the first argument is a flag (i.e. starts with '-')
# in that case, we interpret this arg as a flag for the default
# command
SUBACTION="default"
if [ "$1" != "" ] && { ! echo "$1" | grep -q "^-"; } then
SUBACTION="$1"; shift
fi
if ! type "cmd_$SUBACTION" >/dev/null 2>&1; then
warn "Unknown subcommand: '$SUBACTION'"
usage
exit 1
fi
# run the specified action
if [ $SUBACTION != "help" ] && [ $SUBCOMMAND != "init" ] ; then
init
fi
cmd_$SUBACTION "$@"
}
main "$@"