diff --git a/.github/workflows/auto-cherry-pick.yml b/.github/workflows/auto-cherry-pick.yml index 7105bbccb2d8a1..f76c88934fdc9e 100644 --- a/.github/workflows/auto-cherry-pick.yml +++ b/.github/workflows/auto-cherry-pick.yml @@ -45,7 +45,7 @@ jobs: pip install PyGithub - name: Check SHA run: | - expected_sha="80b7c6087f2a3e4f4c7f035a52e8e7b05ce00f27aa5c1bd52179df685c912447f94a96145fd3204a3958d8ed9777de5a5183b120e99e0e95bbca0366d69b0ac0" + expected_sha="4e4c0d7689b765c7f0677d75d23222555afa9286af46cf77ced66fa247a298d9f8a8c86830d0ce55f70e5f09532b54fbafee040c0343833077cbc7e214d486d2" calculated_sha=$(sha512sum tools/auto-pick-script.py | awk '{ print $1 }') if [ "$calculated_sha" != "$expected_sha" ]; then echo "SHA mismatch! Expected: $expected_sha, but got: $calculated_sha" diff --git a/tools/auto-pick-script.py b/tools/auto-pick-script.py index 8f5376863d3043..a26abeaaa3ac02 100644 --- a/tools/auto-pick-script.py +++ b/tools/auto-pick-script.py @@ -59,8 +59,17 @@ # Clone the repository locally and switch to the new branch repo_url = f"https://x-access-token:{GITHUB_TOKEN}@github.com/{REPO_NAME}.git" -subprocess.run(["git", "clone", repo_url]) repo_dir = REPO_NAME.split("/")[-1] # Get the directory name +#create tmp dir +repo_tmp_dir = f"/tmp/{pr_number}/{TARGET_BRANCH}/" +if os.path.exists(repo_tmp_dir): + print(f"Directory {repo_tmp_dir} already exists. Deleting it.") + subprocess.run(["rm", "-rf", repo_tmp_dir]) +os.makedirs(repo_tmp_dir) +# cd to tmp +os.chdir(repo_tmp_dir) +subprocess.run(["git", "clone", repo_url]) + subprocess.run(["git", "checkout", new_branch_name], cwd=repo_dir) # Set Git user identity for commits @@ -89,11 +98,10 @@ # Create a new PR for the cherry-picked changes new_pr = repo.create_pull( title=f"{TARGET_BRANCH}: {pr.title}", # Prefix with branch name - body=f"PR Body: {pr.body} \n Cherry-picked from #{pr.number}", # Keep the original PR body + body=f"Cherry-picked from #{pr.number}", # Keep the original PR body head=new_branch_name, base=TARGET_BRANCH ) - new_pr.create_issue_comment("run buildall") print(f"Created a new PR #{new_pr.number} for cherry-picked changes.") else: print(f"Commit {merge_commit_sha} was not found in {new_branch_name} after cherry-picking.")