Created
February 13, 2023 20:13
-
-
Save ViktorHofer/2be5314439e75860326a60cee6523bef to your computer and use it in GitHub Desktop.
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 bash | |
# Match hidden files with the asterisk | |
shopt -s dotglob | |
source="${BASH_SOURCE[0]}" | |
# resolve $source until the file is no longer a symlink | |
while [[ -h "$source" ]]; do | |
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" | |
source="$(readlink "$source")" | |
# if $source was a relative symlink, we need to resolve it relative to the path where the | |
# symlink file was located | |
[[ $source != /* ]] && source="$scriptroot/$source" | |
done | |
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" | |
git clone https://github.com/dotnet/runtime | |
git clone https://github.com/dotnet/winforms | |
echo "Setting up git user: dotnet-bot (dotnet-bot@microsoft.com)" | |
git config --global user.email "dotnet-bot@microsoft.com" | |
git config --global user.name "dotnet-bot" | |
cd runtime | |
git remote rm origin | |
echo "Rewriting commits..." | |
git filter-branch --subdirectory-filter "src/libraries/System.Drawing.Common/" --prune-empty --force --msg-filter ' | |
sed -r "s/(#[0-9]+)/dotnet\/runtime\1/g" | | |
sed -r "s/\b([a-f0-9]{40})\b/dotnet\/runtime@\1/g" | | |
cat && echo "\n\nCommit migrated from https://github.com/dotnet/runtime/commit/$GIT_COMMIT" | |
' --index-filter ' | |
git ls-files -sz | | |
perl -0pe "s{\t}{\tsrc/System.Drawing.Common/}" | | |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ | |
git update-index --clear -z --index-info && | |
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD | |
echo "Cleaning repository..." | |
git reset --hard | |
git gc --aggressive | |
git prune | |
git clean -fd | |
cd ../winforms | |
echo "Copying git objects into target repository..." | |
git remote add "runtime" "../runtime/" | |
git pull -n --no-edit --no-rebase --allow-unrelated-histories "runtime" main | |
git remote rm "runtime" | |
echo "Deleting runtime repository..." | |
rm -rf ../runtime | |
echo "Applying System.Drawing.Common patch" | |
git apply ../drawing.patch | |
echo "Pushing changes..." | |
git checkout -b DrawingMigration | |
sleep 5 | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment