2020-06-11 21:56:20 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Exports a subdirectory into another github repository
|
|
|
|
#
|
|
|
|
|
|
|
|
set -e
|
|
|
|
if [[ -z $GITHUB_TOKEN ]]; then
|
|
|
|
echo GITHUB_TOKEN not defined
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
|
|
|
|
pip3 install git-filter-repo
|
|
|
|
|
|
|
|
declare subdir=$1
|
|
|
|
declare repo_name=$2
|
|
|
|
|
2020-06-12 16:06:32 -07:00
|
|
|
[[ -n "$subdir" ]] || {
|
2020-06-11 21:56:20 -07:00
|
|
|
echo "Error: subdir not specified"
|
|
|
|
exit 1
|
|
|
|
}
|
2020-06-12 16:06:32 -07:00
|
|
|
[[ -n "$repo_name" ]] || {
|
2020-06-11 21:56:20 -07:00
|
|
|
echo "Error: repo_name not specified"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Exporting $subdir"
|
|
|
|
|
|
|
|
set -x
|
|
|
|
rm -rf .github_export/"$repo_name"
|
2020-06-12 16:06:32 -07:00
|
|
|
git clone https://"$GITHUB_TOKEN"@github.com/solana-labs/"$repo_name" .github_export/"$repo_name"
|
2020-06-11 21:56:20 -07:00
|
|
|
git filter-repo --subdirectory-filter "$subdir" --target .github_export/"$repo_name"
|
2020-06-12 16:06:32 -07:00
|
|
|
git -C .github_export/"$repo_name" push https://"$GITHUB_TOKEN"@github.com/solana-labs/"$repo_name"
|