adopting uniq code style across multiple scripts: variables assignments, arguments validation and core logic. This style reduces if statements usage and makes code easier to understand. :D

This commit is contained in:
Jonhnny Weslley 2010-11-25 16:23:38 -03:00
parent 6f63a770c5
commit f235670a3e
9 changed files with 35 additions and 29 deletions

1
.gitignore vendored
View file

@ -1 +0,0 @@

View file

@ -1,10 +1,9 @@
#!/bin/sh
user="$1"
if test -z "$user"; then
echo "user name required." && exit 1
else
count=`git log --oneline --pretty="format: %an" | grep "$user" | wc -l`
test $count -eq 0 && echo "$user did not contribute." && exit 1
git shortlog | grep "$user (" -A $count
fi
user="$*"
test -z "$user" && echo "user name required." && exit 1
count=`git log --oneline --pretty="format: %an" | grep "$user" | wc -l`
test $count -eq 0 && echo "$user did not contribute." && exit 1
git shortlog | grep "$user (" -A $count

View file

@ -1,5 +1,6 @@
#!/bin/sh
test -z $1 && echo "branch required." && exit 1
git branch -D $1
git branch -d -r origin/$1 && git push origin :$1
branch=$1
test -z $branch && echo "branch required." && exit 1
git branch -D $branch
git branch -d -r origin/$branch && git push origin :$branch

View file

@ -1,9 +1,11 @@
#!/bin/sh
test -z $1 && echo "submodule required" && exit 1
submodule=$1
test -z $submodule && echo "submodule required" && exit 1
test ! -f .gitmodules && echo ".gitmodules file not found" && exit 2
NAME=$(echo $1 | sed 's/\/$//g')
NAME=$(echo $submodule | sed 's/\/$//g')
test -z $(git config --file=.gitmodules submodule.$NAME.url) && echo "submodule not found" && exit 3
git config --remove-section submodule.$NAME

View file

@ -1,4 +1,5 @@
#!/bin/sh
test -z $1 && echo "tag required." && exit 1
git tag -d $1 && git push origin :refs/tags/$1
tagname=$1
test -z $tagname && echo "tag required." && exit 1
git tag -d $tagname && git push origin :refs/tags/$tagname

View file

@ -1,6 +1,9 @@
#!/bin/sh
test -z $1 && echo "branch required." && exit 1
git symbolic-ref HEAD refs/heads/$1
branch=$1
test -z $branch && echo "branch required." && exit 1
git symbolic-ref HEAD refs/heads/$branch
rm .git/index
git clean -fdx
git clean -fdx

View file

@ -1,9 +1,10 @@
#!/bin/sh
test -z $1 && echo "source branch required." && exit 1
src=$1
dst=${2-master}
test -z $src && echo "source branch required." && exit 1
git checkout $dst \
&& git merge --no-ff $src \
&& git branch -d $src
&& git branch -d $src

View file

@ -1,10 +1,10 @@
#!/bin/sh
tagname=$1
tagname="$1"
test -z $tagname && echo "tag required" && exit 1
test -z "$tagname" && echo "tag required" && exit 1
echo "... releasing $1"
git tag -a "$1" -m "Release $1" \
echo "... releasing $tagname"
git tag -a "$tagname" -m "Release $tagname" \
&& git push --tags \
&& echo "... complete"

View file

@ -1,8 +1,8 @@
#!/bin/sh
filename=$1
filename="$*"
test -z $filename && echo "filename required" && exit 1
test -z "$filename" && echo "filename required" && exit 1
touch $filename \
&& git add $filename
touch "$filename" \
&& git add "$filename"