Skip to content

Commit

Permalink
Merge branch 'master' into arv/brillig_funs
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant authored Jul 26, 2023
2 parents b01335e + 3b803c9 commit 756c33f
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions scripts/migrate_barretenberg_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
set -eu

# Usage: ./this.sh <branch> <commit_message>
# Script for migrating PRs from barretenberg repo to aztec-packages.
# Meant to be used from master with a branch name that exists on barretenberg repo but not aztec-packages.
# You can change the commit message after with git commit --amend if needed.

# Display usage if not enough arguments
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <branch> <commit_message>"
exit 1
fi

# Check for unstaged changes
if ! git diff-index --quiet HEAD --; then
echo "Error: You have unstaged changes. Please commit or stash them before running git_subrepo.sh."
exit 1
fi

BRANCH="$1"
COMMIT_MESSAGE="$2"
SUBREPO_PATH=circuits/cpp/barretenberg # can be changed to another subrepo if useful

SCRIPT_DIR=$(dirname "$(realpath "$0")")
cd "$SCRIPT_DIR"/..

echo "(branch migrate) Switching to a new branch named '$BRANCH' (this branch can't already exist)"

# Check if branch already exists
if git rev-parse --verify "$BRANCH" >/dev/null 2>&1; then
echo "Error: Aztec branch '$BRANCH' already exists. Please delete it with 'git branch -D $BRANCH' if you are sure you don't need it."
exit 1
fi

git checkout -b "$BRANCH"

echo "(branch migrate) Pulling from upstream barretenberg repo. If this doesn't work, your barretenberg branch may need to merge barretenberg master."
# note: we use force with the assumption that people don't care about their subrepo stash branch
if ! scripts/git_subrepo.sh pull "$SUBREPO_PATH" --branch=$BRANCH --force; then
echo "Error: Failed to pull from upstream barretenberg repo. Check your branch name or network connection."
exit 1
fi

echo "(branch migrate) Automatic git data fix"
# Tosses away the .gitrepo changes, as those we only want if pulling from barretenberg master, not PRs (which will go in as aztec commits).
# because git-subrepo uses 'git rm -r', we fix up .gitmodules after as well. This is an edge-case gotcha using
# git submodules along with git-subrepo.

git checkout HEAD^ -- "$SUBREPO_PATH"/.gitrepo .gitmodules

if ! git commit --amend -m "$COMMIT_MESSAGE"; then
echo "Error: Failed to commit changes. Check your commit message."
exit 1
fi
echo "(branch migrate) All done. You can now 'git push origin HEAD' and click to create a PR on aztec. Changes will then automatically go into barretenberg when merged."

0 comments on commit 756c33f

Please sign in to comment.