Last active
June 9, 2021 17:57
-
-
Save gadomski/a0ab8d18f56ff34454d2ed890d234534 to your computer and use it in GitHub Desktop.
Extracting a stactools subpackage to its own repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
set -ex | |
if [ $# -ne 1 ]; then | |
echo "USAGE: $0 NAME" | |
exit 1 | |
fi | |
name=$1 | |
if [ -d stactools-$name ]; then | |
rm -rf stactools-$name | |
fi | |
if [ ! -d stactools ]; then | |
git clone https://github.com/stac-utils/stactools | |
fi | |
git clone --no-local --no-tags --single-branch stactools stactools-$name | |
cd stactools-$name | |
git filter-repo --path stactools_$name/stactools/ --path tests/$name/ --path tests/data-files/$name --path-rename stactools_$name/stactools/:src/stactools/ --path-rename tests/$name/:tests/ --path-rename tests/data-files/$name/:tests/data-files/ | |
cd .. | |
if [ ! -d template ]; then | |
git clone https://github.com/stactools-packages/template | |
fi | |
for file in $(ls -a template); do | |
if [ -f template/$file ]; then | |
cp template/$file stactools-$name/$file | |
elif [ ! -d stactools-$name/$file ]; then | |
cp -r template/$file stactools-$name/$file | |
fi | |
done | |
cd stactools-$name | |
git branch -M master main | |
cat src/stactools/$name/version.py >> src/stactools/$name/__init__.py && rm src/stactools/$name/version.py | |
for file in $(find . -path ./.git -prune -false -o -type f -print); do | |
sed -i '.bak' "s/stactools-package/stactools-$name/g" $file && rm $file.bak | |
sed -i '.bak' "s/stactools.package/stactools.$name/g" $file && rm $file.bak | |
sed -i '.bak' "s/stactools_package/stactools_$name/g" $file && rm $file.bak | |
done | |
docker/cibuild |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment