git: clean up plugin file and delete current_repository function

Closes #6329
This commit is contained in:
Marc Cornellà 2019-05-21 10:57:37 +02:00
parent f8d5fdce3a
commit 4ad4a81657
2 changed files with 20 additions and 34 deletions

View file

@ -191,7 +191,6 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa
| Command | Description | | Command | Description |
|:-----------------------|:----------------------------------------| |:-----------------------|:----------------------------------------|
| current_branch | Return the name of the current branch | | current_branch | Return the name of the current branch |
| current_repository | Return the names of the current remotes |
| git_current_user_name | Returns the `user.name` config value | | git_current_user_name | Returns the `user.name` config value |
| git_current_user_email | Returns the `user.email` config value | | git_current_user_email | Returns the `user.email` config value |
@ -204,3 +203,9 @@ These features allow to pause a branch development and switch to another one (_"
| work_in_progress | Echoes a warning if the current branch is a wip | | work_in_progress | Echoes a warning if the current branch is a wip |
| gwip | Commit wip branch | | gwip | Commit wip branch |
| gunwip | Uncommit wip branch | | gunwip | Uncommit wip branch |
### Deprecated
| Command | Description | Reason |
|:-----------------------|:----------------------------------------|:----------------------------------------------------------------|
| current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) |

View file

@ -1,7 +1,3 @@
# Query/use custom command for `git`.
zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
: ${_omz_git_git_cmd:=git}
# #
# Functions # Functions
# #
@ -13,19 +9,15 @@ zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
function current_branch() { function current_branch() {
git_current_branch git_current_branch
} }
# The list of remotes
function current_repository() {
if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then
return
fi
echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2)
}
# Pretty log messages # Pretty log messages
function _git_log_prettily(){ function _git_log_prettily(){
if ! [ -z $1 ]; then if ! [ -z $1 ]; then
git log --pretty=$1 git log --pretty=$1
fi fi
} }
compdef _git _git_log_prettily=git-log
# Warn if the current branch is a WIP # Warn if the current branch is a WIP
function work_in_progress() { function work_in_progress() {
if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
@ -80,7 +72,6 @@ alias gcd='git checkout develop'
alias gcmsg='git commit -m' alias gcmsg='git commit -m'
alias gco='git checkout' alias gco='git checkout'
alias gcount='git shortlog -sn' alias gcount='git shortlog -sn'
compdef _git gcount
alias gcp='git cherry-pick' alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort' alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue' alias gcpc='git cherry-pick --continue'
@ -89,35 +80,35 @@ alias gcs='git commit -S'
alias gd='git diff' alias gd='git diff'
alias gdca='git diff --cached' alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff' alias gdcw='git diff --cached --word-diff'
alias gdct='git describe --tags `git rev-list --tags --max-count=1`' alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gds='git diff --staged' alias gds='git diff --staged'
alias gdt='git diff-tree --no-commit-id --name-only -r' alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdw='git diff --word-diff' alias gdw='git diff --word-diff'
gdv() { git diff -w "$@" | view - } function gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff compdef _git gdv=git-diff
alias gf='git fetch' alias gf='git fetch'
alias gfa='git fetch --all --prune' alias gfa='git fetch --all --prune'
alias gfo='git fetch origin' alias gfo='git fetch origin'
function gfg() { git ls-files | grep $@ } alias gfg='git ls-files | grep'
compdef _grep gfg
alias gg='git gui citool' alias gg='git gui citool'
alias gga='git gui citool --amend' alias gga='git gui citool --amend'
ggf() { function ggf() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)" [[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force origin "${b:=$1}" git push --force origin "${b:=$1}"
} }
ggfl() { compdef _git ggf=git-checkout
function ggfl() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)" [[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force-with-lease origin "${b:=$1}" git push --force-with-lease origin "${b:=$1}"
} }
compdef _git ggf=git-checkout compdef _git ggfl=git-checkout
ggl() { function ggl() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git pull origin "${*}" git pull origin "${*}"
else else
@ -127,7 +118,7 @@ ggl() {
} }
compdef _git ggl=git-checkout compdef _git ggl=git-checkout
ggp() { function ggp() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git push origin "${*}" git push origin "${*}"
else else
@ -137,7 +128,7 @@ ggp() {
} }
compdef _git ggp=git-checkout compdef _git ggp=git-checkout
ggpnp() { function ggpnp() {
if [[ "$#" == 0 ]]; then if [[ "$#" == 0 ]]; then
ggl && ggp ggl && ggp
else else
@ -146,20 +137,15 @@ ggpnp() {
} }
compdef _git ggpnp=git-checkout compdef _git ggpnp=git-checkout
ggu() { function ggu() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)" [[ "$#" != 1 ]] && local b="$(git_current_branch)"
git pull --rebase origin "${b:=$1}" git pull --rebase origin "${b:=$1}"
} }
compdef _git ggu=git-checkout compdef _git ggu=git-checkout
alias ggpur='ggu' alias ggpur='ggu'
compdef _git ggpur=git-checkout
alias ggpull='git pull origin "$(git_current_branch)"' alias ggpull='git pull origin "$(git_current_branch)"'
compdef _git ggpull=git-checkout
alias ggpush='git push origin "$(git_current_branch)"' alias ggpush='git push origin "$(git_current_branch)"'
compdef _git ggpush=git-checkout
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias gpsup='git push --set-upstream origin $(git_current_branch)' alias gpsup='git push --set-upstream origin $(git_current_branch)'
@ -169,12 +155,9 @@ alias ghh='git help'
alias gignore='git update-index --assume-unchanged' alias gignore='git update-index --assume-unchanged'
alias gignored='git ls-files -v | grep "^[[:lower:]]"' alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
compdef _git git-svn-dcommit-push=git
alias gk='\gitk --all --branches' alias gk='\gitk --all --branches'
compdef _git gk='gitk'
alias gke='\gitk --all $(git log -g --pretty=%h)' alias gke='\gitk --all $(git log -g --pretty=%h)'
compdef _git gke='gitk'
alias gl='git pull' alias gl='git pull'
alias glg='git log --stat' alias glg='git log --stat'
@ -191,7 +174,6 @@ alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgr
alias glog='git log --oneline --decorate --graph' alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all' alias gloga='git log --oneline --decorate --graph --all'
alias glp="_git_log_prettily" alias glp="_git_log_prettily"
compdef _git glp=git-log
alias gm='git merge' alias gm='git merge'
alias gmom='git merge origin/master' alias gmom='git merge origin/master'
@ -205,7 +187,6 @@ alias gpd='git push --dry-run'
alias gpf='git push --force-with-lease' alias gpf='git push --force-with-lease'
alias gpf!='git push --force' alias gpf!='git push --force'
alias gpoat='git push origin --all && git push origin --tags' alias gpoat='git push origin --all && git push origin --tags'
compdef _git gpoat=git-push
alias gpu='git push upstream' alias gpu='git push upstream'
alias gpv='git push -v' alias gpv='git push -v'