Skip to content

Add excise stdlib script #51550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions contrib/excise_stdlib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

# Uses https://github.com/newren/git-filter-repo
# Recommended use of `Github cli`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you maybe add a comment pointing to the homepage (https://cli.github.com/), so that users can get to the installation instructions easily?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh is just a recommendation. It's not actively used in the script. I decided that the push to github is best done manually after the user inspects the result.


set -e
set -f
set -x

if [ -z "$*" ]; then echo "Expected name of stdlib"; fi

STDLIB=$1
WORKDIR=$(mktemp -d)

echo "Excising stdlib $STDLIB; workdir $WORKDIR"
pushd $WORKDIR
git clone https://github.com/JuliaLang/julia $STDLIB
pushd $STDLIB

echo "Filtering repo"
git filter-repo --subdirectory-filter stdlib/$STDLIB --path LICENSE.md \
--message-callback 'return re.sub(b"(\W)(#\d+)", lambda m: m.group(1) + b"JuliaLang/julia" + m.group(2), message)'


echo "Deleting branches"
git branch -l | grep -v release- | grep -v master | xargs git branch -v -D

popd
popd
echo "Done! Inspect the result and push it!"
echo """
cd $WORKDIR/$STDLIB
gh repo create JuliaLang/$STDLIB.jl --push --source=. --public
git push --all
git push --tags"""

echo """
Remember to:
1. Add a README.md
2. Setup GHA or similar for CI
"""