-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmake-git-snapshot.sh
More file actions
executable file
·46 lines (40 loc) · 979 Bytes
/
make-git-snapshot.sh
File metadata and controls
executable file
·46 lines (40 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
APP=`basename $0`
while test "$1" != ""; do
case $1 in
--no-date)
NO_DATE=1
;;
--no-commit-id)
NO_COMMIT_ID=1
;;
-p|--pre-release)
PRE_RELEASE=pre
;;
-n)
PROJECT_NAME=$2
shift
;;
-o)
OBJECT=$2
shift
;;
*)
VERSION=$1
esac
shift
done
if [ -z "$VERSION" ]; then
echo "Usage: $APP [--no-date] [--no-commit-id] [-p|--pre-release] [-n PROJECT_NAME] [-o OBJECT] <version>"
exit
fi
test -z "$PROJECT_NAME" && PROJECT_NAME=$(basename `pwd`)
test -z "$OBJECT" && OBJECT=HEAD
test -z "$NO_DATE" && DATE=_$PRE_RELEASE$(date +%Y%m%d)
test -z "$NO_COMMIT_ID" &&
COMMIT_ID=git$(git rev-parse --short $OBJECT)
DIRNAME="$PROJECT_NAME-$VERSION$DATE"
ARCHIVE_FILE="$DIRNAME$COMMIT_ID.tar.bz2"
echo Creating archive from $OBJECT ...
git archive --format=tar --prefix=$DIRNAME/ $OBJECT | bzip2 > $ARCHIVE_FILE
sha1sum $ARCHIVE_FILE