Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitflow
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tools
gitflow
Commits
d3bc7602
Commit
d3bc7602
authored
Jan 29, 2010
by
Vincent Driessen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/allow-prefixes-as-name-arg-on-finish' into develop
parents
7ae320bf
1ee37e72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
6 deletions
+48
-6
git-flow-feature
git-flow-feature
+48
-6
No files found.
git-flow-feature
View file @
d3bc7602
...
@@ -18,10 +18,10 @@ FLAG_FETCH=0
...
@@ -18,10 +18,10 @@ FLAG_FETCH=0
usage() {
usage() {
echo "usage: git flow feature [list]"
echo "usage: git flow feature [list]"
echo " git flow feature start <name> [<base>]"
echo " git flow feature start <name> [<base>]"
echo " git flow feature finish <name> [<base>]"
echo " git flow feature finish <name
|nameprefix
> [<base>]"
echo " git flow feature publish <name>"
echo " git flow feature publish <name>"
echo " git flow feature track <name>"
echo " git flow feature track <name>"
echo " git flow feature diff <name>"
echo " git flow feature diff <name
|nameprefix
>"
# TODO
# TODO
#echo ""
#echo ""
#echo "options:"
#echo "options:"
...
@@ -55,12 +55,44 @@ cmd_help() {
...
@@ -55,12 +55,44 @@ cmd_help() {
exit 0
exit 0
}
}
parse_args() {
resolve_name_by_prefix() {
# first, check if there is a perfect match
if has "$LOCAL_BRANCHES" "$PREFIX$1"; then
echo "$1"
return 0
fi
MATCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX$1")"
NUM_MATCHES=$(echo "$MATCHES" | wc -l)
if [ $NUM_MATCHES -eq 1 ]; then
# sed arg looks a bit weird, but $PREFIX should not contain spaces,
# so this one is safe
echo "$MATCHES" | sed "s $PREFIX g"
elif [ $NUM_MATCHES -eq 0 ]; then
# no prefix match, so take it literally
echo "$1"
else
# multiple matches, cannot decide
warn "Multiple branches match for prefix '$1':"
for match in $MATCHES; do
warn "- $match"
done
die "Aborting. Use an unambiguous prefix."
fi
}
get_name_by_prefix() {
NAME=$(resolve_name_by_prefix "$1")
if [ -z "$NAME" ]; then
exit 1
fi
}
parse_args_common() {
# TODO: When we have a nice structured way of parsing flags with getopt,
# TODO: When we have a nice structured way of parsing flags with getopt,
# implement the following flags:
# implement the following flags:
# --fetch, to set FLAG_FETCH=1
# --fetch, to set FLAG_FETCH=1
# --no-fetch, to set FLAG_FETCH=0
# --no-fetch, to set FLAG_FETCH=0
NAME="$1"
BASE="${2:-$DEVELOP_BRANCH}"
BASE="${2:-$DEVELOP_BRANCH}"
if [ "$NAME" = "" ]; then
if [ "$NAME" = "" ]; then
echo "Missing argument <name>."
echo "Missing argument <name>."
...
@@ -70,6 +102,16 @@ parse_args() {
...
@@ -70,6 +102,16 @@ parse_args() {
BRANCH=$PREFIX$NAME
BRANCH=$PREFIX$NAME
}
}
parse_args_with_name_prefix() {
get_name_by_prefix "$1"
parse_args_common
}
parse_args() {
NAME="$1"
parse_args_common
}
cmd_start() {
cmd_start() {
parse_args "$@"
parse_args "$@"
...
@@ -99,7 +141,7 @@ cmd_start() {
...
@@ -99,7 +141,7 @@ cmd_start() {
}
}
cmd_finish() {
cmd_finish() {
parse_args "$@"
parse_args
_with_name_prefix
"$@"
# sanity checks
# sanity checks
gitflow_require_branch $BRANCH
gitflow_require_branch $BRANCH
...
@@ -251,7 +293,7 @@ cmd_track() {
...
@@ -251,7 +293,7 @@ cmd_track() {
}
}
cmd_diff() {
cmd_diff() {
parse_args "$@"
parse_args
_with_name_prefix
"$@"
# TODO: if this feature has been based on a non-develop branch, we really
# TODO: if this feature has been based on a non-develop branch, we really
# should not be comparing to $DEVELOP. How to deal with this?
# should not be comparing to $DEVELOP. How to deal with this?
git diff $DEVELOP_BRANCH..$BRANCH
git diff $DEVELOP_BRANCH..$BRANCH
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment