forked from misc/zsh-config
Changed "colors" app nam in enabled apps config to "showcolors".
Fixed gitinfo application, now it would not spam on jist-git-init'ed repos, fixing #1. Also reworked checks things, now every function will call gitinfo_internal_checks function and do nothing if internal checks method returns 1.
This commit is contained in:
parent
64a3d533fa
commit
a12c9bcff9
@ -12,8 +12,8 @@ GITINFO_STASHES_COUNT=0
|
|||||||
######################################################################
|
######################################################################
|
||||||
function gitinfo()
|
function gitinfo()
|
||||||
{
|
{
|
||||||
curdir=`pwd`
|
gitinfo_internal_checks
|
||||||
if [ ! -d "${curdir}/.git" ]; then
|
if [ $? -eq 1 ]; then
|
||||||
echo "This is not a git repository."
|
echo "This is not a git repository."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -54,9 +54,15 @@ function gitinfo_chpwd()
|
|||||||
function gitinfo_check()
|
function gitinfo_check()
|
||||||
{
|
{
|
||||||
curdir=`pwd`
|
curdir=`pwd`
|
||||||
|
|
||||||
if [ "${#GITINFO_BRANCH}" -eq 0 ]; then
|
if [ "${#GITINFO_BRANCH}" -eq 0 ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
objects=`ls .git/objects | grep -v "info\|pack" | wc -l`
|
||||||
|
if [ ${objects} -lt 1 ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
@ -64,8 +70,8 @@ function gitinfo_check()
|
|||||||
######################################################################
|
######################################################################
|
||||||
function gitinfo_get_branch()
|
function gitinfo_get_branch()
|
||||||
{
|
{
|
||||||
curdir=`pwd`
|
gitinfo_internal_checks
|
||||||
if [ ! -d "${curdir}/.git" ]; then
|
if [ $? -eq 1 ]; then
|
||||||
GITINFO_BRANCH=""
|
GITINFO_BRANCH=""
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -77,8 +83,8 @@ function gitinfo_get_branch()
|
|||||||
######################################################################
|
######################################################################
|
||||||
function gitinfo_get_changes()
|
function gitinfo_get_changes()
|
||||||
{
|
{
|
||||||
curdir=`pwd`
|
gitinfo_internal_checks
|
||||||
if [ ! -d "${curdir}/.git" ]; then
|
if [ $? -eq 1 ]; then
|
||||||
GITINFO_NEW_FILES=""
|
GITINFO_NEW_FILES=""
|
||||||
GITINFO_MODIFIED_FILES=""
|
GITINFO_MODIFIED_FILES=""
|
||||||
return 1
|
return 1
|
||||||
@ -93,8 +99,8 @@ function gitinfo_get_changes()
|
|||||||
######################################################################
|
######################################################################
|
||||||
function gitinfo_get_commit_data()
|
function gitinfo_get_commit_data()
|
||||||
{
|
{
|
||||||
curdir=`pwd`
|
gitinfo_internal_checks
|
||||||
if [ ! -d "${curdir}/.git" ]; then
|
if [ $? -eq 1 ]; then
|
||||||
GITINFO_COMMIT_SHORTID=""
|
GITINFO_COMMIT_SHORTID=""
|
||||||
GITINFO_COMMIT_ID=""
|
GITINFO_COMMIT_ID=""
|
||||||
GITINFO_COMMIT_COUNT=""
|
GITINFO_COMMIT_COUNT=""
|
||||||
@ -110,8 +116,8 @@ function gitinfo_get_commit_data()
|
|||||||
######################################################################
|
######################################################################
|
||||||
function gitinfo_get_remotes()
|
function gitinfo_get_remotes()
|
||||||
{
|
{
|
||||||
curdir=`pwd`
|
gitinfo_internal_checks
|
||||||
if [ ! -d "${curdir}/.git" ]; then
|
if [ $? -eq 1 ]; then
|
||||||
GITINFO_REMOTES=""
|
GITINFO_REMOTES=""
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -122,11 +128,24 @@ function gitinfo_get_remotes()
|
|||||||
# Gets current directory's stashes count.
|
# Gets current directory's stashes count.
|
||||||
######################################################################
|
######################################################################
|
||||||
function gitinfo_get_stashes()
|
function gitinfo_get_stashes()
|
||||||
|
{
|
||||||
|
|
||||||
|
GITINFO_STASHES_COUNT=$(git stash list 2>/dev/null | wc -l)
|
||||||
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# Some common checks that is used everywhere.
|
||||||
|
######################################################################
|
||||||
|
function gitinfo_internal_checks()
|
||||||
{
|
{
|
||||||
curdir=`pwd`
|
curdir=`pwd`
|
||||||
if [ ! -d "${curdir}/.git" ]; then
|
if [ ! -d "${curdir}/.git" ]; then
|
||||||
GITINFO_STASHES_COUNT=""
|
GITINFO_STASHES_COUNT=""
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
GITINFO_STASHES_COUNT=$(git stash list 2>/dev/null | wc -l)
|
|
||||||
|
objects=`ls .git/objects | grep -v "info\|pack" | wc -l`
|
||||||
|
if [ ${objects} -lt 1 ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
# Apps list to enable.
|
# Apps list to enable.
|
||||||
ENABLED_APPS=("colors")
|
ENABLED_APPS=("showcolors")
|
||||||
|
Loading…
Reference in New Issue
Block a user