21bb79
#!/bin/bash
21bb79
21bb79
NAME=$(basename $PWD)
21bb79
OWNER=$(sed   -n '/^%global gh_owner/{s/.* //;p}'   $NAME.spec)
21bb79
PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec)
21bb79
VERSION=$(sed -n '/^Version:/{s/.* //;p}'           $NAME.spec)
21bb79
COMMIT=$(sed  -n '/^%global gh_commit/{s/.* //;p}'  $NAME.spec)
21bb79
SHORT=${COMMIT:0:7}
21bb79
21bb79
echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n"
21bb79
21bb79
echo "Cloning..."
21bb79
rm -rf $PROJECT-$COMMIT
21bb79
git clone --recursive https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT
21bb79
21bb79
echo "Getting commit..."
21bb79
pushd $PROJECT-$COMMIT
21bb79
git checkout $COMMIT
21bb79
popd
21bb79
21bb79
echo "Archiving..."
21bb79
tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $PROJECT-$COMMIT
21bb79
21bb79
echo "Cleaning..."
21bb79
rm -rf $PROJECT-$COMMIT
21bb79
21bb79
echo "Done."