diff --git a/git-now-grep b/git-now-grep index f562023..27de185 100644 --- a/git-now-grep +++ b/git-now-grep @@ -1,5 +1,5 @@ usage() { - echo "usage: git now grep [--patch|-p] [--stat|-s] []" + echo "usage: git now grep [--patch|-p] [--stat|-s] [--author|-a] []" } 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() { diff --git a/git-now-rebase b/git-now-rebase index 7b4e9ef..e3078eb 100644 --- a/git-now-rebase +++ b/git-now-rebase @@ -1,8 +1,8 @@ usage() { - echo "usage: git now rebase []" - echo " git now rebase --push []" - echo " git now rebase --push --upstream []" - echo " git now rebase --push --remove []" + echo "usage: git now rebase [--author|-a] []" + #echo " git now rebase --push []" + #echo " git now rebase --push --upstream []" + #echo " git now rebase --push --remove []" } @@ -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 } diff --git a/git-now.rb b/git-now.rb index 38d59c8..1452121 100644 --- a/git-now.rb +++ b/git-now.rb @@ -1,8 +1,8 @@ require 'formula' class GitNow < Formula - url 'https://github.com/iwata/git-now.git', :tag => 'v0.0.4' - version '0.0.4' + url 'https://github.com/iwata/git-now.git', :tag => 'v0.0.4.1' + version '0.0.4.1' head 'https://github.com/iwata/git-now.git', :branch => 'develop' homepage 'https://github.com/iwata/git-now' diff --git a/gitnow-common b/gitnow-common index aec7aff..409458f 100644 --- a/gitnow-common +++ b/gitnow-common @@ -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; }