[PATCH] D142726: [Workflow] Add Release Repo sync script

Tobias Hieta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 27 07:49:33 PST 2023


thieta created this revision.
thieta added reviewers: kwk, tstellar.
Herald added a project: All.
thieta requested review of this revision.
Herald added a project: LLVM.

Adds a bash script that syncs llvm/llvm-project and llvm/llvm-project-release-prs.
This should run on pushes to any of the repositories release branches.

I will follow this up with a change to the github actions to run this
script.

This breaks out the sync script from: https://reviews.llvm.org/D133476
so we can keep them separate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142726

Files:
  llvm/utils/git/sync-release-repo.sh


Index: llvm/utils/git/sync-release-repo.sh
===================================================================
--- /dev/null
+++ llvm/utils/git/sync-release-repo.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+# This script is meant to sync the llvm-project-release-prs repo with the
+# main repo to make the updating automatic. It's meant to be executed from
+# GitHub actions.
+# The script should be executed from a repo cloned from release-prs.
+
+set -e
+set -x
+
+# We should always get the branch from the environment.
+# But otherwise just default to something. We can probably
+# have a better default here?
+BRANCH="${BRANCH:-release/16.x}"
+REPO="https://github.com/llvm/llvm-project"
+
+git config remote.upstream.url >&- || git remote add upstream $REPO
+
+CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+
+# Make sure we are up to date on all our repos first
+git fetch --all
+
+# Start by resetting to the upstream release branch - this is the most important
+# branch always
+git switch -c sync-repos upstream/$BRANCH
+git merge --ff-only origin/$BRANCH
+
+if ! git diff-index --quiet origin/$BRANCH; then
+  echo "Changes in origin - pushing to upstream"
+  git push origin sync-repos:$BRANCH
+fi
+
+# Then we need to update again
+git fetch --all
+
+# And merge all the new data to the current branch
+git merge --ff-only upstream/$BRANCH
+
+# If anything changed let's merge it
+if ! git diff-index --quiet upstream/$BRANCH; then
+  echo "Changes in upstream - pushing to origin"
+  git push upstream sync-repos:$BRANCH
+fi
+
+# Done - let's clean up
+git switch $CURRENT_BRANCH
+
+if git diff-index --quiet HEAD; then
+  git reset --hard @{u}
+fi
+
+git branch -d sync-repos


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142726.492758.patch
Type: text/x-patch
Size: 1684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230127/617e287e/attachment.bin>


More information about the llvm-commits mailing list