Merge pull request #65 from singingwolfboy/master

fixes for packaging
This commit is contained in:
TJ Holowaychuk 2012-02-09 00:18:15 -08:00
commit f07ca4b4d3
19 changed files with 96 additions and 45 deletions

View file

@ -19,3 +19,4 @@ Patches and Suggestions
- Alex McHale
- Gert Van Gool
- Devin Withers
- David Baumgold

View file

@ -7,17 +7,17 @@ MAN_HTML = $(MANS:.md=.html)
MAN_PAGES = $(MANS:.md=.1)
install:
@mkdir -p $(MANPREFIX)
@mkdir -p $(PREFIX)/bin
@echo "... installing bins to $(PREFIX)/bin"
@echo "... installing man pages to $(MANPREFIX)"
@mkdir -p $(DESTDIR)$(MANPREFIX)
@mkdir -p $(DESTDIR)$(PREFIX)/bin
@echo "... installing bins to $(DESTDIR)$(PREFIX)/bin"
@echo "... installing man pages to $(DESTDIR)$(MANPREFIX)"
@$(foreach BIN, $(BINS), \
echo "... installing `basename $(BIN)`"; \
cp -f $(BIN) $(PREFIX)/$(BIN); \
cp -f $(BIN) $(DESTDIR)$(PREFIX)/$(BIN); \
)
cp -f man/git-*.1 $(MANPREFIX)
@mkdir -p /etc/bash_completion.d
cp -f etc/bash_completion.sh /etc/bash_completion.d/git-extras
cp -f man/git-*.1 $(DESTDIR)$(MANPREFIX)
@mkdir -p $(DESTDIR)$(PREFIX)/etc/bash_completion.d
cp -f etc/bash_completion.sh $(DESTDIR)$(PREFIX)/etc/bash_completion.d/git-extras
docs: $(MAN_HTML) $(MAN_PAGES)
@ -36,14 +36,14 @@ man/%.1: man/%.md
uninstall:
@$(foreach BIN, $(BINS), \
echo "... uninstalling $(PREFIX)/$(BIN)"; \
rm -f $(PREFIX)/$(BIN); \
echo "... uninstalling $(DESTDIR)$(PREFIX)/$(BIN)"; \
rm -f $(DESTDIR)$(PREFIX)/$(BIN); \
)
@$(foreach MAN, $(MAN_PAGES), \
echo "... uninstalling $(MANPREFIX)/$(MAN)"; \
rm -f $(MANPREFIX)/$(MAN); \
echo "... uninstalling $(DESTDIR)$(MANPREFIX)/$(MAN)"; \
rm -f $(DESTDIR)$(MANPREFIX)/$(MAN); \
)
rm -f /etc/bash_completion.d/git-extras
rm -f $(DESTDIR)$(PREFIX)/etc/bash_completion.d/git-extras
clean: docclean

View file

@ -16,6 +16,12 @@ One-liner:
$ curl https://raw.github.com/visionmedia/git-extras/master/bin/git-extras | INSTALL=y sh
```
[MacPorts](http://www.macports.org/)
```bash
$ sudo port install git-extras
```
[Brew](github.com/mxcl/homebrew/) (buggy):
```bash

View file

@ -4,8 +4,8 @@ if test $# -eq 0; then
git reset --soft HEAD~1
else
if `echo $1 | grep -q [^[:digit:]]`; then
echo $1 is not a number
echo "$1 is not a number" 1>&2
else
git reset --soft HEAD~$1
fi
fi
fi

View file

@ -1,7 +1,7 @@
#!/bin/sh
if test "$1" = "finish"; then
test -z $2 && echo "bug <name> required." && exit 1
test -z $2 && echo "bug <name> required." 1>&2 && exit 1
branch=bug/$2
git merge --no-ff $branch && git delete-branch $branch
else
@ -9,4 +9,4 @@ else
branch=bug/$1
git checkout -b $branch &> /dev/null
git checkout $branch &> /dev/null
fi
fi

View file

@ -2,7 +2,7 @@
user="$*"
test -z "$user" && echo "user name required." && exit 1
test -z "$user" && echo "user name required." 1>&2 && exit 1
count=`git log --oneline --pretty="format: %an" | grep "$user" | wc -l`
test $count -eq 0 && echo "$user did not contribute." && exit 1

View file

@ -1,7 +1,7 @@
#!/bin/sh
branch=$1
test -z $branch && echo "branch required." && exit 1
test -z $branch && echo "branch required." 1>&2 && exit 1
git push origin origin:refs/heads/$branch
git fetch origin

View file

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

View file

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

View file

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

View file

