Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Sets up the `gh-pages` branch. (See [GitHub Pages](http://pages.github.com/) do

## git feature|refactor|bug|chore

Create the given feature, refactor, bug or chore branch `name`:
Create/Merge the given feature, refactor, bug or chore branch `name`:

```bash
$ git feature dependencies
Expand Down
45 changes: 31 additions & 14 deletions bin/git-feature
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
#!/usr/bin/env bash

branch_prefix=feature
declare -a argv
while test $# != 0
do
case $1 in
-a|--alias )
if [[ -n $2 ]]
then
shift # shift -a|-alias
branch_prefix=$1
else
argv+=($1) # treat tail '-a' as <name>
fi
;;
* )
argv+=($1)
;;
esac
shift
done

concatargs(){
delim='-'
str=
for i in "$@"; do
str="$str$delim$i"
done
branch=feature/${str:1}
str=$(IFS='-'; echo "$*")
branch="$branch_prefix"/$str
}

if test "$1" = "finish"; then
test -z $2 && echo "feature <name> required." 1>&2 && exit 1
branch=feature/$2
git merge --no-ff $branch && git delete-branch $branch
if test "${argv[0]}" = "finish"; then
test -z "${argv[1]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
branch="$branch_prefix"/"${argv[1]}"
git merge --no-ff "$branch" && git delete-branch "$branch"
else
test -z $1 && echo "feature <name> required." 1>&2 && exit 1
if test -n "$2"; then
concatargs ${@:2}
test -z "${argv[0]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
if test -n "${argv[1]}"; then
concatargs "${argv[@]}"
else
branch=feature/$1
branch="$branch_prefix"/"${argv[0]}"
fi
git checkout -b $branch
fi
24 changes: 18 additions & 6 deletions man/git-feature.1
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-FEATURE" "1" "April 2015" "" ""
.TH "GIT\-FEATURE" "1" "September 2015" "" ""
.
.SH "NAME"
\fBgit\-feature\fR \- Create feature branch
\fBgit\-feature\fR \- Create/Merge feature branch
.
.SH "SYNOPSIS"
\fBgit\-feature\fR [finish] <name>
\fBgit\-feature\fR [\-a|\-\-alias branch_prefix] [finish] <name>
.
.SH "DESCRIPTION"
Create the given feature branch
Create/Merge the given feature branch
.
.SH "OPTIONS"
<\-a|\-\-alias branch_prefix>
.
.P
use \fBbranch_prefix\fR instead of \fBfeature\fR
.
.P
<finish>
.
.P
Expand All @@ -30,10 +36,16 @@ The name of the feature branch\.

$ git feature dependencies
\.\.\.
$ git commit \-m "Some changes"
$ (feature/dependencies) git commit \-m "Some changes"
\.\.\.
$ git checkout master
$ (feature/dependencies) git checkout master
$ git feature finish dependencies

$ git alias features "feature \-a features"
$ git features dependencies
$ (features/dependencies) \.\.\.
$ (features/dependencies) git checkout master
$ git features finish dependencies
.
.fi
.
Expand Down
136 changes: 136 additions & 0 deletions man/git-feature.1.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions man/git-feature.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
git-feature(1) -- Create feature branch
git-feature(1) -- Create/Merge feature branch
=======================================

## SYNOPSIS

`git-feature` [finish] &lt;name&gt;
`git-feature` [-a|--alias branch_prefix] [finish] &lt;name&gt;

## DESCRIPTION

Create the given feature branch
Create/Merge the given feature branch

## OPTIONS

&lt;-a|--alias branch_prefix&gt;

use `branch_prefix` instead of `feature`

&lt;finish&gt;

Merge and delete the feature branch.
Expand All @@ -23,11 +27,17 @@ git-feature(1) -- Create feature branch

$ git feature dependencies
...
$ git commit -m "Some changes"
$ (feature/dependencies) git commit -m "Some changes"
...
$ git checkout master
$ (feature/dependencies) git checkout master
$ git feature finish dependencies

$ git alias features "feature -a features"
$ git features dependencies
$ (features/dependencies) ...
$ (features/dependencies) git checkout master
$ git features finish dependencies

## AUTHOR

Written by Jesús Espino &lt;<[email protected]>&gt;
Expand Down