#!/usr/bin/bash
REPO_URI=https://github.com/github/hub
OLD_COMMIT=$(grep "%global commit" hub.spec |cut -d ' ' -f3)
HEAD_COMMIT=$(git ls-remote $REPO_URI HEAD | cut -f1)
sed -i "/%global commit/c\%global commit $HEAD_COMMIT" hub.spec
spectool -g hub.spec
CHANGELOG=$(/usr/bin/python3 hub-commits.py $OLD_COMMIT $HEAD_COMMIT 2>/dev/null)
if [ $? ]; then
CHANGELOG=
fi
rpmdev-bumpspec hub.spec -c "Updating to upstream commit $HEAD_COMMIT"
TARBALL=hub-prerelease-${HEAD_COMMIT:0:7}.tar.gz
echo "Uploading $TARBALL to Fedora"
fedpkg new-sources $TARBALL