Last active
March 31, 2025 10:02
-
-
Save faustinoaq/bdf7058199af0374160fd0302c554106 to your computer and use it in GitHub Desktop.
Migrate the old UIUCPlus to the new UIUCPlus, ensuring it is properly formatted and compilable.
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 | |
# Migrate the old UIUCPlus to the new UIUCPlus, ensuring it is properly formatted and compilable. | |
# Cleanup | |
rm -rf FormattedUIUCPlus NewUIUCPlus | |
# Clone updated repos | |
git clone https://github.com/sugamadhiakri/UIUCPlus FormattedUIUCPlus | |
git clone https://github.com/summer-research-program/UIUCPlus NewUIUCPlus | |
# Merge fixed main into new repo | |
# git -C NewUIUCPlus merge --no-edit origin/compilable-uiucplus | |
# Reset Git history in NewUIUCPlus | |
cd NewUIUCPlus | |
rm -rf .git # Remove existing Git history | |
git init | |
git add . | |
git commit -q -m "Initial commit" | |
cd .. | |
# Iterate over branches in FormattedUIUCPlus and copy the changed .java file | |
for branch in $(git -C FormattedUIUCPlus branch -r | grep -E 'buggy|mutant' | sed 's|origin/||'); do | |
# Example branch name: | |
# $branch=NatGen-base.commons-codec.mid-168.idx-651.1.mutant | |
# Checkout the branch from FormattedUIUCPlus into NewUIUCPlus without the 'origin/' part | |
git -C FormattedUIUCPlus checkout "origin/$branch" # Checkout remote branch | |
# Diff between the current branch and main in FormattedUIUCPlus to identify the changed file | |
# Exclude LICENSE file and only include the first .java file | |
filename=$(git -C FormattedUIUCPlus diff --name-only main origin/$branch | grep '\.java$' | head -n 1) | |
# if no .java file is found, look for previous commit | |
if ! [[ -n "$filename" ]]; then | |
if echo "$branch" | grep -q "leam-base"; then | |
echo "Skipping $branch" | |
continue # Skip lean-base branches with no changes | |
fi | |
filename=$(git -C FormattedUIUCPlus diff --name-only main origin/$branch~1 | grep '\.java$' | head -n 1) | |
echo "No .java file found in $branch, using previous commit" | |
git -C FormattedUIUCPlus checkout "origin/$branch~1" # Checkout remote branch previous 1 commit | |
fi | |
# Create a local branch with the same name (without origin/ prexif) | |
git -C NewUIUCPlus checkout -b "$branch" | |
# Copy .java file to NewUIUCPlus | |
cp -v FormattedUIUCPlus/$filename NewUIUCPlus/$filename | |
git -C NewUIUCPlus add . | |
git -C NewUIUCPlus commit -m "$branch" | |
git -C NewUIUCPlus checkout main | |
#exit # Debugging | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment