41 lines
727 B
Plaintext
41 lines
727 B
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
# check if there's .git dir in a parent dir
|
||
|
isgit() {
|
||
|
_path="$PWD"
|
||
|
while [ -n "$_path" ]
|
||
|
do
|
||
|
if [ -d "$_path/.git" ]
|
||
|
then
|
||
|
return 0
|
||
|
fi
|
||
|
_path="${_path%/*}"
|
||
|
done
|
||
|
return 1
|
||
|
}
|
||
|
|
||
|
if ! isgit
|
||
|
then echo "no git repository"
|
||
|
return
|
||
|
fi
|
||
|
|
||
|
_log=$(git --no-pager log \
|
||
|
--abbrev-commit \
|
||
|
--pretty=format:'%h | %an: %s' \
|
||
|
...origin/HEAD)
|
||
|
_stat=$(git --no-pager status \
|
||
|
--short)
|
||
|
|
||
|
if [ -n "$_log" ]
|
||
|
then echo "$_log"
|
||
|
else _branch=$(git --no-pager branch --no-color --show-current)
|
||
|
echo "git log: no change in $_branch"
|
||
|
fi
|
||
|
|
||
|
if [ -n "$_stat" ]
|
||
|
then echo "git status:"
|
||
|
echo "$_stat"
|
||
|
else echo "git status: clean"
|
||
|
fi
|
||
|
|