@ -1,12 +1,12 @@
#!/bin/sh
if test "$1" = "finish"; then
test -z $2 && echo "feature <name> required." && exit 1
test -z $2 && echo "feature <name> required." 1>&2 && exit 1
branch=feature/$2
git merge --no-ff $branch && git delete-branch $branch
else
test -z $1 && echo "feature <name> required." && exit 1
test -z $1 && echo "feature <name> required." 1>&2 && exit 1
branch=feature/$1
git checkout -b $branch &> /dev/null
git checkout $branch &> /dev/null
fi
fi

View file

@ -2,7 +2,7 @@
branch=$1
test -z $branch && echo "branch required." && exit 1
test -z $branch && echo "branch required." 1>&2 && exit 1
git symbolic-ref HEAD refs/heads/$branch
rm .git/index

17
bin/git-gh-oauth Normal file
View file

@ -0,0 +1,17 @@
#!/bin/sh
user=`git config github.user`
test -z "$user" && echo "failed to fetch github.user" 1>&2 && exit 1
oauthToken=`git config github.oauthToken`
if [ -z $oauthToken ] ; then
echo "Github oAuth token not found. Creating a new one."
stty_orig=`stty -g`
stty -echo
printf "Github password:"
read passwd
stty $stty_orig
url="https://api.github.com/authorizations"
oauthToken=$(curl -# -u "$user:$passwd" $url -d '{"scopes": ["repo", "user", "gist"]}' | jshon -e token | sed -e 's/"//g')
git config --global github.oauthToken $oauthToken
fi
echo $oauthToken

View file

@ -3,7 +3,7 @@
src=$1
dst=$2
test -z $src && echo "source branch required." && exit 1
test -z $src && echo "source branch required." 1>&2 && exit 1
git checkout $dst \
&& git merge --no-ff $src \

View file

@ -1,15 +1,42 @@
#!/bin/sh
request=$1
# check if arg 1 is a number or not
echo $1 | egrep "^[[:digit:]]+$" > /dev/null
is_not_number=$?
repo=${PWD##*/}
user=`git config github.user`
url="https://github.com/$user/$repo/pull/$request.patch"
test -z "$request" && echo "pull request number required" && exit 1
test -z "$repo" && echo "failed to detect repo" && exit 2
test -z "$user" && echo "failed to fetch github.user" && exit 3
test -z "$repo" && echo "failed to detect repo" 1>&2 && exit 2
test -z "$user" && echo "failed to fetch github.user" 1>&2 && exit 3
if [ ! $is_not_number ] ; then
# apply existing pull request
url="https://github.com/$user/$repo/pull/$1.patch"
echo "pulling $url"
curl -# $url \
| git am --signoff \
&& echo "completed pull request $request"
else
# push
branchname=`git branch --no-color | sed -n -e 's/^\* \(.*\)/\1/p'`
echo "git push origin $branchname"
git push origin $branchname
# create new pull request
url="https://api.github.com/repos/$user/$repo/pulls"
echo "creating pull request"
oauthToken=`git gh-oauth`
body="{\"title\": \"$branchname\", \"head\": \"$user:$branchname\", \"base\": \"master\"}"
curl_result=$(curl -H "Authorization: token $oauthToken" $url -d "$body" --silent \
--write-out "%{http_code}")
json=`echo ${curl_result} | sed 's/...$//'`
http_code=`echo ${curl_request} | perl -pe 's/(.*)(...)$/$2/'`
if [ "${http_code:0:1}" == "2" ] ; then
pr_num=`echo "$json" | jshon -e number`
echo "Created pull request #${pr_num}"
else
echo "$json" | jshon -e message
echo "$json"
fi
fi
echo "pulling $url"
curl -# $url \
| git am --signoff \
&& echo "completed pull request $request"

View file

@ -1,12 +1,12 @@
#!/bin/sh
if test "$1" = "finish"; then
test -z $2 && echo "refactor <name> required." && exit 1
test -z $2 && echo "refactor <name> required." 1>&2 && exit 1
branch=refactor/$2
git merge --no-ff $branch && git delete-branch $branch
else
test -z $1 && echo "refactor <name> required." && exit 1
test -z $1 && echo "refactor <name> required." 1>&2 && exit 1
branch=refactor/$1
git checkout -b $branch &> /dev/null
git checkout $branch &> /dev/null
fi
fi

View file

@ -18,5 +18,5 @@ if test $# -gt 0; then
&& hook post-release \
&& echo "... complete"
else
echo "tag required" && exit 1
echo "tag required" 1>&2 && exit 1
fi

View file

@ -2,7 +2,7 @@
filename="$*"
test -z "$filename" && echo "filename required" && exit 1
test -z "$filename" && echo "filename required" 1>&2 && exit 1
touch "$filename" \
&& git add "$filename"

View file

@ -4,8 +4,8 @@ if test $# -eq 0; then
git reset --hard HEAD~1
else
if `echo $1 | grep -q [^[:digit:]]`; then
echo $1 is not a number
echo "$1 is not a number" 1>&2
else
git reset --hard HEAD~$1
fi
fi
fi