Created
October 28, 2019 15:36
-
-
Save Fryguy/3490682c7761edeedba1ee28de5ed117 to your computer and use it in GitHub Desktop.
code-extractor
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
#!/bin/bash | |
# Also see https://github.com/juliancheal/code-extractor/blob/master/code_extractor.rb | |
[email protected]:crystal-lang/crystal | |
SOURCE_REPO=crystal-lang/crystal | |
SOURCE_BRANCH=master | |
DEST_NAME=crystal-readline | |
DEST_DIR=$DEST_NAME | |
# List of all of the files and directories to extract, space-delimited | |
EXTRACTIONS="spec/std/readline_spec.cr src/readline.cr" | |
git clone -o upstream $SOURCE_URL $DEST_DIR | |
# Create branch for upstream deletion | |
cd $DEST_DIR | |
git checkout $SOURCE_BRANCH | |
git fetch upstream | |
git rebase upstream/$SOURCE_BRANCH | |
git checkout -b extract_$DEST_NAME | |
git rm -r $EXTRACTIONS | |
git commit -m "Extract $DEST_NAME" | |
# Cleanup | |
git remote rm upstream | |
for tag in $(git tag); do | |
git tag -d $tag | |
done | |
# Filter down to the extractions | |
git filter-branch --index-filter " | |
git read-tree --empty | |
git reset \$GIT_COMMIT -- $EXTRACTIONS | |
" --msg-filter " | |
cat - | |
echo | |
echo | |
echo \"(transferred from $SOURCE_REPO@\$GIT_COMMIT)\" | |
" -- $SOURCE_BRANCH -- $EXTRACTIONS | |
git checkout $SOURCE_BRANCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment