forked from community-ssu/hildon-thumbnail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-make-dist
executable file
·68 lines (56 loc) · 1.42 KB
/
git-make-dist
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# git-make-dist -- Make a release tag in a git repository. The tag
# will have the same content as the tarball produced
# by "make dist", plus the debian/ directory as it is
# tracked by git.
set -e
exportcwd () {
for f in `find . -type f`; do
ff=`echo $f | sed 's,^./,,'`
if [ -x "$f" ]; then
echo M 100755 inline $ff
else
echo M 100644 inline $ff
fi
echo data `wc -c <$f`
cat $f
done
}
exportcommit () {
echo commit $1
echo committer `git config user.name` '<'`git config user.email`'>' now
echo 'data <<EOD'
echo Prepare for distribution
echo EOD
echo from HEAD
echo deleteall
exportcwd
}
if [ $# != 1 ]; then
echo >&2 "Usage: git-make-dist TAGNAME"
exit 1
fi
tagname="$1"
if ! git diff --quiet ; then
echo >&2 "Your working tree is not clean. Aborting."
exit 1
fi
if ! git diff --quiet --cached; then
echo >&2 "Your index is not clean. Aborting."
exit 1
fi
if git rev-parse --verify $tagname >/dev/null >&/dev/null; then
echo >&2 "Tag $tagname exists already. Aborting."
exit 1
fi
distdir=$(mktemp -d tmp.XXXXXX)
make distdir distdir=$distdir
for f in `git ls-files debian`; do
if ! [ -a $distdir/$f ]; then
mkdir -p $(dirname $distdir/$f)
ln $f $distdir/$f
fi
done
(cd $distdir && exportcommit refs/tags/$tagname) \
| git fast-import --date-format=now --quiet --force
rm -rf $distdir