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