From 4176c7530e7d6bf2ad503b4b9e351849d1d57211 Mon Sep 17 00:00:00 2001
From: Tom French <tom@tomfren.ch>
Date: Thu, 13 Jun 2024 12:45:56 +0100
Subject: [PATCH] chore: copy across typo PR script from aztec-packages

---
 scripts/redo-typo-pr.sh | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100755 scripts/redo-typo-pr.sh

diff --git a/scripts/redo-typo-pr.sh b/scripts/redo-typo-pr.sh
new file mode 100755
index 00000000000..416be65a449
--- /dev/null
+++ b/scripts/redo-typo-pr.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+set -eux
+
+# Configuration
+ORIGINAL_PR_NUMBER=$1
+REPO='noir-lang/noir'
+NEW_BRANCH="chore/typo-redo-$ORIGINAL_PR_NUMBER"
+AUTHOR=`gh pr view $ORIGINAL_PR_NUMBER --json author --jq '.author.login'`
+
+# Step 1: Checkout the PR locally
+echo "Checking out PR #$ORIGINAL_PR_NUMBER"
+gh pr checkout $ORIGINAL_PR_NUMBER
+
+# Step 2: Create a new local branch
+echo "Creating new local branch $NEW_BRANCH"
+git checkout -b $NEW_BRANCH
+
+# Step 3: Push the new branch to GitHub
+echo "Pushing new branch $NEW_BRANCH to GitHub"
+git commit --amend --no-edit
+git push origin $NEW_BRANCH
+
+# Step 4: create a new pull request
+echo "Creating a new pull request for $NEW_BRANCH"
+gh pr create --base master --head $NEW_BRANCH --title "chore: redo typo PR by $AUTHOR" --body "Thanks $AUTHOR for https://github.com/$REPO/pull/$ORIGINAL_PR_NUMBER. Our policy is to redo typo changes to dissuade metric farming. This is an automated script."
+
+# Step 5: Close the original PR
+echo "Closing original PR #$ORIGINAL_PR_NUMBER"
+gh pr close $ORIGINAL_PR_NUMBER
+
+echo "Script completed."