mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
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:
parent
6f63a770c5
commit
f235670a3e
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue