diff --git a/README.mdown b/README.mdown index 8eac906..20c37dc 100644 --- a/README.mdown +++ b/README.mdown @@ -21,7 +21,8 @@ You can use the same option as ``git add``. Available subcommands are: * rebase - rebase for temporary commits. - * grep - grep temporary commits. + * push - rebuild remote branch after rebase. + * grep - grep temporary commits. _Try 'git now \ help' for details._ diff --git a/etc/_git-now b/etc/_git-now index 962bc37..9b565f7 100644 --- a/etc/_git-now +++ b/etc/_git-now @@ -24,6 +24,7 @@ __git-now-add () '-e[open diff against index in editor]'\ '-u[update only files git already knows about]'\ '-N[record only that path will be added later]'\ + '-s[generate diffstat instead of patch]'\ ':filepattern:_files' } @@ -76,6 +77,7 @@ case $state in subcommands=( 'add:default subcommand.' 'rebase:rebase for temporary commits.' + 'push:remove remote branch and push to remote repoistory for rebase commits.' 'grep:grep temporary commits.' ) _describe -t commands 'git now' subcommands @@ -95,6 +97,11 @@ case $state in ':branch-name:__git_branch_names' ;; + (push) + _arguments \ + ':remote-repostory:__git_remotes' + ;; + (grep) _arguments \ '-p[generate diff in patch format]'\ diff --git a/etc/git-now-completion.zsh b/etc/git-now-completion.zsh index 5bbff76..a1919b4 100644 --- a/etc/git-now-completion.zsh +++ b/etc/git-now-completion.zsh @@ -34,6 +34,7 @@ _git-now () subcommands=( 'add:default subcommand.' 'rebase:rebase for temporary commits.' + 'push:remove remote branch and push to remote repoistory for rebase commits.' 'grep:grep temporary commits.' ) _describe -t commands 'git now' subcommands @@ -53,6 +54,11 @@ _git-now () ':branch-name:__git_branch_names' ;; + (push) + _arguments \ + ':remote-repostory:__git_remotes' + ;; + (grep) _arguments \ '-p[generate diff in patch format]'\ @@ -82,6 +88,7 @@ __git-now-add () '-e[open diff against index in editor]'\ '-u[update only files git already knows about]'\ '-N[record only that path will be added later]'\ + '-s[generate diffstat instead of patch]'\ ':filepattern:_files' } diff --git a/git-now b/git-now index 9ee7500..2b346fe 100755 --- a/git-now +++ b/git-now @@ -19,6 +19,7 @@ usage() { echo "Available subcommands are:" echo " add default subcommand." echo " rebase rebase for temporary commits." + echo " push remove remote branch before push to remote repoistory for rebase commits." echo " grep grep temporary commits." echo echo "Try 'git now help' for details." diff --git a/git-now-add b/git-now-add index 0976d63..30ddd57 100644 --- a/git-now-add +++ b/git-now-add @@ -1,7 +1,7 @@ usage() { echo "usage: git now add [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]" echo " [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]" - echo " [--refresh] [--ignore-errors] [--ignore-missing] [--]" + echo " [--refresh] [--ignore-errors] [--ignore-missing] [ --stat | -s ] [--]" echo " [...]" } @@ -11,13 +11,32 @@ cmd_default() { git add -u printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F - else + local is_stat=false + local args=() + + # args loop + for arg in "$@" + do + if [ $arg = "--stat" ] || [ $arg = "-s" ]; then + is_stat=true + else + n=${#args[@]} + args[$n]=$arg + fi + done + if [ $1 != "--all" ]; then - git add $@ + git add ${args[@]} else git add -u git add . fi - printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F - + + if $is_stat; then + printf "${MESSAGE}\n\n%s" "`git diff --cached --stat`" | git commit -F - + else + printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F - + fi fi } @@ -26,3 +45,4 @@ cmd_help() { exit 0 } +# vim: set ff=unix ft=sh : diff --git a/git-now-grep b/git-now-grep index 5ac70c3..487eb4c 100644 --- a/git-now-grep +++ b/git-now-grep @@ -41,3 +41,4 @@ cmd_help() { exit 0 } +# vim: set ff=unix ft=sh : diff --git a/git-now-push b/git-now-push new file mode 100644 index 0000000..bbb4e88 --- /dev/null +++ b/git-now-push @@ -0,0 +1,23 @@ +usage() { + echo "usage: git now push []" +} + + +cmd_default() { + REMOTE=$1 + + WORKING_BRANCH=$(git_current_branch) + + if [ -n "$REMOTE" ]; then + git push ${REMOTE} :${WORKING_BRANCH} && git push ${REMOTE} ${WORKING_BRANCH} + else + git push origin :${WORKING_BRANCH} && git push + fi +} + +cmd_help() { + usage + exit 0 +} + +# vim: set ff=unix ft=sh : diff --git a/git-now-rebase b/git-now-rebase index 451b0f6..0359566 100644 --- a/git-now-rebase +++ b/git-now-rebase @@ -1,8 +1,5 @@ usage() { echo "usage: git now rebase [--mine|-m] []" - #echo " git now rebase --push []" - #echo " git now rebase --push --upstream []" - #echo " git now rebase --push --remove []" } @@ -42,17 +39,6 @@ cmd_default() { git rebase --onto HEAD ${FIRST_NOW_COMMIT} ${WORKING_BRANCH} 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() { @@ -63,15 +49,11 @@ cmd_help() { parse_args() { # parse options DEFINE_boolean 'mine' false 'limit git-now commits by my name' 'm' - #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 } +# vim: set ff=unix ft=sh : diff --git a/git-now.rb b/git-now.rb index 7a82d28..9da806a 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.6.0' - version '0.0.6.0' + url 'https://github.com/iwata/git-now.git', :tag => 'v0.1.0.0' + version '0.1.0.0' 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 409458f..3b7bd3e 100644 --- a/gitnow-common +++ b/gitnow-common @@ -60,3 +60,5 @@ git_now_my_first_commit() { } git_now_initial_commit() { git log --pretty=oneline | tail -n 1 | cut -d " " -f 1; } + +# vim: set ff=unix ft=sh