mirror of
https://github.com/iwata/git-now.git
synced 2026-09-10 07:26:29 -04:00
z * rebase, grepにauthorオプションを追加
* rebaseのpushオプションを廃止
This commit is contained in:
parent
9a73bbeeed
commit
3864632dff
|
|
@ -1,5 +1,5 @@
|
|||
usage() {
|
||||
echo "usage: git now grep [--patch|-p] [--stat|-s] [<base-branch>]"
|
||||
echo "usage: git now grep [--patch|-p] [--stat|-s] [--author|-a] [<base-branch>]"
|
||||
}
|
||||
|
||||
cmd_default() {
|
||||
|
|
@ -18,6 +18,7 @@ parse_args() {
|
|||
# parse options
|
||||
DEFINE_boolean 'patch' false 'generate diff in patch format' 'p'
|
||||
DEFINE_boolean 'stat' false 'generate diffstat instead of patch' 's'
|
||||
DEFINE_boolean 'author' false 'limit git-now commits by your name' 'a'
|
||||
FLAGS "$@" || exit $?
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
# read arguments into global variables
|
||||
|
|
@ -29,6 +30,10 @@ parse_args() {
|
|||
if flag stat; then
|
||||
ARGS="${ARGS} --stat"
|
||||
fi
|
||||
if flag author; then
|
||||
AUTHOR=$(escape `git config --get user.name`)
|
||||
ARGS="${ARGS} --author=$AUTHOR"
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_help() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
usage() {
|
||||
echo "usage: git now rebase [<base-branch>]"
|
||||
echo " git now rebase --push [<base-branch>]"
|
||||
echo " git now rebase --push --upstream <remote> [<base-branch>]"
|
||||
echo " git now rebase --push --remove <remote> [<base-branch>]"
|
||||
echo "usage: git now rebase [--author|-a] [<base-branch>]"
|
||||
#echo " git now rebase --push [<base-branch>]"
|
||||
#echo " git now rebase --push --upstream <remote> [<base-branch>]"
|
||||
#echo " git now rebase --push --remove <remote> [<base-branch>]"
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -14,7 +14,11 @@ cmd_default() {
|
|||
|
||||
if [ -n "$BASE_BRANCH" ]; then
|
||||
COMMON_ANCESTOR_COMMIT=`git merge-base ${BASE_BRANCH} ${WORKING_BRANCH}`
|
||||
FIRST_NOW_COMMIT=$(git_now_first_commit $COMMON_ANCESTOR_COMMIT)
|
||||
if flag author; then
|
||||
FIRST_NOW_COMMIT=$(git_now_my_first_commit $COMMON_ANCESTOR_COMMIT)
|
||||
else
|
||||
FIRST_NOW_COMMIT=$(git_now_first_commit $COMMON_ANCESTOR_COMMIT)
|
||||
fi
|
||||
|
||||
if [ "$FIRST_NOW_COMMIT" != "$INITIAL_COMMIT" ]; then
|
||||
git rebase -i ${FIRST_NOW_COMMIT}^
|
||||
|
|
@ -24,7 +28,11 @@ cmd_default() {
|
|||
git rebase --onto HEAD ${FIRST_NOW_COMMIT} ${WORKING_BRANCH}
|
||||
fi
|
||||
else
|
||||
FIRST_NOW_COMMIT=$(git_now_first_commit)
|
||||
if flag author; then
|
||||
FIRST_NOW_COMMIT=$(git_now_my_first_commit)
|
||||
else
|
||||
FIRST_NOW_COMMIT=$(git_now_first_commit)
|
||||
fi
|
||||
|
||||
if [ "$FIRST_NOW_COMMIT" != "$INITIAL_COMMIT" ]; then
|
||||
git rebase -i ${FIRST_NOW_COMMIT}^
|
||||
|
|
@ -35,16 +43,16 @@ cmd_default() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if flag push; then
|
||||
if [ -n "$UPSTREAM_REMOTE" ]; then
|
||||
git push --set-upstream $UPSTREAM_REMOTE $WORKING_BRANCH
|
||||
elif [ -n "$REMOVE_REMOTE" ]; then
|
||||
git push $REMOVE_REMOTE :$WORKING_BRANCH
|
||||
git push
|
||||
else
|
||||
git push
|
||||
fi
|
||||
fi
|
||||
#if flag push; then
|
||||
#if [ -n "$UPSTREAM_REMOTE" ]; then
|
||||
#git push --set-upstream $UPSTREAM_REMOTE $WORKING_BRANCH
|
||||
#elif [ -n "$REMOVE_REMOTE" ]; then
|
||||
#git push $REMOVE_REMOTE :$WORKING_BRANCH
|
||||
#git push
|
||||
#else
|
||||
#git push
|
||||
#fi
|
||||
#fi
|
||||
}
|
||||
|
||||
cmd_help() {
|
||||
|
|
@ -54,15 +62,16 @@ cmd_help() {
|
|||
|
||||
parse_args() {
|
||||
# parse options
|
||||
DEFINE_boolean 'push' false 'push to remote repository finally' ''
|
||||
DEFINE_string 'remove' '' 'remote name to remove the remote branch before push' ''
|
||||
DEFINE_string 'upstream' '' 'remote name for --set-upstream' ''
|
||||
DEFINE_boolean 'author' false 'limit git-now commits by your name' 'a'
|
||||
#DEFINE_boolean 'push' false 'push to remote repository finally' ''
|
||||
#DEFINE_string 'remove' '' 'remote name to remove the remote branch before push' ''
|
||||
#DEFINE_string 'upstream' '' 'remote name for --set-upstream' ''
|
||||
FLAGS "$@" || exit $?
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
|
||||
# read arguments into global variables
|
||||
BASE_BRANCH=$1
|
||||
UPSTREAM_REMOTE=$FLAGS_upstream
|
||||
REMOVE_REMOTE=$FLAGS_remove
|
||||
#UPSTREAM_REMOTE=$FLAGS_upstream
|
||||
#REMOVE_REMOTE=$FLAGS_remove
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,4 +49,14 @@ git_now_first_commit() {
|
|||
fi
|
||||
}
|
||||
|
||||
git_now_my_first_commit() {
|
||||
local author=$(escape `git config --get user.name`)
|
||||
local common=$1
|
||||
if [ $# -eq 1 ]; then
|
||||
git log ${common}.. --pretty=oneline --author=${author} --grep="${PREFIX}" | tail -n 1 | cut -d " " -f 1
|
||||
else
|
||||
git log --pretty=oneline --author=${author} --grep="${PREFIX}" | tail -n 1 | cut -d " " -f 1
|
||||
fi
|
||||
}
|
||||
|
||||
git_now_initial_commit() { git log --pretty=oneline | tail -n 1 | cut -d " " -f 1; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue