From 5dd110a1c38ba6303eaa41a5c18157724ee00b10 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 13:16:51 +0300 Subject: [PATCH 01/67] *out, espeak --- git-wizard | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/git-wizard b/git-wizard index d63078d..e595415 100755 --- a/git-wizard +++ b/git-wizard @@ -6,8 +6,12 @@ declare -A prop flag msg declare -a keys actprop actkey conf act +echo | espeak 2> /dev/null +quiet=$? + while [ "$1" ]; do case $1 in + '--quiet') quiet=1 ;; *) echo error: unknown argument $1;; esac shift @@ -69,6 +73,12 @@ actg() acti $1 $2 $3 "git $4" } +out() +{ + echo "$1 \e[1m$2\e[0m" + [ $quiet != 0 ] && return + espeak "$2" 2> /dev/null & +} # Ask user which available actions to perform perform-actions() @@ -80,7 +90,7 @@ perform-actions() [[ ! $flag[$key] =~ a ]] && continue [[ -z "$v" || "$v" == 0 ]] && continue - print "What to do with $(prop-print $key) ?" + out "What to do with" "$(prop-print $key)?" for n ({1..${#actprop}}) { [[ $actprop[$n] != $key ]] && continue @@ -124,15 +134,14 @@ prop-print() summary() { - echo -n "At '$prop[head]'" + local m="At head '$prop[head]'" for key in $keys; do [[ ! $flag[$key] =~ s ]] && continue p="$prop[$key]" - [ -z "$p" -o "$p" = 0 -o -z $m ] && continue - echo -n ", " - prop-print $key + [ -z "$p" -o "$p" = 0 ] && continue + m+=", $(prop-print $key)" done - echo + out $m } report() @@ -232,7 +241,7 @@ rep root '%1 @v' 'rev-parse --show-toplevel' if [ $(git rev-parse --show-toplevel) ]; then gitw-start "$@" else - echo "Not a git repository" + out "Here is no a git repository" read -r -k "?Create empty? (y/n)" echo [[ $REPLY =~ ^[Yy]$ ]] && git init . From 1fcd9ca4cef0ad771cdbc667fef6463608294660 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 13:17:03 +0300 Subject: [PATCH 02/67] readable names --- git-wizard | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-wizard b/git-wizard index e595415..5adfc3a 100755 --- a/git-wizard +++ b/git-wizard @@ -210,10 +210,10 @@ git-general() if [[ -z "$prop[fetch_age]" || "$prop[fetch_age]" -gt 10 || "$prop[fetch_age]" -lt 0 ]]; then git fetch --all fi - prs ahead '%1' 'rev-list --count @{u}..HEAD' - actg ahead p "Push to remote" push - rep behind '%1' 'rev-list --count HEAD..@{u}' - actg behind l "pull from remote" 'pull --autostash' + prs local_commits '%1' 'rev-list --count @{u}..HEAD' + actg local_commits p "Push to remote" push + rep remote_commits '%1' 'rev-list --count HEAD..@{u}' + actg remote_commits l "pull from remote" 'pull --autostash' fi } From 0288e4a73fce1e7beebbb9221b98d742b821e689 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 16:21:19 +0300 Subject: [PATCH 03/67] move in_progress --- git-wizard | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/git-wizard b/git-wizard index 5adfc3a..ba3c116 100755 --- a/git-wizard +++ b/git-wizard @@ -163,6 +163,16 @@ git-general() # rep - property for report only, prs - long and short git_dir=$(git rev-parse --git-dir) rep root '%1 @v' 'rev-parse --show-toplevel' + + prs in_progress '%1' 'merge HEAD > /dev/null && git status --ignored=no HEAD | {! grep -q "in progress"}; echo $((? != 0))' + actg in_progress ' ' "Check head status" 'status --untracked-files=no HEAD' # without modifered + # TODO: + # git status -uno HEAD | grep 'rebase in progress' + # all conflicts fixed: run "git rebase --continue" + # git commit --amend + # git rebase --edit-todo + # git rebase --continue + prs unmerged '%1 file(s)' 'diff --name-status --diff-filter=U | wc -l' actg unmerged g "Run merge tool" mergetool @@ -193,15 +203,6 @@ git-general() actg stashes o "pop from stash" 'stash pop' rep commited '%1' 'log -1 --format="%ar"' - prs in_progress '%1' 'merge HEAD > /dev/null && git status --ignored=no HEAD | {! grep -q "in progress"}; echo $((? != 0))' - actg in_progress t "Check head status" 'status --untracked-files=no HEAD' # without modifered - # TODO: - # git status -uno HEAD | grep 'rebase in progress' - # all conflicts fixed: run "git rebase --continue" - # git commit --amend - # git rebase --edit-todo - # git rebase --continue - rep remote '%1' "config --get branch.$prop[branch].remote" if [[ $prop[remote] ]]; then local h=$git_dir/FETCH_HEAD From fcc27a8e82e658a26e9db3ff2e5d1d2bdb3769cd Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 16:21:46 +0300 Subject: [PATCH 04/67] space - more details --- git-wizard | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/git-wizard b/git-wizard index ba3c116..78dc132 100755 --- a/git-wizard +++ b/git-wizard @@ -58,7 +58,7 @@ prs() { prop_git "s" "$1" "$2" "$3" } acti() { actprop+=($1) - [[ "${actkey[(ie)$2]}" -le "${#actkey}" ]] && echo "duplicated key $2" + #[[ "${actkey[(ie)$2]}" -le "${#actkey}" ]] && echo "duplicated key $2" actkey+=("$2") conf+=("$3") flag[$1]+=a @@ -177,29 +177,29 @@ git-general() actg unmerged g "Run merge tool" mergetool prs modified '%1 file(s)' 'diff --name-only | wc -l' - actg modified m "show" 'diff' + actg modified ' ' "show" 'diff' actg modified u "update stage with modifications" 'add --patch' actg modified s "push into stash" 'stash push --patch' actg modified d "discard" 'checkout --patch' rep head "%1 '@v'" 'describe --all --contains --always' - acti head r 'print report' report + acti head ' ' 'print report' report rep branch '' 'rev-parse --abbrev-ref HEAD' prs untracked '%1 file(s)' 'ls-files --others --exclude-standard --directory| wc -l' - actg untracked L "list" 'status --untracked-files=normal' + actg untracked ' ' "list" 'status --untracked-files=normal' actg untracked a "add and stage" 'add --interactive' actg untracked C "cleanup" 'clean --interactive -d' actg untracked i "ignore" 'ls-files --others --directory --exclude-standard --exclude .gitignore >> .gitignore' # TODO: add to .gitignore prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' - actg staged S "show" 'diff --staged' + actg staged ' ' "show" 'diff --staged' actg staged c "commit" commit actg staged R "unstage (reset) modifications" 'reset --patch' prs stashes '%1' 'stash list | wc -l' - actg stashes T "show and list stash" 'stash show; git stash list' + actg stashes ' ' "show and list stash" 'stash show; git stash list --stat' actg stashes o "pop from stash" 'stash pop' rep commited '%1' 'log -1 --format="%ar"' From 3ba98844746055df2b9f599754711ace10ce55e0 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 17:09:37 +0300 Subject: [PATCH 05/67] reorder --- git-wizard | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/git-wizard b/git-wizard index 78dc132..5ebdb71 100755 --- a/git-wizard +++ b/git-wizard @@ -164,6 +164,9 @@ git-general() git_dir=$(git rev-parse --git-dir) rep root '%1 @v' 'rev-parse --show-toplevel' + prs unmerged '%1 file(s)' 'diff --name-status --diff-filter=U | wc -l' + actg unmerged g "Run merge tool" mergetool + prs in_progress '%1' 'merge HEAD > /dev/null && git status --ignored=no HEAD | {! grep -q "in progress"}; echo $((? != 0))' actg in_progress ' ' "Check head status" 'status --untracked-files=no HEAD' # without modifered # TODO: @@ -173,8 +176,10 @@ git-general() # git rebase --edit-todo # git rebase --continue - prs unmerged '%1 file(s)' 'diff --name-status --diff-filter=U | wc -l' - actg unmerged g "Run merge tool" mergetool + prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' + actg staged ' ' "show" 'diff --staged' + actg staged c "commit" commit + actg staged R "unstage (reset) modifications" 'reset --patch' prs modified '%1 file(s)' 'diff --name-only | wc -l' actg modified ' ' "show" 'diff' @@ -186,18 +191,6 @@ git-general() acti head ' ' 'print report' report rep branch '' 'rev-parse --abbrev-ref HEAD' - prs untracked '%1 file(s)' 'ls-files --others --exclude-standard --directory| wc -l' - actg untracked ' ' "list" 'status --untracked-files=normal' - actg untracked a "add and stage" 'add --interactive' - actg untracked C "cleanup" 'clean --interactive -d' - actg untracked i "ignore" 'ls-files --others --directory --exclude-standard --exclude .gitignore >> .gitignore' - # TODO: add to .gitignore - - prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' - actg staged ' ' "show" 'diff --staged' - actg staged c "commit" commit - actg staged R "unstage (reset) modifications" 'reset --patch' - prs stashes '%1' 'stash list | wc -l' actg stashes ' ' "show and list stash" 'stash show; git stash list --stat' actg stashes o "pop from stash" 'stash pop' @@ -216,6 +209,12 @@ git-general() rep remote_commits '%1' 'rev-list --count HEAD..@{u}' actg remote_commits l "pull from remote" 'pull --autostash' fi + + prs untracked '%1 file(s)' 'ls-files --others --exclude-standard --directory| wc -l' + actg untracked ' ' "list" 'status --untracked-files=normal' + actg untracked a "add and stage" 'add --interactive' + actg untracked C "cleanup" 'clean --interactive -d' + actg untracked i "ignore" 'ls-files --others --directory --exclude-standard --exclude .gitignore >> .gitignore' } gitw-start() From 5ff8c57baf48be6bcc55dcf3b0e870113d0d59c4 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 19:41:28 +0300 Subject: [PATCH 06/67] remote() --- git-wizard | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/git-wizard b/git-wizard index 5ebdb71..ff26dc2 100755 --- a/git-wizard +++ b/git-wizard @@ -158,6 +158,23 @@ report() echo } +remote() +{ + rep remote '%1' "config --get branch.$prop[branch].remote" + if [[ $prop[remote] ]]; then + local h=$git_dir/FETCH_HEAD + test -e $h && prop l fetch_age '%1 (min) @v' "$(((`date +%s` - `stat -c %Z $h`) / 60))" + #((fetch= ! ${#fetch_age} || $prop[fetch_age] > 10 || $prop[fetch_age] < 0)) + if [[ -z "$prop[fetch_age]" || "$prop[fetch_age]" -gt 10 || "$prop[fetch_age]" -lt 0 ]]; then + git fetch --all + fi + prs local_commits '%1' 'rev-list --count @{u}..HEAD' + actg local_commits p "Push to remote" push + rep remote_commits '%1' 'rev-list --count HEAD..@{u}' + actg remote_commits l "pull from remote" 'pull --autostash' + fi +} + git-general() { # rep - property for report only, prs - long and short @@ -196,19 +213,7 @@ git-general() actg stashes o "pop from stash" 'stash pop' rep commited '%1' 'log -1 --format="%ar"' - rep remote '%1' "config --get branch.$prop[branch].remote" - if [[ $prop[remote] ]]; then - local h=$git_dir/FETCH_HEAD - test -e $h && prop l fetch_age '%1 (min) @v' "$(((`date +%s` - `stat -c %Z $h`) / 60))" - #((fetch= ! ${#fetch_age} || $prop[fetch_age] > 10 || $prop[fetch_age] < 0)) - if [[ -z "$prop[fetch_age]" || "$prop[fetch_age]" -gt 10 || "$prop[fetch_age]" -lt 0 ]]; then - git fetch --all - fi - prs local_commits '%1' 'rev-list --count @{u}..HEAD' - actg local_commits p "Push to remote" push - rep remote_commits '%1' 'rev-list --count HEAD..@{u}' - actg remote_commits l "pull from remote" 'pull --autostash' - fi + remote prs untracked '%1 file(s)' 'ls-files --others --exclude-standard --directory| wc -l' actg untracked ' ' "list" 'status --untracked-files=normal' From 8b4dfc1a417909c8a69a8893f6439b96b6af743e Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 21:28:26 +0300 Subject: [PATCH 07/67] +in_progress() --- git-wizard | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/git-wizard b/git-wizard index ff26dc2..13bdfe2 100755 --- a/git-wizard +++ b/git-wizard @@ -158,6 +158,21 @@ report() echo } +in_progress() +{ + prs unmerged '%1 file(s)' 'diff --name-status --diff-filter=U | wc -l' + actg unmerged g "Run merge tool" mergetool + + prop s in_progress '%1' "$(git status --untracked-files=no HEAD | grep -q -e "You are" -e "in progress" && echo "an operation")" + actg in_progress ' ' "Check head status" 'status --untracked-files=no HEAD' # without modifered + actg in_progress c "Continue rebase" 'rebase --continue' + # TODO: + # git status -uno HEAD | grep 'rebase in progress' + # git commit --amend + # git rebase --edit-todo + +} + remote() { rep remote '%1' "config --get branch.$prop[branch].remote" @@ -181,17 +196,7 @@ git-general() git_dir=$(git rev-parse --git-dir) rep root '%1 @v' 'rev-parse --show-toplevel' - prs unmerged '%1 file(s)' 'diff --name-status --diff-filter=U | wc -l' - actg unmerged g "Run merge tool" mergetool - - prs in_progress '%1' 'merge HEAD > /dev/null && git status --ignored=no HEAD | {! grep -q "in progress"}; echo $((? != 0))' - actg in_progress ' ' "Check head status" 'status --untracked-files=no HEAD' # without modifered - # TODO: - # git status -uno HEAD | grep 'rebase in progress' - # all conflicts fixed: run "git rebase --continue" - # git commit --amend - # git rebase --edit-todo - # git rebase --continue + in_progress prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' actg staged ' ' "show" 'diff --staged' From 263254de305616de6fd02b96561f157e703f2ee7 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 21:56:34 +0300 Subject: [PATCH 08/67] log remote, local --- git-wizard | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-wizard b/git-wizard index 13bdfe2..49e7908 100755 --- a/git-wizard +++ b/git-wizard @@ -125,6 +125,7 @@ prop-print() m=${m/\(s\)/s} else m=${m/es-EOL/} + m=${m/commits-EOL/commit} fi m=${m/-EOL/} m=${m/\(s\)/} @@ -184,8 +185,10 @@ remote() git fetch --all fi prs local_commits '%1' 'rev-list --count @{u}..HEAD' + actg local_commits ' ' "list" "log ..@{u}" actg local_commits p "Push to remote" push rep remote_commits '%1' 'rev-list --count HEAD..@{u}' + actg remote_commits ' ' "list" 'log --stat HEAD..@{u}' actg remote_commits l "pull from remote" 'pull --autostash' fi } From e859c36b2f96a0dab43880e29a6bdf1ef2514a03 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 22:45:36 +0300 Subject: [PATCH 09/67] *head --- git-wizard | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git-wizard b/git-wizard index 49e7908..e04a005 100755 --- a/git-wizard +++ b/git-wizard @@ -155,7 +155,6 @@ report() [ -z $msg[$key] ] && continue echo "$m: $prop[$key]" done - git status --untracked-files=no echo } @@ -214,6 +213,8 @@ git-general() rep head "%1 '@v'" 'describe --all --contains --always' acti head ' ' 'print report' report + actg head c 'show the last commit' 'show --stat' + actg head s "check head status" 'status --untracked-files=no HEAD' # without modifered rep branch '' 'rev-parse --abbrev-ref HEAD' prs stashes '%1' 'stash list | wc -l' From 0eb7d09c611f954a9192a9d9574b0d522919d4de Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 22:46:32 +0300 Subject: [PATCH 10/67] branches --- git-wizard | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-wizard b/git-wizard index e04a005..da28d12 100755 --- a/git-wizard +++ b/git-wizard @@ -215,7 +215,10 @@ git-general() acti head ' ' 'print report' report actg head c 'show the last commit' 'show --stat' actg head s "check head status" 'status --untracked-files=no HEAD' # without modifered + rep branch '' 'rev-parse --abbrev-ref HEAD' + rep local_branches '%1' 'branch | wc -l' + rep remote_branches '%1' 'branch --remote | wc -l' prs stashes '%1' 'stash list | wc -l' actg stashes ' ' "show and list stash" 'stash show; git stash list --stat' From 6bb999acd4a28c482e84a6cc7fff91fcdd7fb94c Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 9 Apr 2020 22:46:51 +0300 Subject: [PATCH 11/67] diff --stat --- git-wizard | 1 + 1 file changed, 1 insertion(+) diff --git a/git-wizard b/git-wizard index da28d12..289fc22 100755 --- a/git-wizard +++ b/git-wizard @@ -206,6 +206,7 @@ git-general() actg staged R "unstage (reset) modifications" 'reset --patch' prs modified '%1 file(s)' 'diff --name-only | wc -l' + actg modified 't' "stat" 'diff --stat' actg modified ' ' "show" 'diff' actg modified u "update stage with modifications" 'add --patch' actg modified s "push into stash" 'stash push --patch' From 1e8d111d49bf00bf033b75a2429521d5cf2db6fc Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sat, 11 Apr 2020 09:02:09 +0300 Subject: [PATCH 12/67] modified --- git-wizard | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/git-wizard b/git-wizard index 289fc22..6a9905d 100755 --- a/git-wizard +++ b/git-wizard @@ -173,6 +173,21 @@ in_progress() } +modified() +{ + prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' + actg staged ' ' "show" 'diff --staged' + actg staged c "commit" commit + actg staged R "unstage (reset) modifications" 'reset --patch' + + prs modified '%1 file(s)' 'diff --name-only | wc -l' + actg modified 't' "stat" 'diff --stat' + actg modified ' ' "show" 'diff' + actg modified u "update stage with modifications" 'add --patch' + actg modified s "push into stash" 'stash push --patch' + actg modified d "discard" 'checkout --patch' +} + remote() { rep remote '%1' "config --get branch.$prop[branch].remote" @@ -199,18 +214,7 @@ git-general() rep root '%1 @v' 'rev-parse --show-toplevel' in_progress - - prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' - actg staged ' ' "show" 'diff --staged' - actg staged c "commit" commit - actg staged R "unstage (reset) modifications" 'reset --patch' - - prs modified '%1 file(s)' 'diff --name-only | wc -l' - actg modified 't' "stat" 'diff --stat' - actg modified ' ' "show" 'diff' - actg modified u "update stage with modifications" 'add --patch' - actg modified s "push into stash" 'stash push --patch' - actg modified d "discard" 'checkout --patch' + modified rep head "%1 '@v'" 'describe --all --contains --always' acti head ' ' 'print report' report From 56275161ed09762ca01196e53d08135e8a005930 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sat, 11 Apr 2020 09:16:56 +0300 Subject: [PATCH 13/67] head-branch --- git-wizard | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/git-wizard b/git-wizard index 6a9905d..a2be042 100755 --- a/git-wizard +++ b/git-wizard @@ -188,6 +188,23 @@ modified() actg modified d "discard" 'checkout --patch' } +head-branch() +{ + rep head "%1 '@v'" 'describe --all --contains --always' + acti head ' ' 'print report' report + actg head c 'show the last commit' 'show --stat' + actg head s "check head status" 'status --untracked-files=no HEAD' # without modifered + + rep branch '' 'rev-parse --abbrev-ref HEAD' + rep local_branches '%1' 'branch | wc -l' + rep remote_branches '%1' 'branch --remote | wc -l' + + prs stashes '%1' 'stash list | wc -l' + actg stashes ' ' "show and list stash" 'stash show; git stash list --stat' + actg stashes o "pop from stash" 'stash pop' + rep commited '%1' 'log -1 --format="%ar"' +} + remote() { rep remote '%1' "config --get branch.$prop[branch].remote" @@ -215,21 +232,7 @@ git-general() in_progress modified - - rep head "%1 '@v'" 'describe --all --contains --always' - acti head ' ' 'print report' report - actg head c 'show the last commit' 'show --stat' - actg head s "check head status" 'status --untracked-files=no HEAD' # without modifered - - rep branch '' 'rev-parse --abbrev-ref HEAD' - rep local_branches '%1' 'branch | wc -l' - rep remote_branches '%1' 'branch --remote | wc -l' - - prs stashes '%1' 'stash list | wc -l' - actg stashes ' ' "show and list stash" 'stash show; git stash list --stat' - actg stashes o "pop from stash" 'stash pop' - rep commited '%1' 'log -1 --format="%ar"' - + head-branch remote prs untracked '%1 file(s)' 'ls-files --others --exclude-standard --directory| wc -l' From ca772068f6092e038194972ad65560c0ca534ad0 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sat, 11 Apr 2020 10:52:37 +0300 Subject: [PATCH 14/67] untracked --- git-wizard | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/git-wizard b/git-wizard index a2be042..76acf03 100755 --- a/git-wizard +++ b/git-wizard @@ -224,6 +224,17 @@ remote() fi } +untracked() +{ + prs untracked '%1 file(s)' 'ls-files --others --exclude-standard --directory| wc -l' + actg untracked ' ' "list" 'status --untracked-files=normal' + actg untracked a "add and stage" 'add --interactive' + actg untracked C "cleanup" 'clean --interactive -d' + actg untracked i "ignore" \ + 'ls-files --others --directory --exclude-standard --exclude .gitignore \ + >> .gitignore' +} + git-general() { # rep - property for report only, prs - long and short @@ -234,12 +245,7 @@ git-general() modified head-branch remote - - prs untracked '%1 file(s)' 'ls-files --others --exclude-standard --directory| wc -l' - actg untracked ' ' "list" 'status --untracked-files=normal' - actg untracked a "add and stage" 'add --interactive' - actg untracked C "cleanup" 'clean --interactive -d' - actg untracked i "ignore" 'ls-files --others --directory --exclude-standard --exclude .gitignore >> .gitignore' + untracked } gitw-start() From 30c1f4e65884f2f30cfa682ba0e07a72aa429bfb Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Mon, 13 Apr 2020 20:07:20 +0300 Subject: [PATCH 15/67] readme --- README.rst | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 README.rst diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..b5fff82 --- /dev/null +++ b/README.rst @@ -0,0 +1,49 @@ +git-wizard - interactive talking front end git wrapper script +===== + +Wizard's vision: collect git tricks, troubleshooting techniques and git wisdom +under one hat. + +git-wizard scans status for your repository and suggests to perform suitable +operations. +Beginners can enjoy interactively learn git functionality. +Experienced command line git users can save they time by using the wizard +to preform recurrent operations. + +For example when you have a merge conflict the wizard first of all suggests +to run mergetool. + +.. contents:: + :local: + +Features +**** + +The wizard uses following commands: + +* init +* status +* add +* commit +* mergetool +* diff +* fetch +* push +* pull +* clone +* stash +* log +* clean + +Each iteration it checks whether the repository contains collisions, +operations in progress, changes, stashes, ahead/behind, untracked files. +Periodically automatically it performs fetch. +Some valuable short messages the wizard tells you audiable via application +espeak. + +To do +**** + +* Analize details of 'in progress' status. +* Cleanup 'gone' branches. +* **You are welcome to request new features and add git tricks** From 249a6e4044f88f228797808dbf50a6e1c75bdb5f Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 14 Apr 2020 06:44:00 +0300 Subject: [PATCH 16/67] clone xsel --- git-wizard | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/git-wizard b/git-wizard index 76acf03..905f531 100755 --- a/git-wizard +++ b/git-wizard @@ -272,7 +272,15 @@ rep root '%1 @v' 'rev-parse --show-toplevel' if [ $(git rev-parse --show-toplevel) ]; then gitw-start "$@" else - out "Here is no a git repository" + out "" "Here is no a git repository" + for c in $(xsel) $(xsel --clipboard); do + if _=$(expr match "$c" ".*:.*/.*git.*"); then + echo "Clipboard content looks like git url: $c" + read -r -k "?Clone? (y/n)" + echo + [[ $REPLY =~ ^[Yy]$ ]] && git clone $c + fi + done read -r -k "?Create empty? (y/n)" echo [[ $REPLY =~ ^[Yy]$ ]] && git init . From fe532340fb4704e363981f8c0e43a318b0257cb3 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 14 Apr 2020 06:44:59 +0300 Subject: [PATCH 17/67] * --- git-wizard | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/git-wizard b/git-wizard index 905f531..890dddc 100755 --- a/git-wizard +++ b/git-wizard @@ -135,14 +135,14 @@ prop-print() summary() { - local m="At head '$prop[head]'" + local m="Summary: head '$prop[head]'" for key in $keys; do [[ ! $flag[$key] =~ s ]] && continue p="$prop[$key]" [ -z "$p" -o "$p" = 0 ] && continue m+=", $(prop-print $key)" done - out $m + out "" $m } report() @@ -267,9 +267,7 @@ gitw-start() esac } -rep root '%1 @v' 'rev-parse --show-toplevel' - -if [ $(git rev-parse --show-toplevel) ]; then +if [ $(git rev-parse --show-toplevel 2> /dev/null) ]; then gitw-start "$@" else out "" "Here is no a git repository" @@ -284,6 +282,5 @@ else read -r -k "?Create empty? (y/n)" echo [[ $REPLY =~ ^[Yy]$ ]] && git init . - #exit 1 fi exit From 15049a3f45c8d1b15c8fb36e502956e9ee5886bc Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 16 Apr 2020 15:48:53 +0300 Subject: [PATCH 18/67] vim diff_to_quickfix --- git-wizard | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/git-wizard b/git-wizard index 890dddc..5298200 100755 --- a/git-wizard +++ b/git-wizard @@ -173,6 +173,16 @@ in_progress() } +diff_to_quickfix() +{ + local file= + while read a;do + [[ "$a" =~ "^\+\+\+ (.*)" ]] && file=$match + [[ "$a" =~ "^@@.*\+([0-9]+)" ]] && echo "$file:$match:$a" + done + #perl -ne '/^\+\+\+ (.+)/ && { $f="$1"};/@@.*\+(\d+)/ &&print "$f:$1:$_\n"' +} + modified() { prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' @@ -186,6 +196,7 @@ modified() actg modified u "update stage with modifications" 'add --patch' actg modified s "push into stash" 'stash push --patch' actg modified d "discard" 'checkout --patch' + acti modified 'e' edit "vim -q <(git diff -U0 --no-prefix | diff_to_quickfix)" } head-branch() From 3d4292679697802f95d87316795ac282b9019a85 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 16 Apr 2020 15:49:37 +0300 Subject: [PATCH 19/67] action_itemes --- git-wizard | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/git-wizard b/git-wizard index 5298200..5f2043c 100755 --- a/git-wizard +++ b/git-wizard @@ -235,6 +235,13 @@ remote() fi } +action_itemes() +{ + rep action_itemes '%1' 'grep --max-depth=3 -w -eTODO -eFIXME | wc -l' + actg action_itemes ' ' list 'grep -w -n -eTODO -eFIXME' + acti action_itemes 'e' edit 'vim -q <(git grep -w -n -eTODO -eFIXME)' +} + untracked() { prs untracked '%1 file(s)' 'ls-files --others --exclude-standard --directory| wc -l' @@ -256,6 +263,7 @@ git-general() modified head-branch remote + action_itemes untracked } From 101792102223f7e850fff2338ef6a472bedddcd2 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 21 Apr 2020 18:01:54 +0300 Subject: [PATCH 20/67] *quickfix --- git-wizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-wizard b/git-wizard index 5f2043c..15d8b7c 100755 --- a/git-wizard +++ b/git-wizard @@ -196,7 +196,7 @@ modified() actg modified u "update stage with modifications" 'add --patch' actg modified s "push into stash" 'stash push --patch' actg modified d "discard" 'checkout --patch' - acti modified 'e' edit "vim -q <(git diff -U0 --no-prefix | diff_to_quickfix)" + acti modified 'e' "edit with vim quickfix" "vim -q <(git diff -U0 --relative --no-prefix | diff_to_quickfix)" } head-branch() From 8a46cd7787b0a0709807369679d2803db6aa74bc Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 21 Apr 2020 18:02:42 +0300 Subject: [PATCH 21/67] move args --- git-wizard | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/git-wizard b/git-wizard index 15d8b7c..046cbc4 100755 --- a/git-wizard +++ b/git-wizard @@ -9,14 +9,6 @@ declare -a keys actprop actkey conf act echo | espeak 2> /dev/null quiet=$? -while [ "$1" ]; do - case $1 in - '--quiet') quiet=1 ;; - *) echo error: unknown argument $1;; - esac - shift -done - reset() { prop=() @@ -286,6 +278,14 @@ gitw-start() esac } +while [ "$1" ]; do + case $1 in + '--quiet') quiet=1 ;; + *) echo error: unknown argument $1;; + esac + shift +done + if [ $(git rev-parse --show-toplevel 2> /dev/null) ]; then gitw-start "$@" else From 06787e81a1c44ef5aee613a3252c8ff22d2d6a65 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 21 Apr 2020 18:03:09 +0300 Subject: [PATCH 22/67] report arg --- README.rst | 25 +++++++++++++++++++++++++ git-wizard | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/README.rst b/README.rst index b5fff82..94590b6 100644 --- a/README.rst +++ b/README.rst @@ -41,6 +41,31 @@ Periodically automatically it performs fetch. Some valuable short messages the wizard tells you audiable via application espeak. +Report +---- + +Just reports current status of the repostory: + +git-wizard report + +root: /home/costa/Dropbox/linux/git-wizard +unmerged files: 0 +in progress: +staged files: 0 +modified files: 2 +head: master +local branches: 2 +remote branches: 3 +stashes: 2 +commited: 2 minutes ago +remote: origin +fetch age (min): 6 +local commits: 3 +remote commits: 0 +action itemes: 1 +gone branches: 0 +untracked files: 3 + To do **** diff --git a/git-wizard b/git-wizard index 046cbc4..ff93026 100755 --- a/git-wizard +++ b/git-wizard @@ -281,6 +281,10 @@ gitw-start() while [ "$1" ]; do case $1 in '--quiet') quiet=1 ;; + 'report') + git-general + report + exit;; *) echo error: unknown argument $1;; esac shift From 74936320af3c5c13993fcbd2f5433b352b0b8af0 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 21 Apr 2020 18:11:47 +0300 Subject: [PATCH 23/67] *Fetures --- README.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 94590b6..001ffd4 100644 --- a/README.rst +++ b/README.rst @@ -19,6 +19,12 @@ to run mergetool. Features **** +Each iteration the wizard checks whether the repository contains collisions, +operations in progress, changes, stashes, ahead/behind commits, untracked files. +Periodically automatically it performs fetch. +Some valuable short messages the wizard tells you audiable via application +espeak. + The wizard uses following commands: * init @@ -35,11 +41,6 @@ The wizard uses following commands: * log * clean -Each iteration it checks whether the repository contains collisions, -operations in progress, changes, stashes, ahead/behind, untracked files. -Periodically automatically it performs fetch. -Some valuable short messages the wizard tells you audiable via application -espeak. Report ---- From 70d66869037acbefab8d3e7ac634e6cf467558b9 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Wed, 22 Apr 2020 19:43:54 +0300 Subject: [PATCH 24/67] move shift --- git-wizard | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/git-wizard b/git-wizard index ff93026..58066bd 100755 --- a/git-wizard +++ b/git-wizard @@ -1,5 +1,6 @@ #!/bin/zsh + # Git Wizard # Interactive front end git wrapper script @@ -9,6 +10,16 @@ declare -a keys actprop actkey conf act echo | espeak 2> /dev/null quiet=$? +while [[ "$1" =~ "^--" ]]; do + case $1 in + '--quiet') quiet=1; shift;; + *) + echo error: unknown argument $1 + break + ;; + esac +done + reset() { prop=() @@ -78,6 +89,7 @@ perform-actions() declare -a kk declare -A actk for key ($keys) { + let n+=1 v=$prop[$key] [[ ! $flag[$key] =~ a ]] && continue [[ -z "$v" || "$v" == 0 ]] && continue @@ -92,13 +104,15 @@ perform-actions() } echo " [Enter] - continue" echo " * - exit" - read -r -k "?>" + echo $probe[$key] + read -r -u 0 -k "?>" [ "$REPLY" = $'\n' ] && continue echo [ -z "$actk[$REPLY]" ] && return 1 eval $actk[$REPLY] break } + [ $#actk -eq 0 ] && echo "Nothing to do" && exit echo } @@ -139,6 +153,7 @@ summary() report() { + summary for key in $keys; do m=${msg[$key]/\(s\)/s} m=${m/ \@v/} @@ -147,6 +162,8 @@ report() [ -z $msg[$key] ] && continue echo "$m: $prop[$key]" done + wait + #git branch --all echo } @@ -232,6 +249,8 @@ action_itemes() rep action_itemes '%1' 'grep --max-depth=3 -w -eTODO -eFIXME | wc -l' actg action_itemes ' ' list 'grep -w -n -eTODO -eFIXME' acti action_itemes 'e' edit 'vim -q <(git grep -w -n -eTODO -eFIXME)' + + prs gone_branches '%1' "branch -vv | grep ': gone]' | wc -l" } untracked() @@ -262,6 +281,10 @@ git-general() gitw-start() { case $1 in + report) + git-general + report + exit;; branches) git for-each-ref --sort=authordate \ --format "%(committerdate:unix) %(committerdate:relative) %(align:left,25)%(refname:short)%(end) %(subject)" \ @@ -271,25 +294,13 @@ gitw-start() until [ $? -eq 1 ] ; do reset git-general - #summary + # summary perform-actions done ;; esac } -while [ "$1" ]; do - case $1 in - '--quiet') quiet=1 ;; - 'report') - git-general - report - exit;; - *) echo error: unknown argument $1;; - esac - shift -done - if [ $(git rev-parse --show-toplevel 2> /dev/null) ]; then gitw-start "$@" else @@ -299,10 +310,10 @@ else echo "Clipboard content looks like git url: $c" read -r -k "?Clone? (y/n)" echo - [[ $REPLY =~ ^[Yy]$ ]] && git clone $c + [[ $REPLY =~ ^[Yy]$ ]] && git clone "$c" fi done - read -r -k "?Create empty? (y/n)" + read -r -u 0 -k "?Create empty? (y/n)" echo [[ $REPLY =~ ^[Yy]$ ]] && git init . fi From 8004a2889ddecafa6884d193260e1f586f7a4aeb Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Wed, 22 Apr 2020 19:47:02 +0300 Subject: [PATCH 25/67] action, ask --- git-wizard | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/git-wizard b/git-wizard index 58066bd..5ee8917 100755 --- a/git-wizard +++ b/git-wizard @@ -10,9 +10,11 @@ declare -a keys actprop actkey conf act echo | espeak 2> /dev/null quiet=$? +action= while [[ "$1" =~ "^--" ]]; do case $1 in '--quiet') quiet=1; shift;; + '--action') action=$2; shift 2;; *) echo error: unknown argument $1 break @@ -20,6 +22,12 @@ while [[ "$1" =~ "^--" ]]; do esac done +ask() +{ + test "$action" && REPLY=$action && return + read -r -k "?$1" +} + reset() { prop=() @@ -80,6 +88,7 @@ out() { echo "$1 \e[1m$2\e[0m" [ $quiet != 0 ] && return + test "$action" && return espeak "$2" 2> /dev/null & } @@ -105,13 +114,15 @@ perform-actions() echo " [Enter] - continue" echo " * - exit" echo $probe[$key] - read -r -u 0 -k "?>" + ask '>' [ "$REPLY" = $'\n' ] && continue echo [ -z "$actk[$REPLY]" ] && return 1 eval $actk[$REPLY] + test "$action" && exit break } + test "$action" && exit [ $#actk -eq 0 ] && echo "Nothing to do" && exit echo } @@ -308,12 +319,12 @@ else for c in $(xsel) $(xsel --clipboard); do if _=$(expr match "$c" ".*:.*/.*git.*"); then echo "Clipboard content looks like git url: $c" - read -r -k "?Clone? (y/n)" + ask 'Clone? (y/n)' echo [[ $REPLY =~ ^[Yy]$ ]] && git clone "$c" fi done - read -r -u 0 -k "?Create empty? (y/n)" + ask 'Create empty? (y/n)' echo [[ $REPLY =~ ^[Yy]$ ]] && git init . fi From 62b63f5c20c5d0ba8cb9b4c073a41241a79b6882 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Wed, 22 Apr 2020 19:52:15 +0300 Subject: [PATCH 26/67] unit-tests, init test --- git-wizard | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/git-wizard b/git-wizard index 5ee8917..c34a68b 100755 --- a/git-wizard +++ b/git-wizard @@ -312,6 +312,19 @@ gitw-start() esac } +[ "$1" = unit-tests ] && +{ + local fails=0 + d=$(mktemp -d) + pushd $d + git-wizard --action y || { echo Fail && false } + let fails+=$? + popd + rm -rf $d + echo Fails: $fails + exit $fails +} + if [ $(git rev-parse --show-toplevel 2> /dev/null) ]; then gitw-start "$@" else @@ -327,5 +340,6 @@ else ask 'Create empty? (y/n)' echo [[ $REPLY =~ ^[Yy]$ ]] && git init . + test -d .git fi exit From 76828fee76548c64a989dcb9b99c36c1d014e55f Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 26 Apr 2020 21:01:22 +0300 Subject: [PATCH 27/67] +other --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 001ffd4..58b06ba 100644 --- a/README.rst +++ b/README.rst @@ -67,6 +67,9 @@ action itemes: 1 gone branches: 0 untracked files: 3 +Other features +---- + To do **** From 76f23ee3b6b046caa51bdefbb876a337b51e4649 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 26 Apr 2020 21:06:44 +0300 Subject: [PATCH 28/67] branches, cleanup --- README.rst | 2 +- git-wizard | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 58b06ba..4682e51 100644 --- a/README.rst +++ b/README.rst @@ -69,10 +69,10 @@ untracked files: 3 Other features ---- +* Cleans up 'gone' branches and helps to keep your workspace tidy. To do **** * Analize details of 'in progress' status. -* Cleanup 'gone' branches. * **You are welcome to request new features and add git tricks** diff --git a/git-wizard b/git-wizard index c34a68b..e0002f3 100755 --- a/git-wizard +++ b/git-wizard @@ -228,7 +228,10 @@ head-branch() rep branch '' 'rev-parse --abbrev-ref HEAD' rep local_branches '%1' 'branch | wc -l' + branches_format='%(committerdate:short) - %(align:left,25)%(committerdate:relative)%(end) %(align:left,25)%(objectname:short) %(refname:short)%(end) %(subject)' + actg local_branches ' ' 'list' "for-each-ref --sort=committerdate --format '$branches_format' refs/heads" rep remote_branches '%1' 'branch --remote | wc -l' + actg remote_branches ' ' 'list recent' "branch --remotes --sort=committerdate --format '$branches_format' | tail -n $((LINES-2))" prs stashes '%1' 'stash list | wc -l' actg stashes ' ' "show and list stash" 'stash show; git stash list --stat' @@ -262,6 +265,7 @@ action_itemes() acti action_itemes 'e' edit 'vim -q <(git grep -w -n -eTODO -eFIXME)' prs gone_branches '%1' "branch -vv | grep ': gone]' | wc -l" + actg gone_branches 'D' "delete gone branches" 'branch -d $(git branch --format="%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(else)%(end)")' } untracked() @@ -296,11 +300,7 @@ gitw-start() git-general report exit;; - branches) - git for-each-ref --sort=authordate \ - --format "%(committerdate:unix) %(committerdate:relative) %(align:left,25)%(refname:short)%(end) %(subject)" \ - refs/heads | sort | cut -f2- ;; - *) + '') true until [ $? -eq 1 ] ; do reset From 101beeeac9402e841b54165ff204ee16f138823e Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 26 Apr 2020 21:31:47 +0300 Subject: [PATCH 29/67] log --- git-wizard | 1 + 1 file changed, 1 insertion(+) diff --git a/git-wizard b/git-wizard index e0002f3..aea2533 100755 --- a/git-wizard +++ b/git-wizard @@ -224,6 +224,7 @@ head-branch() rep head "%1 '@v'" 'describe --all --contains --always' acti head ' ' 'print report' report actg head c 'show the last commit' 'show --stat' + actg head l 'list recent log' 'log --pretty="format:%ar: %ae: %h %s" --reverse -n $((LINES-2))' actg head s "check head status" 'status --untracked-files=no HEAD' # without modifered rep branch '' 'rev-parse --abbrev-ref HEAD' From f94bda826ecafd013fea101c693c6b0d54f40654 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 26 Apr 2020 21:41:34 +0300 Subject: [PATCH 30/67] gui --- README.rst | 1 + git-wizard | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.rst b/README.rst index 4682e51..daf51aa 100644 --- a/README.rst +++ b/README.rst @@ -40,6 +40,7 @@ The wizard uses following commands: * stash * log * clean +* gui and gitk Report diff --git a/git-wizard b/git-wizard index aea2533..915cc4e 100755 --- a/git-wizard +++ b/git-wizard @@ -217,6 +217,7 @@ modified() actg modified s "push into stash" 'stash push --patch' actg modified d "discard" 'checkout --patch' acti modified 'e' "edit with vim quickfix" "vim -q <(git diff -U0 --relative --no-prefix | diff_to_quickfix)" + actg modified 'g' "gui" "gui" } head-branch() @@ -226,6 +227,8 @@ head-branch() actg head c 'show the last commit' 'show --stat' actg head l 'list recent log' 'log --pretty="format:%ar: %ae: %h %s" --reverse -n $((LINES-2))' actg head s "check head status" 'status --untracked-files=no HEAD' # without modifered + acti head k "explore with gitk" "gitk" + actg head a "amend the last commit" "commit --amend" rep branch '' 'rev-parse --abbrev-ref HEAD' rep local_branches '%1' 'branch | wc -l' From 88611a9556b8ea67cc066cd0c892c0dcbbb48e45 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 26 Apr 2020 21:46:25 +0300 Subject: [PATCH 31/67] * --- README.rst | 8 ++++---- git-wizard | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index daf51aa..bde814a 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,8 @@ -git-wizard - interactive talking front end git wrapper script +git-wizard - instant git magic and tricks ===== Wizard's vision: collect git tricks, troubleshooting techniques and git wisdom -under one hat. +under one hat and perform them interactively in dialogue. git-wizard scans status for your repository and suggests to perform suitable operations. @@ -25,7 +25,7 @@ Periodically automatically it performs fetch. Some valuable short messages the wizard tells you audiable via application espeak. -The wizard uses following commands: +The wizard uses following commands under the hood: * init * status @@ -41,7 +41,7 @@ The wizard uses following commands: * log * clean * gui and gitk - +* espeak Report ---- diff --git a/git-wizard b/git-wizard index 915cc4e..e317b05 100755 --- a/git-wizard +++ b/git-wizard @@ -313,6 +313,7 @@ gitw-start() perform-actions done ;; + *) echo Unknown command $1. ;; esac } @@ -346,4 +347,4 @@ else [[ $REPLY =~ ^[Yy]$ ]] && git init . test -d .git fi -exit +exit $? From d3da531f3accd058075a0a8a2a00a1ba9516fe58 Mon Sep 17 00:00:00 2001 From: Costa Date: Sun, 26 Apr 2020 21:55:20 +0300 Subject: [PATCH 32/67] Update README.rst --- README.rst | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/README.rst b/README.rst index bde814a..db26017 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ git-wizard scans status for your repository and suggests to perform suitable operations. Beginners can enjoy interactively learn git functionality. Experienced command line git users can save they time by using the wizard -to preform recurrent operations. +to preform frequent operations. For example when you have a merge conflict the wizard first of all suggests to run mergetool. @@ -48,25 +48,24 @@ Report Just reports current status of the repostory: -git-wizard report +git-wizard report:: -root: /home/costa/Dropbox/linux/git-wizard -unmerged files: 0 -in progress: -staged files: 0 -modified files: 2 -head: master -local branches: 2 -remote branches: 3 -stashes: 2 -commited: 2 minutes ago -remote: origin -fetch age (min): 6 -local commits: 3 -remote commits: 0 -action itemes: 1 -gone branches: 0 -untracked files: 3 + root: /home/costa/Dropbox/linux/git-wizard + unmerged files: 0 + in progress: + modified files: 2 + head: master + local branches: 2 + remote branches: 3 + stashes: 2 + commited: 2 minutes ago + remote: origin + fetch age (min): 6 + local commits: 3 + remote commits: 0 + action itemes: 1 + gone branches: 0 + untracked files: 3 Other features ---- From cd2d1b096df65593262bd05303de6361908813b3 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 5 May 2020 12:08:06 +0300 Subject: [PATCH 33/67] print-actions --- git-wizard | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/git-wizard b/git-wizard index e317b05..f7fcb93 100755 --- a/git-wizard +++ b/git-wizard @@ -92,6 +92,18 @@ out() espeak "$2" 2> /dev/null & } +print-actions() +{ + for n ({1..${#actprop}}) { + [[ $actprop[$n] != $key ]] && continue + kk+=($actkey[$n]) + actk[$actkey[$n]]=$act[$n] + echo " [$actkey[$n]] - $conf[$n]" + } + echo " [Enter] - continue" + echo " * - exit" +} + # Ask user which available actions to perform perform-actions() { @@ -104,16 +116,7 @@ perform-actions() [[ -z "$v" || "$v" == 0 ]] && continue out "What to do with" "$(prop-print $key)?" - - for n ({1..${#actprop}}) { - [[ $actprop[$n] != $key ]] && continue - kk+=($actkey[$n]) - actk[$actkey[$n]]=$act[$n] - echo " [$actkey[$n]] - $conf[$n]" - } - echo " [Enter] - continue" - echo " * - exit" - echo $probe[$key] + print-actions ask '>' [ "$REPLY" = $'\n' ] && continue echo From 0c1e4da3df27e1bd5c7640576b67176a3caa5f4c Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 5 May 2020 12:11:35 +0300 Subject: [PATCH 34/67] *unmerged --- git-wizard | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-wizard b/git-wizard index f7fcb93..e368676 100755 --- a/git-wizard +++ b/git-wizard @@ -183,8 +183,8 @@ report() in_progress() { - prs unmerged '%1 file(s)' 'diff --name-status --diff-filter=U | wc -l' - actg unmerged g "Run merge tool" mergetool + prs unmerged '%1 file(s)' 'ls-files --unmerged | cut -f2 | sort -u | wc -l' + actg unmerged t "Run merge tool" mergetool prop s in_progress '%1' "$(git status --untracked-files=no HEAD | grep -q -e "You are" -e "in progress" && echo "an operation")" actg in_progress ' ' "Check head status" 'status --untracked-files=no HEAD' # without modifered From 7f7c3692f4cbb52ba90ffed7633888e8b8650aad Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 5 May 2020 12:12:06 +0300 Subject: [PATCH 35/67] conflicted --- README.rst | 4 +++- git-wizard | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index db26017..8b3d612 100644 --- a/README.rst +++ b/README.rst @@ -20,7 +20,8 @@ Features **** Each iteration the wizard checks whether the repository contains collisions, -operations in progress, changes, stashes, ahead/behind commits, untracked files. +operations in progress, conflicts, unmerged files, +changes, stashes, ahead/behind commits, untracked files. Periodically automatically it performs fetch. Some valuable short messages the wizard tells you audiable via application espeak. @@ -51,6 +52,7 @@ Just reports current status of the repostory: git-wizard report:: root: /home/costa/Dropbox/linux/git-wizard + conflicted files: 0 unmerged files: 0 in progress: modified files: 2 diff --git a/git-wizard b/git-wizard index e368676..3a8a60b 100755 --- a/git-wizard +++ b/git-wizard @@ -183,8 +183,12 @@ report() in_progress() { + local conflict_pattern='^\(^<<<<<<<\)\|\(^>>>>>>>\)' + prs conflicted '%1 file(s)' "grep -e '$conflict_pattern' -- $(echo $(git diff --name-only --relative)) null \ + | wc -l | ( read c; echo \$(((c+1)/2)))" prs unmerged '%1 file(s)' 'ls-files --unmerged | cut -f2 | sort -u | wc -l' actg unmerged t "Run merge tool" mergetool + [ $prop[conflicted] = 0 ] && actg unmerged a "Add" "add \$(git diff --name-only --relative)" prop s in_progress '%1' "$(git status --untracked-files=no HEAD | grep -q -e "You are" -e "in progress" && echo "an operation")" actg in_progress ' ' "Check head status" 'status --untracked-files=no HEAD' # without modifered From 63a9a681e32ac7c555afa0e0cdd28561bfbafced Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 5 May 2020 12:16:57 +0300 Subject: [PATCH 36/67] show-current-patch --- git-wizard | 1 + 1 file changed, 1 insertion(+) diff --git a/git-wizard b/git-wizard index 3a8a60b..e88d372 100755 --- a/git-wizard +++ b/git-wizard @@ -193,6 +193,7 @@ in_progress() prop s in_progress '%1' "$(git status --untracked-files=no HEAD | grep -q -e "You are" -e "in progress" && echo "an operation")" actg in_progress ' ' "Check head status" 'status --untracked-files=no HEAD' # without modifered actg in_progress c "Continue rebase" 'rebase --continue' + actg in_progress p "Show current patch" 'am --show-current-patch' # TODO: # git status -uno HEAD | grep 'rebase in progress' # git commit --amend From e7bf4c7ebc92fb49c59d5fc2664070834a7cd3fb Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 5 May 2020 12:17:40 +0300 Subject: [PATCH 37/67] reorder modified --- git-wizard | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/git-wizard b/git-wizard index e88d372..1e9386b 100755 --- a/git-wizard +++ b/git-wizard @@ -213,12 +213,7 @@ diff_to_quickfix() modified() { - prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' - actg staged ' ' "show" 'diff --staged' - actg staged c "commit" commit - actg staged R "unstage (reset) modifications" 'reset --patch' - - prs modified '%1 file(s)' 'diff --name-only | wc -l' + prs modified '%1 file(s)' 'ls-files --modified | wc -l' actg modified 't' "stat" 'diff --stat' actg modified ' ' "show" 'diff' actg modified u "update stage with modifications" 'add --patch' @@ -226,6 +221,13 @@ modified() actg modified d "discard" 'checkout --patch' acti modified 'e' "edit with vim quickfix" "vim -q <(git diff -U0 --relative --no-prefix | diff_to_quickfix)" actg modified 'g' "gui" "gui" + + prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' + actg staged ' ' "show" 'diff --staged' + acti staged e "edit with vim quickfix" "vim -q <(git diff -U0 --staged --relative --no-prefix | diff_to_quickfix)" + actg staged c "commit" commit + actg staged R "unstage (reset) modifications" 'reset --patch' + } head-branch() From e7573241842a2937e78d2f76134087b41efa2b1c Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 5 May 2020 12:18:19 +0300 Subject: [PATCH 38/67] head-branch^ --- git-wizard | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-wizard b/git-wizard index 1e9386b..7fcbeac 100755 --- a/git-wizard +++ b/git-wizard @@ -235,14 +235,15 @@ head-branch() rep head "%1 '@v'" 'describe --all --contains --always' acti head ' ' 'print report' report actg head c 'show the last commit' 'show --stat' + acti head e "edit with vim quickfix" "vim -q <(git show -U0 --relative --no-prefix | diff_to_quickfix)" actg head l 'list recent log' 'log --pretty="format:%ar: %ae: %h %s" --reverse -n $((LINES-2))' actg head s "check head status" 'status --untracked-files=no HEAD' # without modifered acti head k "explore with gitk" "gitk" actg head a "amend the last commit" "commit --amend" - rep branch '' 'rev-parse --abbrev-ref HEAD' + rep branch '%1' 'rev-parse --abbrev-ref HEAD' rep local_branches '%1' 'branch | wc -l' - branches_format='%(committerdate:short) - %(align:left,25)%(committerdate:relative)%(end) %(align:left,25)%(objectname:short) %(refname:short)%(end) %(subject)' + branches_format='%(committerdate:short) - %(align:left,25)%(committerdate:relative) %(upstream:trackshort) %(end) %(align:left,25)%(objectname:short) %(refname:short)%(end) %(subject)' actg local_branches ' ' 'list' "for-each-ref --sort=committerdate --format '$branches_format' refs/heads" rep remote_branches '%1' 'branch --remote | wc -l' actg remote_branches ' ' 'list recent' "branch --remotes --sort=committerdate --format '$branches_format' | tail -n $((LINES-2))" @@ -261,7 +262,7 @@ remote() test -e $h && prop l fetch_age '%1 (min) @v' "$(((`date +%s` - `stat -c %Z $h`) / 60))" #((fetch= ! ${#fetch_age} || $prop[fetch_age] > 10 || $prop[fetch_age] < 0)) if [[ -z "$prop[fetch_age]" || "$prop[fetch_age]" -gt 10 || "$prop[fetch_age]" -lt 0 ]]; then - git fetch --all + git fetch --all --prune fi prs local_commits '%1' 'rev-list --count @{u}..HEAD' actg local_commits ' ' "list" "log ..@{u}" From ec8e044c34c817f0deb834664a54baa95b97c047 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 5 May 2020 12:33:59 +0300 Subject: [PATCH 39/67] *readme --- README.rst | 55 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/README.rst b/README.rst index 8b3d612..8e95aba 100644 --- a/README.rst +++ b/README.rst @@ -1,17 +1,17 @@ git-wizard - instant git magic and tricks ===== +Interactive cli git utility for efficient work + Wizard's vision: collect git tricks, troubleshooting techniques and git wisdom under one hat and perform them interactively in dialogue. -git-wizard scans status for your repository and suggests to perform suitable -operations. Beginners can enjoy interactively learn git functionality. Experienced command line git users can save they time by using the wizard to preform frequent operations. For example when you have a merge conflict the wizard first of all suggests -to run mergetool. +you to run mergetool. .. contents:: :local: @@ -19,35 +19,46 @@ to run mergetool. Features **** +Fast +---- +* Requires minimal key presses to perform requires actions. +* Faster then raw git cli or gui for many actions + +Comfortable +---- +* Prints improved reports +* Takes on routine tasks automatically + +Smart +---- +* Prioritizes issues accordingly importance +* Filters unstable and proposes to perform suitable tasks + +For example the wizard proposes add changes to stage only when +there are changed files. + +Details +**** + +Internal checks +---- Each iteration the wizard checks whether the repository contains collisions, operations in progress, conflicts, unmerged files, changes, stashes, ahead/behind commits, untracked files. Periodically automatically it performs fetch. -Some valuable short messages the wizard tells you audiable via application +Some valuable short messages the wizard tells you audible via application espeak. -The wizard uses following commands under the hood: - -* init -* status -* add -* commit -* mergetool -* diff -* fetch -* push -* pull -* clone -* stash -* log -* clean -* gui and gitk -* espeak +Internal actions +---- +The wizard uses following commands under the hood: init, status, add, +commit, mergetool, diff, fetch, push, pull, clone, stash, log, clean, +gui and gitk, espeak Report ---- -Just reports current status of the repostory: +Just reports current status of the repository: git-wizard report:: From 6cdbb9b7e03e4c6c0d5befa6b6a4cf94be50baa3 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Tue, 5 May 2020 13:38:51 +0300 Subject: [PATCH 40/67] try to correct some grammar (#2) --- README.rst | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/README.rst b/README.rst index 8e95aba..57a2b37 100644 --- a/README.rst +++ b/README.rst @@ -1,17 +1,17 @@ git-wizard - instant git magic and tricks ===== -Interactive cli git utility for efficient work +An interactive git `Command-line interface (CLI)` utility for working efficiently. -Wizard's vision: collect git tricks, troubleshooting techniques and git wisdom -under one hat and perform them interactively in dialogue. +Git-Wizard's vision: collect git tricks, troubleshooting techniques and git wisdom +under one hat and perform them interactively. -Beginners can enjoy interactively learn git functionality. -Experienced command line git users can save they time by using the wizard -to preform frequent operations. +Beginners can enjoy learning git functionality interactively. +Experienced command line git users can save time by using the wizard +to perform frequent operations. -For example when you have a merge conflict the wizard first of all suggests -you to run mergetool. +For example, when you have a merge conflict the wizard first suggests +that you run mergetool. .. contents:: :local: @@ -21,20 +21,20 @@ Features Fast ---- -* Requires minimal key presses to perform requires actions. -* Faster then raw git cli or gui for many actions +* Requires minimal key presses to perform the necessary actions. +* Faster then raw git CLI or GUI for many actions. Comfortable ---- -* Prints improved reports -* Takes on routine tasks automatically +* Displays improved reports. +* Automatically performs routine tasks. Smart ---- -* Prioritizes issues accordingly importance -* Filters unstable and proposes to perform suitable tasks +* Prioritizes issues by their importance. +* Filters unsuitable tasks and proposes to perform suitable ones. -For example the wizard proposes add changes to stage only when +For example, the wizard proposes to stage changes only when there are changed files. Details @@ -42,23 +42,24 @@ Details Internal checks ---- -Each iteration the wizard checks whether the repository contains collisions, +Each iteration, the wizard checks whether the repository contains collisions, operations in progress, conflicts, unmerged files, -changes, stashes, ahead/behind commits, untracked files. -Periodically automatically it performs fetch. -Some valuable short messages the wizard tells you audible via application -espeak. +changes, stashes, ahead/behind commits, and untracked files. + +It performs "git fetch" periodically and automatically. + +It pronounces some valuable short messages audibly using the espeak application. Internal actions ---- The wizard uses following commands under the hood: init, status, add, commit, mergetool, diff, fetch, push, pull, clone, stash, log, clean, -gui and gitk, espeak +gui and gitk, espeak. Report ---- -Just reports current status of the repository: +Reports the current status of the repository: git-wizard report:: @@ -87,5 +88,5 @@ Other features To do **** -* Analize details of 'in progress' status. +* Analyze the details of 'in progress' status. * **You are welcome to request new features and add git tricks** From 569d9bf7f43550851451ed3bbab3c7dc28d47b54 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Thu, 14 May 2020 07:27:56 +0300 Subject: [PATCH 41/67] unconditional fetch --- git-wizard | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/git-wizard b/git-wizard index 7fcbeac..700457a 100755 --- a/git-wizard +++ b/git-wizard @@ -257,13 +257,13 @@ head-branch() remote() { rep remote '%1' "config --get branch.$prop[branch].remote" + local h=$git_dir/FETCH_HEAD + test -e $h && prop l fetch_age '%1 (min) @v' "$(((`date +%s` - `stat -c %Z $h`) / 60))" + #((fetch= ! ${#fetch_age} || $prop[fetch_age] > 10 || $prop[fetch_age] < 0)) + if [[ -z "$prop[fetch_age]" || "$prop[fetch_age]" -gt 10 || "$prop[fetch_age]" -lt 0 ]]; then + git fetch --all --prune + fi if [[ $prop[remote] ]]; then - local h=$git_dir/FETCH_HEAD - test -e $h && prop l fetch_age '%1 (min) @v' "$(((`date +%s` - `stat -c %Z $h`) / 60))" - #((fetch= ! ${#fetch_age} || $prop[fetch_age] > 10 || $prop[fetch_age] < 0)) - if [[ -z "$prop[fetch_age]" || "$prop[fetch_age]" -gt 10 || "$prop[fetch_age]" -lt 0 ]]; then - git fetch --all --prune - fi prs local_commits '%1' 'rev-list --count @{u}..HEAD' actg local_commits ' ' "list" "log ..@{u}" actg local_commits p "Push to remote" push From 500757eb15e2ba0d926fc02bc0657df680e757d1 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 26 May 2020 18:20:18 +0300 Subject: [PATCH 42/67] git-status-parse --- git-wizard | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/git-wizard b/git-wizard index 700457a..92c394d 100755 --- a/git-wizard +++ b/git-wizard @@ -181,6 +181,20 @@ report() echo } +git-status-parse() +{ + git status | while read a; do \ + if [[ "$a" =~ "currently (.*) commit ([^.]*)" ]]; then prop[in_progress]=$match[1]; hash=$match[2]; fi + [[ "$a" =~ "currently ([^ ]*)" ]] && prop[in_progress]=$match[1] + [[ "$a" =~ "while ([^ ]*)" ]] && prop[in_progress]=$match[1] + [[ "$a" =~ 'git ((.*) --edit-todo)' ]] && actg in_progress v "view and edit $match[2]" "$match[1]" + [[ "$a" =~ 'git ((.*) --continue)' ]] && actg in_progress c "continue $match[2]" "$match[1]" + [[ "$a" =~ 'git ((.*) --skip)' ]] && actg in_progress s "skip patch '$(cat $prop[root]/.git/rebase-apply/final-commit)'" "$match[1]" + [[ "$a" =~ 'git ((.*) --abort)' ]] && actg in_progress C "cancel $match[2]" "$match[1]" + [[ "$a" =~ 'git (am --show-current-patch)' ]] && actg in_progress c "Show current patch" "$match[1]" + done +} + in_progress() { local conflict_pattern='^\(^<<<<<<<\)\|\(^>>>>>>>\)' @@ -192,8 +206,7 @@ in_progress() prop s in_progress '%1' "$(git status --untracked-files=no HEAD | grep -q -e "You are" -e "in progress" && echo "an operation")" actg in_progress ' ' "Check head status" 'status --untracked-files=no HEAD' # without modifered - actg in_progress c "Continue rebase" 'rebase --continue' - actg in_progress p "Show current patch" 'am --show-current-patch' + git-status-parse # TODO: # git status -uno HEAD | grep 'rebase in progress' # git commit --amend From 75d45d7569eb337ae84386fcbfeead3d1868ea89 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 26 May 2020 18:21:29 +0300 Subject: [PATCH 43/67] * head-branch head-branch untracked --- git-wizard | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/git-wizard b/git-wizard index 92c394d..16b4f40 100755 --- a/git-wizard +++ b/git-wizard @@ -252,11 +252,12 @@ head-branch() actg head l 'list recent log' 'log --pretty="format:%ar: %ae: %h %s" --reverse -n $((LINES-2))' actg head s "check head status" 'status --untracked-files=no HEAD' # without modifered acti head k "explore with gitk" "gitk" + acti head t "text-mode interface for Git" tig actg head a "amend the last commit" "commit --amend" rep branch '%1' 'rev-parse --abbrev-ref HEAD' rep local_branches '%1' 'branch | wc -l' - branches_format='%(committerdate:short) - %(align:left,25)%(committerdate:relative) %(upstream:trackshort) %(end) %(align:left,25)%(objectname:short) %(refname:short)%(end) %(subject)' + branches_format=$'%(committerdate:short) - %(align:left,25)%(committerdate:relative) %(upstream:trackshort) %(end) %(align:left,25)%(objectname:short) \e[1m%(refname:short)\e[0m%(end) %(subject)' actg local_branches ' ' 'list' "for-each-ref --sort=committerdate --format '$branches_format' refs/heads" rep remote_branches '%1' 'branch --remote | wc -l' actg remote_branches ' ' 'list recent' "branch --remotes --sort=committerdate --format '$branches_format' | tail -n $((LINES-2))" @@ -293,7 +294,8 @@ action_itemes() acti action_itemes 'e' edit 'vim -q <(git grep -w -n -eTODO -eFIXME)' prs gone_branches '%1' "branch -vv | grep ': gone]' | wc -l" - actg gone_branches 'D' "delete gone branches" 'branch -d $(git branch --format="%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(else)%(end)")' + actg gone_branches 'd' "delete merged gone branches" 'branch -d $(git branch --format="%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(else)%(end)")' + actg gone_branches 'D' "delete all gone branches" 'branch -D $(git branch --format="%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(else)%(end)")' } untracked() @@ -301,7 +303,8 @@ untracked() prs untracked '%1 file(s)' 'ls-files --others --exclude-standard --directory| wc -l' actg untracked ' ' "list" 'status --untracked-files=normal' actg untracked a "add and stage" 'add --interactive' - actg untracked C "cleanup" 'clean --interactive -d' + actg untracked c "cleanup" 'clean --interactive -d' + acti untracked r "remove interactively" 'rm --recursive --interactive=always $(git ls-files --others --directory --exclude-standard --exclude .gitignore)' actg untracked i "ignore" \ 'ls-files --others --directory --exclude-standard --exclude .gitignore \ >> .gitignore' From e4440171336714cb720ecfab37c8b273902f4a65 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 26 May 2020 18:23:08 +0300 Subject: [PATCH 44/67] * untracked, interactively --- git-wizard | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/git-wizard b/git-wizard index 16b4f40..3beb700 100755 --- a/git-wizard +++ b/git-wizard @@ -229,18 +229,18 @@ modified() prs modified '%1 file(s)' 'ls-files --modified | wc -l' actg modified 't' "stat" 'diff --stat' actg modified ' ' "show" 'diff' - actg modified u "update stage with modifications" 'add --patch' - actg modified s "push into stash" 'stash push --patch' - actg modified d "discard" 'checkout --patch' + actg modified u "update stage with modifications interactively" 'add --patch' + actg modified s "push into stash interactively" 'stash push --patch' + actg modified d "discard interactively" 'checkout --patch' acti modified 'e' "edit with vim quickfix" "vim -q <(git diff -U0 --relative --no-prefix | diff_to_quickfix)" + actg modified 'h' "html view" "diff --relative --no-prefix | pygmentize -l diff -f html -O full > modifications.html; xdg-open modifications.html" actg modified 'g' "gui" "gui" prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' actg staged ' ' "show" 'diff --staged' acti staged e "edit with vim quickfix" "vim -q <(git diff -U0 --staged --relative --no-prefix | diff_to_quickfix)" actg staged c "commit" commit - actg staged R "unstage (reset) modifications" 'reset --patch' - + actg staged R "unstage (reset) modifications interactively" 'reset --patch' } head-branch() From 3aa1a22eec58db20697a02b22537400c46f2c461 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Wed, 27 May 2020 19:36:44 +0300 Subject: [PATCH 45/67] verbose --- git-wizard | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-wizard b/git-wizard index 3beb700..968b30a 100755 --- a/git-wizard +++ b/git-wizard @@ -14,6 +14,7 @@ action= while [[ "$1" =~ "^--" ]]; do case $1 in '--quiet') quiet=1; shift;; + '--verbose') verbose=1; shift;; '--action') action=$2; shift 2;; *) echo error: unknown argument $1 @@ -53,7 +54,11 @@ prop() } # functions for reading git property -prop_git() { prop "$1" "$2" "$3" "$(zsh -c "git $4" 2>/dev/null)" } +prop_git() +{ + test "$verbose" && echo checking $2: git $4 + prop "$1" "$2" "$3" "$(zsh -c "git $4" 2>/dev/null)" +} # rep - property for report only rep() { prop_git "l" "$1" "$2" "$3" } From 8b48c29832bb9c09da2ca603db58a24e28f04468 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 9 Aug 2020 12:53:44 +0300 Subject: [PATCH 46/67] +git-get-file() *git-status-parse() --- git-wizard | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/git-wizard b/git-wizard index 968b30a..df7bbd3 100755 --- a/git-wizard +++ b/git-wizard @@ -186,17 +186,33 @@ report() echo } +git-get-file() +{ + REPLY= + cat $prop[root]/.git/$1 2> /dev/null | read + echo "$REPLY" +} + git-status-parse() { - git status | while read a; do \ + local mm=$(git-get-file MERGE_MSG) + local mh=$(git-get-file MERGE_HEAD) + if [[ "$mh" ]]; then prop[in_progress]=merge; fi + local oc=$(git-get-file rebase-apply/original-commit) + local fcm=$(git-get-file rebase-apply/final-commit) + local sc=$(git-get-file rebase-merge/stopped-sha) # also REBASE_HEAD) # + local sm=$(git-get-file rebase-merge/message) # also MERGE_MSG + test "$oc" && actg in_progress s "Show current patch '$fcm'" "show $oc" + test "$sc" && actg in_progress s "Show current patch '$sm'" "show $sc" + git status --untracked-files=no | while read a; do \ if [[ "$a" =~ "currently (.*) commit ([^.]*)" ]]; then prop[in_progress]=$match[1]; hash=$match[2]; fi [[ "$a" =~ "currently ([^ ]*)" ]] && prop[in_progress]=$match[1] [[ "$a" =~ "while ([^ ]*)" ]] && prop[in_progress]=$match[1] - [[ "$a" =~ 'git ((.*) --edit-todo)' ]] && actg in_progress v "view and edit $match[2]" "$match[1]" + [[ "$a" =~ 'git ((.*) --edit-todo)' ]] && actg in_progress v "view and edit $match[2] todo list" "$match[1]" [[ "$a" =~ 'git ((.*) --continue)' ]] && actg in_progress c "continue $match[2]" "$match[1]" - [[ "$a" =~ 'git ((.*) --skip)' ]] && actg in_progress s "skip patch '$(cat $prop[root]/.git/rebase-apply/final-commit)'" "$match[1]" + [[ "$fcm" && "$a" =~ 'git ((.*) --skip)' ]] && actg in_progress S "skip current patch '$fcm'" "$match[1]" + [[ "$sm" && "$a" =~ 'git ((.*) --skip)' ]] && actg in_progress S "skip current patch '$sm'" "$match[1]" [[ "$a" =~ 'git ((.*) --abort)' ]] && actg in_progress C "cancel $match[2]" "$match[1]" - [[ "$a" =~ 'git (am --show-current-patch)' ]] && actg in_progress c "Show current patch" "$match[1]" done } From 9d2f60a71e91ad949408517737e5079b1183ad80 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 9 Aug 2020 12:54:07 +0300 Subject: [PATCH 47/67] *conflicted --- git-wizard | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/git-wizard b/git-wizard index df7bbd3..3abd426 100755 --- a/git-wizard +++ b/git-wizard @@ -218,9 +218,14 @@ git-status-parse() in_progress() { - local conflict_pattern='^\(^<<<<<<<\)\|\(^>>>>>>>\)' - prs conflicted '%1 file(s)' "grep -e '$conflict_pattern' -- $(echo $(git diff --name-only --relative)) null \ - | wc -l | ( read c; echo \$(((c+1)/2)))" + local conflict_pattern='^\(^<<<<<<<\)\|\(^=======\)\|\(^>>>>>>>\)' + #prs conflicted '%1 file(s)' "grep -e '$conflict_pattern' -- $(echo $(git diff --name-only --relative)) null \ + # | wc -l | ( read c; echo \$(((c+2)/3)))" + grep -n -e '\(^<<<<<<<\)\|\(^=======\)\|\(^>>>>>>>\)' -- $(echo $(git diff --name-only --relative)) /dev/null > conflicts + prop s conflicted 'conflict(s)' "$(cat conflicts | wc -l | ( read c; echo $(((c+2)/3))))" + #acti conflicted 'e' "edit with vim quickfix" 'vim -q <(grep -n -e '$conflict_pattern' -- $(echo $(git diff --name-only --relative)))' + #acti conflicted 'e' "edit with vim quickfix" 'vim -q <(grep -n -e '$conflict_pattern' -- $(echo $(git diff --name-only --relative)))' + acti conflicted 'e' "edit with vim quickfix" 'vim -q conflicts' prs unmerged '%1 file(s)' 'ls-files --unmerged | cut -f2 | sort -u | wc -l' actg unmerged t "Run merge tool" mergetool [ $prop[conflicted] = 0 ] && actg unmerged a "Add" "add \$(git diff --name-only --relative)" From bd8a6e51d0c38e226f07fcc639f08fdff6bfb39a Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 9 Aug 2020 12:54:44 +0300 Subject: [PATCH 48/67] *in_progress --- git-wizard | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/git-wizard b/git-wizard index 3abd426..bf3fe0a 100755 --- a/git-wizard +++ b/git-wizard @@ -229,8 +229,9 @@ in_progress() prs unmerged '%1 file(s)' 'ls-files --unmerged | cut -f2 | sort -u | wc -l' actg unmerged t "Run merge tool" mergetool [ $prop[conflicted] = 0 ] && actg unmerged a "Add" "add \$(git diff --name-only --relative)" - - prop s in_progress '%1' "$(git status --untracked-files=no HEAD | grep -q -e "You are" -e "in progress" && echo "an operation")" + # git diff --diff-filter=U --name-only + # git add $(git diff --diff-filter=U --name-only) + prop s in_progress '%1' "$(git status --untracked-files=no HEAD | grep -q -i -e "you are" -e "in progress" && echo "an operation")" actg in_progress ' ' "Check head status" 'status --untracked-files=no HEAD' # without modifered git-status-parse # TODO: From fce20d5ea2215db01f4aceab45163de5d1d66173 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 9 Aug 2020 12:56:09 +0300 Subject: [PATCH 49/67] ->selectively, small fixes --- git-wizard | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/git-wizard b/git-wizard index bf3fe0a..7fb8564 100755 --- a/git-wizard +++ b/git-wizard @@ -256,9 +256,9 @@ modified() prs modified '%1 file(s)' 'ls-files --modified | wc -l' actg modified 't' "stat" 'diff --stat' actg modified ' ' "show" 'diff' - actg modified u "update stage with modifications interactively" 'add --patch' - actg modified s "push into stash interactively" 'stash push --patch' - actg modified d "discard interactively" 'checkout --patch' + actg modified u "update stage with modifications selectively" 'add --patch' + actg modified s "push into stash selectively" 'stash push --patch' + actg modified d "discard selectively" 'checkout --patch' acti modified 'e' "edit with vim quickfix" "vim -q <(git diff -U0 --relative --no-prefix | diff_to_quickfix)" actg modified 'h' "html view" "diff --relative --no-prefix | pygmentize -l diff -f html -O full > modifications.html; xdg-open modifications.html" actg modified 'g' "gui" "gui" @@ -267,7 +267,7 @@ modified() actg staged ' ' "show" 'diff --staged' acti staged e "edit with vim quickfix" "vim -q <(git diff -U0 --staged --relative --no-prefix | diff_to_quickfix)" actg staged c "commit" commit - actg staged R "unstage (reset) modifications interactively" 'reset --patch' + actg staged r "unstage (reset) modifications selectively" 'reset --patch' } head-branch() @@ -276,15 +276,15 @@ head-branch() acti head ' ' 'print report' report actg head c 'show the last commit' 'show --stat' acti head e "edit with vim quickfix" "vim -q <(git show -U0 --relative --no-prefix | diff_to_quickfix)" - actg head l 'list recent log' 'log --pretty="format:%ar: %ae: %h %s" --reverse -n $((LINES-2))' - actg head s "check head status" 'status --untracked-files=no HEAD' # without modifered + actg head l 'list recent log' $'log --pretty="format:%ar: %ae: %h %s \e[4m%D\e[0m" --reverse -n $((LINES-2))' + actg head s "check the head status" 'status --untracked-files=no HEAD' # without modifered acti head k "explore with gitk" "gitk" acti head t "text-mode interface for Git" tig actg head a "amend the last commit" "commit --amend" rep branch '%1' 'rev-parse --abbrev-ref HEAD' rep local_branches '%1' 'branch | wc -l' - branches_format=$'%(committerdate:short) - %(align:left,25)%(committerdate:relative) %(upstream:trackshort) %(end) %(align:left,25)%(objectname:short) \e[1m%(refname:short)\e[0m%(end) %(subject)' + branches_format=$'%(committerdate:short) - %(align:left,25)%(committerdate:relative) %(upstream:trackshort) %(end) %(align:left,25)%(objectname:short) \e[1m%(refname:short)\e[0m%(end) %(subject) \e[3;37m%(authorname)\e[0m' actg local_branches ' ' 'list' "for-each-ref --sort=committerdate --format '$branches_format' refs/heads" rep remote_branches '%1' 'branch --remote | wc -l' actg remote_branches ' ' 'list recent' "branch --remotes --sort=committerdate --format '$branches_format' | tail -n $((LINES-2))" @@ -316,7 +316,7 @@ remote() action_itemes() { - rep action_itemes '%1' 'grep --max-depth=3 -w -eTODO -eFIXME | wc -l' + rep action_itemes '%1' 'grep --max-depth=2 -w -eTODO -eFIXME | wc -l' actg action_itemes ' ' list 'grep -w -n -eTODO -eFIXME' acti action_itemes 'e' edit 'vim -q <(git grep -w -n -eTODO -eFIXME)' @@ -331,7 +331,7 @@ untracked() actg untracked ' ' "list" 'status --untracked-files=normal' actg untracked a "add and stage" 'add --interactive' actg untracked c "cleanup" 'clean --interactive -d' - acti untracked r "remove interactively" 'rm --recursive --interactive=always $(git ls-files --others --directory --exclude-standard --exclude .gitignore)' + acti untracked r "remove selectively" 'rm --recursive --interactive=always $(git ls-files --others --directory --exclude-standard --exclude .gitignore)' actg untracked i "ignore" \ 'ls-files --others --directory --exclude-standard --exclude .gitignore \ >> .gitignore' From c348f9bd80bca1ba0cb8ea7dd2e1cefc06c39420 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 9 Aug 2020 12:59:00 +0300 Subject: [PATCH 50/67] * gone_branches local_commits --- git-wizard | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/git-wizard b/git-wizard index 7fb8564..89156e4 100755 --- a/git-wizard +++ b/git-wizard @@ -301,12 +301,16 @@ remote() local h=$git_dir/FETCH_HEAD test -e $h && prop l fetch_age '%1 (min) @v' "$(((`date +%s` - `stat -c %Z $h`) / 60))" #((fetch= ! ${#fetch_age} || $prop[fetch_age] > 10 || $prop[fetch_age] < 0)) - if [[ -z "$prop[fetch_age]" || "$prop[fetch_age]" -gt 10 || "$prop[fetch_age]" -lt 0 ]]; then + if [[ -z "$prop[fetch_age]" || "$prop[fetch_age]" -gt 360 || "$prop[fetch_age]" -lt 0 ]]; then git fetch --all --prune + + prs gone_branches '%1' "branch -vv | grep ': gone]' | wc -l" + actg gone_branches 'd' "delete merged gone branches" 'branch -d $(git branch --format="%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(else)%(end)")' + actg gone_branches 'D' "delete all gone branches" 'branch -D $(git branch --format="%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(else)%(end)")' fi if [[ $prop[remote] ]]; then - prs local_commits '%1' 'rev-list --count @{u}..HEAD' - actg local_commits ' ' "list" "log ..@{u}" + prs local_commits '%1' 'rev-list --count @{push}..' + actg local_commits ' ' "list" "log @{push}.." actg local_commits p "Push to remote" push rep remote_commits '%1' 'rev-list --count HEAD..@{u}' actg remote_commits ' ' "list" 'log --stat HEAD..@{u}' @@ -319,10 +323,6 @@ action_itemes() rep action_itemes '%1' 'grep --max-depth=2 -w -eTODO -eFIXME | wc -l' actg action_itemes ' ' list 'grep -w -n -eTODO -eFIXME' acti action_itemes 'e' edit 'vim -q <(git grep -w -n -eTODO -eFIXME)' - - prs gone_branches '%1' "branch -vv | grep ': gone]' | wc -l" - actg gone_branches 'd' "delete merged gone branches" 'branch -d $(git branch --format="%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(else)%(end)")' - actg gone_branches 'D' "delete all gone branches" 'branch -D $(git branch --format="%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(else)%(end)")' } untracked() From 7bfda977befe2ad4a3da67a6889b779d913172ea Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 9 Aug 2020 12:59:48 +0300 Subject: [PATCH 51/67] +tools --- git-wizard | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-wizard b/git-wizard index 89156e4..46128c2 100755 --- a/git-wizard +++ b/git-wizard @@ -260,14 +260,17 @@ modified() actg modified s "push into stash selectively" 'stash push --patch' actg modified d "discard selectively" 'checkout --patch' acti modified 'e' "edit with vim quickfix" "vim -q <(git diff -U0 --relative --no-prefix | diff_to_quickfix)" - actg modified 'h' "html view" "diff --relative --no-prefix | pygmentize -l diff -f html -O full > modifications.html; xdg-open modifications.html" + actg modified 'h' "html view" "diff --relative --no-prefix | pygmentize -l diff -O full -o modifications.html; xdg-open modifications.html" + actg modified 'l' "run difftool" "difftool" actg modified 'g' "gui" "gui" prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' actg staged ' ' "show" 'diff --staged' acti staged e "edit with vim quickfix" "vim -q <(git diff -U0 --staged --relative --no-prefix | diff_to_quickfix)" actg staged c "commit" commit + actg staged g "run GUI commit tools" citool actg staged r "unstage (reset) modifications selectively" 'reset --patch' + actg staged R "unstage (reset) all modifications" reset } head-branch() From e3ce78d2ac1fb9c9f6095c6d6d08f145363ebcce Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 9 Aug 2020 13:00:52 +0300 Subject: [PATCH 52/67] * --- git-wizard | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-wizard b/git-wizard index 46128c2..f69b25a 100755 --- a/git-wizard +++ b/git-wizard @@ -160,7 +160,7 @@ prop-print() summary() { - local m="Summary: head '$prop[head]'" + local m="Summary: head '$prop[head]' on branch '$prop[branch]'" for key in $keys; do [[ ! $flag[$key] =~ s ]] && continue p="$prop[$key]" @@ -253,6 +253,8 @@ diff_to_quickfix() modified() { + ## checks for modified and staged(cached) files and what to do with them + prs modified '%1 file(s)' 'ls-files --modified | wc -l' actg modified 't' "stat" 'diff --stat' actg modified ' ' "show" 'diff' From c0caddb5a1689c17d8c4af7408731384ff181719 Mon Sep 17 00:00:00 2001 From: Costa Date: Wed, 12 May 2021 14:29:30 +0300 Subject: [PATCH 53/67] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 57a2b37..f795551 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ git-wizard - instant git magic and tricks ===== -An interactive git `Command-line interface (CLI)` utility for working efficiently. +An interactive git shell utility for working efficiently. Git-Wizard's vision: collect git tricks, troubleshooting techniques and git wisdom under one hat and perform them interactively. From 1c32dc17c9b4bba32d22f26d13111b1ab131e8cb Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:19:40 +0200 Subject: [PATCH 54/67] * --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index f795551..b114764 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ git-wizard - instant git magic and tricks An interactive git shell utility for working efficiently. -Git-Wizard's vision: collect git tricks, troubleshooting techniques and git wisdom +Vision: collect git tricks, troubleshooting techniques and git wisdom under one hat and perform them interactively. Beginners can enjoy learning git functionality interactively. From d86c7345a79b947f5e3da3666cd79b0d0c3745ac Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:21:49 +0200 Subject: [PATCH 55/67] *conflicts --- git-wizard | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-wizard b/git-wizard index f69b25a..2b0597f 100755 --- a/git-wizard +++ b/git-wizard @@ -218,10 +218,10 @@ git-status-parse() in_progress() { - local conflict_pattern='^\(^<<<<<<<\)\|\(^=======\)\|\(^>>>>>>>\)' + local conflict_pattern='^\(^<<<<<<< \)\|\(^=======$\)\|\(^>>>>>>> \)' #prs conflicted '%1 file(s)' "grep -e '$conflict_pattern' -- $(echo $(git diff --name-only --relative)) null \ # | wc -l | ( read c; echo \$(((c+2)/3)))" - grep -n -e '\(^<<<<<<<\)\|\(^=======\)\|\(^>>>>>>>\)' -- $(echo $(git diff --name-only --relative)) /dev/null > conflicts + grep -s -r -n -e "$conflict_pattern" -- $(echo $(git diff --name-only --relative)) /dev/null > conflicts prop s conflicted 'conflict(s)' "$(cat conflicts | wc -l | ( read c; echo $(((c+2)/3))))" #acti conflicted 'e' "edit with vim quickfix" 'vim -q <(grep -n -e '$conflict_pattern' -- $(echo $(git diff --name-only --relative)))' #acti conflicted 'e' "edit with vim quickfix" 'vim -q <(grep -n -e '$conflict_pattern' -- $(echo $(git diff --name-only --relative)))' From a48aeffed9c94216ba58ad1e19bef092ce757a37 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:22:31 +0200 Subject: [PATCH 56/67] select_branch --- git-wizard | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/git-wizard b/git-wizard index 2b0597f..b04a522 100755 --- a/git-wizard +++ b/git-wizard @@ -241,6 +241,13 @@ in_progress() } +select_branch() +{ + select a in $(git branch --format='%(refname:short)'); do break; done + [ $quiet = 0 ] && espeak -v en+f4 "Selected branch $a" 2> /dev/null & + echo $a +} + diff_to_quickfix() { local file= @@ -291,6 +298,7 @@ head-branch() rep local_branches '%1' 'branch | wc -l' branches_format=$'%(committerdate:short) - %(align:left,25)%(committerdate:relative) %(upstream:trackshort) %(end) %(align:left,25)%(objectname:short) \e[1m%(refname:short)\e[0m%(end) %(subject) \e[3;37m%(authorname)\e[0m' actg local_branches ' ' 'list' "for-each-ref --sort=committerdate --format '$branches_format' refs/heads" + actg local_branches 's' 'switch' 'switch $(select_branch)' rep remote_branches '%1' 'branch --remote | wc -l' actg remote_branches ' ' 'list recent' "branch --remotes --sort=committerdate --format '$branches_format' | tail -n $((LINES-2))" From c115ddb9191a0324403529ee99d3d7d082bfa88f Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:22:59 +0200 Subject: [PATCH 57/67] *branch --- git-wizard | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/git-wizard b/git-wizard index b04a522..034de18 100755 --- a/git-wizard +++ b/git-wizard @@ -294,9 +294,13 @@ head-branch() acti head t "text-mode interface for Git" tig actg head a "amend the last commit" "commit --amend" - rep branch '%1' 'rev-parse --abbrev-ref HEAD' + rep branch "%1 '@v'" 'rev-parse --abbrev-ref HEAD' rep local_branches '%1' 'branch | wc -l' - branches_format=$'%(committerdate:short) - %(align:left,25)%(committerdate:relative) %(upstream:trackshort) %(end) %(align:left,25)%(objectname:short) \e[1m%(refname:short)\e[0m%(end) %(subject) \e[3;37m%(authorname)\e[0m' + branches_format=( + $'%(committerdate:short) - %(align:left,25)%(committerdate:relative)' + $'%(upstream:trackshort) %(end)' + $'%(align:left,25)\e[37m%(objectname:short)\e[0m \e[1m%(refname:short)\e[0m%(end)' + $'%(subject)\e[3;37m. %(authorname)\e[0m') actg local_branches ' ' 'list' "for-each-ref --sort=committerdate --format '$branches_format' refs/heads" actg local_branches 's' 'switch' 'switch $(select_branch)' rep remote_branches '%1' 'branch --remote | wc -l' From e35f733501cc6a360d06b6410c37f92bd54e05dc Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:23:21 +0200 Subject: [PATCH 58/67] undo, drop --- git-wizard | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-wizard b/git-wizard index 034de18..4195a5d 100755 --- a/git-wizard +++ b/git-wizard @@ -293,6 +293,7 @@ head-branch() acti head k "explore with gitk" "gitk" acti head t "text-mode interface for Git" tig actg head a "amend the last commit" "commit --amend" + actg head u "undo the last commit" "reset --soft HEAD~1" rep branch "%1 '@v'" 'rev-parse --abbrev-ref HEAD' rep local_branches '%1' 'branch | wc -l' @@ -309,6 +310,7 @@ head-branch() prs stashes '%1' 'stash list | wc -l' actg stashes ' ' "show and list stash" 'stash show; git stash list --stat' actg stashes o "pop from stash" 'stash pop' + actg stashes d "drop the topmost stash" 'stash drop' rep commited '%1' 'log -1 --format="%ar"' } From 898b9fa42724de657a855c5457b77a2f58d37c17 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:24:19 +0200 Subject: [PATCH 59/67] *action_itemes --- git-wizard | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-wizard b/git-wizard index 4195a5d..690ee16 100755 --- a/git-wizard +++ b/git-wizard @@ -339,8 +339,8 @@ remote() action_itemes() { - rep action_itemes '%1' 'grep --max-depth=2 -w -eTODO -eFIXME | wc -l' - actg action_itemes ' ' list 'grep -w -n -eTODO -eFIXME' + rep action_itemes '%1' 'grep --no-messages --max-depth=2 -w -eTODO -eFIXME | wc -l' + actg action_itemes ' ' list 'grep --no-messages -w -n -eTODO -eFIXME' acti action_itemes 'e' edit 'vim -q <(git grep -w -n -eTODO -eFIXME)' } From 3df4d116db51ceb47cd434f90cb473bb93f080df Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:24:33 +0200 Subject: [PATCH 60/67] no remote --- git-wizard | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/git-wizard b/git-wizard index 690ee16..5afbb76 100755 --- a/git-wizard +++ b/git-wizard @@ -334,6 +334,14 @@ remote() rep remote_commits '%1' 'rev-list --count HEAD..@{u}' actg remote_commits ' ' "list" 'log --stat HEAD..@{u}' actg remote_commits l "pull from remote" 'pull --autostash' + else # when there is no remote assigned + rep head_remote '%1' "config --get branch.$prop[head].remote" + if hr=$prop[head_remote] && [ $prop[branch] != HEAD ]; then + echo head_remote $prop[head_remote] + echo hr $hr + echo branch $prop[branch] + actg branch p "Push new branch to remote $hr" "push --set-upstream $hr $prop[branch]" + fi fi } From c61d49b3890ce96738cfed868618cbeefe2e643a Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:24:54 +0200 Subject: [PATCH 61/67] *fetch_age --- git-wizard | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-wizard b/git-wizard index 5afbb76..2e8855a 100755 --- a/git-wizard +++ b/git-wizard @@ -318,7 +318,9 @@ remote() { rep remote '%1' "config --get branch.$prop[branch].remote" local h=$git_dir/FETCH_HEAD - test -e $h && prop l fetch_age '%1 (min) @v' "$(((`date +%s` - `stat -c %Z $h`) / 60))" + test -e $h && + prop l fetch_age '%1 (min) @v' \ + "$(((`date +%s` - `stat -c %Z $h`) / 60))" #((fetch= ! ${#fetch_age} || $prop[fetch_age] > 10 || $prop[fetch_age] < 0)) if [[ -z "$prop[fetch_age]" || "$prop[fetch_age]" -gt 360 || "$prop[fetch_age]" -lt 0 ]]; then git fetch --all --prune From 37c65c86ecc1c8893c829ffdfa594e6be6756c2a Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:25:15 +0200 Subject: [PATCH 62/67] *unit-tests --- git-wizard | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/git-wizard b/git-wizard index 2e8855a..c707500 100755 --- a/git-wizard +++ b/git-wizard @@ -400,15 +400,32 @@ gitw-start() esac } +fail() +{ + let fails+=1 + set | grep HIST + history + setopt + echo +} + [ "$1" = unit-tests ] && { local fails=0 - d=$(mktemp -d) + #d=$(mktemp -d) + d=/tmp/git-wizard-test + rm -rf $d + mkdir $d pushd $d - git-wizard --action y || { echo Fail && false } - let fails+=$? + touch empty + HISTFILE=qqq + SAVEHIST=3 + set -o pipefail + git-wizard --action y | grep Initialized || fail + ls -A + #git-wizard popd - rm -rf $d + #rm -rf $d echo Fails: $fails exit $fails } From 2d6e811fdece70c71fed904efe300b3911196475 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:25:54 +0200 Subject: [PATCH 63/67] xdg-open --- git-wizard | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/git-wizard b/git-wizard index c707500..b27d261 100755 --- a/git-wizard +++ b/git-wizard @@ -258,6 +258,14 @@ diff_to_quickfix() #perl -ne '/^\+\+\+ (.+)/ && { $f="$1"};/@@.*\+(\d+)/ &&print "$f:$1:$_\n"' } +xdg-open() +{ + + test "$SSH_CLIENT" \ + && ssh ${SSH_CLIENT%% *} xdg-open $PWD/modifications.html \ + || /usr/bin/xdg-open "$@" +} + modified() { ## checks for modified and staged(cached) files and what to do with them From af586d4ff965f487f8917e9881159f1776b6522b Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 10:27:48 +0200 Subject: [PATCH 64/67] modifications, reset-actions --- git-wizard | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/git-wizard b/git-wizard index b27d261..3675f3f 100755 --- a/git-wizard +++ b/git-wizard @@ -29,16 +29,23 @@ ask() read -r -k "?$1" } +reset-actions() +{ + actprop=() + actkey=() + conf=() + act=() + restart=1 +} + reset() { prop=() flag=() msg=() keys=() - actprop=() - actkey=() - conf=() - act=() + reset-actions + restart=0 } # function for acquiring common property @@ -266,19 +273,34 @@ xdg-open() || /usr/bin/xdg-open "$@" } +modifications() +{ + reset-actions + git diff --stat + actg modified ' ' "show diff of the modifications" 'diff' + actg modified 'l' "run difftool" "difftool" + actg modified 'h' "html view" "diff --relative --no-prefix | pygmentize -l diff -O full -o modifications.html; xdg-open modifications.html" + print-actions + ask '>' + [ "$REPLY" = $'\n' ] && return + echo + [ -z "$actk[$REPLY]" ] && return + test "$verbose" && echo "$actk[$REPLY]" + eval $actk[$REPLY] + test "$action" && exit + break +} + modified() { ## checks for modified and staged(cached) files and what to do with them prs modified '%1 file(s)' 'ls-files --modified | wc -l' - actg modified 't' "stat" 'diff --stat' - actg modified ' ' "show" 'diff' + acti modified ' ' "show modifications" "modifications" actg modified u "update stage with modifications selectively" 'add --patch' actg modified s "push into stash selectively" 'stash push --patch' actg modified d "discard selectively" 'checkout --patch' acti modified 'e' "edit with vim quickfix" "vim -q <(git diff -U0 --relative --no-prefix | diff_to_quickfix)" - actg modified 'h' "html view" "diff --relative --no-prefix | pygmentize -l diff -O full -o modifications.html; xdg-open modifications.html" - actg modified 'l' "run difftool" "difftool" actg modified 'g' "gui" "gui" prs staged '%1 file(s)' 'diff --name-only --staged | wc -l' From 80663534f7cd99ff172b390d005068cedf9ef2f6 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 13:36:15 +0200 Subject: [PATCH 65/67] message_prev, *out --- git-wizard | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/git-wizard b/git-wizard index 3675f3f..f9f803e 100755 --- a/git-wizard +++ b/git-wizard @@ -4,7 +4,7 @@ # Git Wizard # Interactive front end git wrapper script -declare -A prop flag msg +declare -A prop flag msg message_prev declare -a keys actprop actkey conf act echo | espeak 2> /dev/null @@ -98,10 +98,15 @@ actg() out() { - echo "$1 \e[1m$2\e[0m" + local key=$1 + local prefix=$2 + local message=$3 + echo "$prefix \e[1m$message\e[0m" [ $quiet != 0 ] && return test "$action" && return - espeak "$2" 2> /dev/null & + test "$message_prev[$key]" = "$message" && return + espeak -v en+f4 "$message" 2> /dev/null & + message_prev[$key]="$message" } print-actions() @@ -174,7 +179,7 @@ summary() [ -z "$p" -o "$p" = 0 ] && continue m+=", $(prop-print $key)" done - out "" $m + out "" "" $m } report() @@ -463,7 +468,7 @@ fail() if [ $(git rev-parse --show-toplevel 2> /dev/null) ]; then gitw-start "$@" else - out "" "Here is no a git repository" + out "" "" "Here is no a git repository" for c in $(xsel) $(xsel --clipboard); do if _=$(expr match "$c" ".*:.*/.*git.*"); then echo "Clipboard content looks like git url: $c" From a7158f1d027054942e6325d48265fcdd1a626958 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 13:36:31 +0200 Subject: [PATCH 66/67] ^print-actions --- git-wizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-wizard b/git-wizard index f9f803e..ea68cff 100755 --- a/git-wizard +++ b/git-wizard @@ -115,7 +115,7 @@ print-actions() [[ $actprop[$n] != $key ]] && continue kk+=($actkey[$n]) actk[$actkey[$n]]=$act[$n] - echo " [$actkey[$n]] - $conf[$n]" + echo " ﹝$actkey[$n]﹞ — $conf[$n]" } echo " [Enter] - continue" echo " * - exit" From f1598db36ee1fa672541d0b3a0a954a5ea930849 Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Sun, 20 Feb 2022 13:36:48 +0200 Subject: [PATCH 67/67] ^verbose --- git-wizard | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-wizard b/git-wizard index ea68cff..edf51d5 100755 --- a/git-wizard +++ b/git-wizard @@ -80,6 +80,7 @@ prs() { prop_git "s" "$1" "$2" "$3" } # internal action acti() { + test "$verbose" && echo acti "$@" actprop+=($1) #[[ "${actkey[(ie)$2]}" -le "${#actkey}" ]] && echo "duplicated key $2" actkey+=("$2") @@ -138,6 +139,7 @@ perform-actions() [ "$REPLY" = $'\n' ] && continue echo [ -z "$actk[$REPLY]" ] && return 1 + test "$verbose" && echo "$actk[$REPLY]" eval $actk[$REPLY] test "$action" && exit break