Skip to content

Instantly share code, notes, and snippets.

@cloudnull
Created December 8, 2020 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cloudnull/5a25ecea8c89730b3f26a75174dc8404 to your computer and use it in GitHub Desktop.
Save cloudnull/5a25ecea8c89730b3f26a75174dc8404 to your computer and use it in GitHub Desktop.
tripleo repo scraper
COMMIT_MSG="The lower constraint file has been removed
This file, and its tests, are not useful for tripleo so we're
removing because they're now becoming problematic."
git clone https://github.com/openstack/governance
pushd governance
python <<EOC
import yaml
with open('reference/projects.yaml') as f:
x = yaml.safe_load(f.read())['tripleo']['deliverables']
repos = []
for key, value in x.items():
repos.extend(value['repos'])
with open('../repos.new', 'w') as f:
f.write('\n'.join(repos))
EOC
popd
cat repos.new | while read line
do
git clone ssh://cloudnull@review.opendev.org:29418/${line}.git
if [[ $? == 0 ]]; then
pushd ${line#"openstack/"}
CHANGED=0
rm -f lower-constraints.txt
if [[ $? == 0 ]]; then
CHANGED=1
fi
if [ -f ".zuul.yaml" ]; then
grep -rnil lower-constraints ".zuul.yaml" | xargs -n 1 sed -i '/openstack-tox-lower-constraints/d'
if [[ $? == 0 ]]; then
CHANGED=1
fi
fi
if [ -d "zuul.d" ]; then
grep -rnil lower-constraints "zuul.d" | xargs -n 1 sed -i '/openstack-tox-lower-constraints/d'
if [[ $? == 0 ]]; then
CHANGED=1
fi
fi
if grep -q lower-constraints tox.ini; then
awk 'BEGIN{f=1} /\[testenv:lower-constraints\]/{f=0} f{print} !$0{f=1}' tox.ini > tox.ini.new
if [[ $? == 0 ]]; then
CHANGED=1
mv tox.ini.new tox.ini
fi
fi
if [[ ${CHANGED} == 1 ]]; then
git commit -asS -m "${COMMIT_MSG}"
git review -t tripleo-lower
fi
CHANGED=0
popd
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment