]>
git.ipfire.org Git - ipfire-3.x.git/blob - tools/make-git
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 # A small helper to make the git functions comfortable #
22 ###############################################################################
23 ###############################################################################
27 ###############################################################################
29 if [ -z "$EDITOR" ]; then
30 for i
in nano emacs vi
; do
31 EDITOR
=$
(which $i 2>/dev
/null
)
32 if ! [ -z "$EDITOR" ]; then
37 [ -z "$EDITOR" ] && exiterror
"You should have installed an editor."
40 CURRENT_BRANCH
=$
(git branch |
grep ^
* | cut
-c 3-)
43 if [ -d "$BASEDIR/.git" ]; then
44 ln -sf $BASEDIR/tools
/make-git
$BASEDIR/.git
/hooks
/pre-commit
47 ###############################################################################
49 # A small helper to make the git functions comfortable
51 ###############################################################################
54 if [ "$1" = "--batch" ]; then
56 git pull $
* |
grep -q "Already up-to-date." ||
rm -f $FAILED
57 [ -e $FAILED ] || distccd_restart
58 [ "$(expr $RANDOM % 25)" -eq "0" ] && git_gc
60 if [ "$CURRENT_BRANCH" == "master" ]; then
61 if ! (git status |
grep -q "working directory clean"); then
62 echo "Your \"master\" branch is not clean. This may cause a merge commit."
63 echo -n "Do you want this? [y/N]"
65 [ -z $REPLY ] && return 0
67 if [ "$i" == "$REPLY" ]; then
77 echo -n "You are not on branch \"master\". Do you want to rebase from \"master\"? [y/N]"
79 [ -z $REPLY ] && return 0
81 if [ "$i" == "$REPLY" ]; then
82 git rebase
-v refs
/heads
/master
86 exiterror
"\"$REPLY\" is not a valid answer."
94 [ "$CURRENT_BRANCH" == "master" ] || \
95 exiterror
"You have to be in branch \"master\", if you want to push."
96 git push
ssh://${IPFIRE_USER}@git.ipfire.org
/pub
/git
/ipfire-3.x master
104 [ "$?" -eq "0" ] || dialogerror
"git commit $* failed."
108 DIFF_NAME
="${BASEDIR}/ipfire-diff-$(date '+%Y%m%d-%0k%0M').diff"
112 echo -ne "Make a local diff to last revision"
113 git
diff HEAD
> $DIFF_NAME
115 if [ -s $DIFF_NAME ]; then # if diff file is empty
116 echo "Diff was successfully saved to $DIFF_NAME"
125 echo -n "Generating changelog from repository"
127 git log
-n 500 --no-merges --pretty=medium
--shortstat $
(git_range
) > $BASEDIR/doc
/ChangeLog
132 git shortlog
--no-merges $
(git_range
)
140 git archive HEAD |
gzip -9 > ${SNAME}-${VERSION}.
source.
tar.gz
145 [ -z $GIT_TAG ] || LAST_TAG
=$GIT_TAG
146 [ -z $LAST_TAG ] || EXT
="$LAST_TAG..HEAD"
151 test $# -gt 0 || exiterror
"You need to pass the hostname of the remote host."
153 SSH_KEYGEN
=`which ssh-keygen`
154 if test $?
-ne 0; then
155 # Error message is printed by 'which'
160 if ! test -d $SSH_DIR; then
165 if [ ! -f $SSH_DIR/identity
] ||
[ ! -f $SSH_DIR/identity.pub
]; then
166 echo "Generating ssh1 RSA keys - please wait..."
167 rm -f $SSH_DIR/identity
$SSH_DIR/identity.pub
168 $SSH_KEYGEN -t rsa1
-f $SSH_DIR/identity
-P ''
169 if [ $?
-ne 0 ]; then
170 echo "Command \"$SSH_KEYGEN -t rsa1 -f $SSH_DIR/identity" \
171 "-P ''\" failed" 1>&2
175 echo "ssh1 RSA key is present"
178 if [ ! -f $SSH_DIR/id_dsa
] ||
[ ! -f $SSH_DIR/id_dsa.pub
]; then
179 echo "Generating ssh2 DSA keys - please wait..."
180 rm -f $SSH_DIR/id_dsa
$SSH_DIR/id_dsa.pub
181 $SSH_KEYGEN -t dsa
-f $SSH_DIR/id_dsa
-P ''
182 if test $?
-ne 0; then
183 echo "Command \"$SSH_KEYGEN -t dsa -f $SSH_DIR/id_dsa" \
184 "-P ''\" failed" 1>&2
188 echo "ssh2 DSA key is present"
191 SSH1_RSA_KEY
=`cat $SSH_DIR/identity.pub`
192 SSH2_DSA_KEY
=`cat $SSH_DIR/id_dsa.pub`
195 echo "You will now be asked for password for $IP"
196 ssh -oStrictHostKeyChecking=no
$IP "mkdir -p ~/.ssh; chmod 700 ~/.ssh; \
197 echo \"$SSH1_RSA_KEY\" >> ~/.ssh/authorized_keys; \
198 echo \"$SSH2_DSA_KEY\" >> ~/.ssh/authorized_keys2; \
199 chmod 600 ~/.ssh/authorized_keys ~/.ssh/authorized_keys2"
200 if test $?
-eq 0; then
201 echo "Keys were put successfully"
203 echo "Error putting keys to $IP" 1>&2
209 echo -n "Checking $IP connectivity by ssh$ver... "
210 ssh -q -oProtocol=${ver} -oBatchMode=yes \
211 -oStrictHostKeyChecking=no
$IP /bin
/true
217 git_hook_pre_commit
() {
218 local USERNAME USERMAIL
219 USERNAME
=$
(git config
--list |
grep ^user.name
)
220 USERNAME
=${USERNAME#user.name=}
222 USERMAIL
=$
(git config
--list |
grep ^user.email
)
223 USERMAIL
=${USERMAIL#user.email=}
225 if [[ ! "$USERMAIL" =~
"@ipfire\.org$" ]]; then
226 echo "User email is not from ipfire.org. Can't commit."
231 for i
in $USERNAME; do
232 COUNTER
=$
[ $COUNTER + 1 ]
235 if [ ! "$COUNTER" -ge 2 ]; then
236 echo "Setup user name as your real name. Can't commit."
242 if [ "$(basename $0)" = "pre-commit" ]; then