2022-11-16 17:14:40 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# args
|
|
|
|
repo="${1%/}"
|
|
|
|
ref="${2-HEAD}"
|
2023-11-28 14:09:31 +00:00
|
|
|
ab="${3-12}"
|
2022-11-16 17:14:40 +00:00
|
|
|
|
|
|
|
# check
|
|
|
|
if test ! -d "${repo}/.git"; then
|
2023-11-28 14:09:31 +00:00
|
|
|
echo "usage: $0 <repodir> [ <ref> [ <abbrev> ] ]"
|
2022-11-16 17:14:40 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# get + print info
|
2023-11-28 14:09:31 +00:00
|
|
|
commit=$(cd $repo; git show --abbrev=$ab --pretty='format:%h' $ref | head -1)
|
2022-11-16 17:14:40 +00:00
|
|
|
date=$(cd $repo; git show --pretty='format:%cs' $ref | head -1 | tr -d '-')
|
|
|
|
echo "# $repo $ref -> commit $commit - date $date"
|
|
|
|
|
|
|
|
# create tarball
|
|
|
|
name="${repo##*/}"
|
|
|
|
file="${name}-${commit}.tar.xz"
|
|
|
|
(cd $repo; git archive --format=tar --prefix=${name}-${commit}/ ${commit}) \
|
|
|
|
| xz -9ev > "$file"
|
|
|
|
echo "# $file written"
|