From a2aa78e8a9ca0848c1cc490c0f750115ec369dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Thu, 22 May 2025 17:46:34 +0200 Subject: [PATCH 1/2] Aggregating code snippets branches --- .../cherry_pick_snippet_updates.sh | 48 +++++++++++++++++++ scripts/code_snippets/sample_commit_output.sh | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 scripts/code_snippets/cherry_pick_snippet_updates.sh diff --git a/scripts/code_snippets/cherry_pick_snippet_updates.sh b/scripts/code_snippets/cherry_pick_snippet_updates.sh new file mode 100755 index 000000000..3ff8f7b65 --- /dev/null +++ b/scripts/code_snippets/cherry_pick_snippet_updates.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -eou pipefail + +release_branch="$1" +if [[ -z "${release_branch}" ]]; then + echo "Usage: $0 " + exit 1 +fi +current_date=$(date "+%Y%m%d") +branch_pattern="origin/meko-snippets-update-${current_date}*" +new_branch_name="mck-snippets-update-cherry-picked-${current_date}-$(date "+%H%M%S")" + +echo "Fetching from origin..." +git fetch origin + +echo "Looking for branches matching '${branch_pattern}'..." +branches_to_pick=() +while IFS= read -r line; do + branches_to_pick+=("$line") +done < <(git branch -r --list "${branch_pattern}" | sed 's/^[[:space:]]*//') + +if [[ ${#branches_to_pick[@]} -eq 0 ]]; then + echo "No branches found matching '${branch_pattern}'. Exiting." + exit 0 +fi + +echo "Found branches to cherry-pick:" +printf " %s\n" "${branches_to_pick[@]}" + +echo "Creating new branch '${new_branch_name}' from 'origin/${release_branch}'..." +git checkout -b "${new_branch_name}" "origin/${release_branch}" + +echo "Cherry-picking commits..." +for branch in "${branches_to_pick[@]}"; do + echo " Picking from ${branch}..." + git cherry-pick "${branch}" || true + + # automatically resolve cherry-pick conflicts by taking whatever it is in the cherry-picked commit + # in case there are no conflicts, this will do nothing + git status --porcelain | grep "^UU" | awk '{print $2}' | xargs -I {} git checkout --theirs {} || true + git status --porcelain | grep "^UU" | awk '{print $2}' | xargs -I {} git add {} || true + # || true for ignoring errors if there are no conflicts + git cherry-pick --continue || true +done + +echo "New branch '${new_branch_name}' created with cherry-picked commits." +echo "Push with: git push origin ${new_branch_name}" diff --git a/scripts/code_snippets/sample_commit_output.sh b/scripts/code_snippets/sample_commit_output.sh index d54623980..3400c5fee 100755 --- a/scripts/code_snippets/sample_commit_output.sh +++ b/scripts/code_snippets/sample_commit_output.sh @@ -5,7 +5,7 @@ source scripts/dev/set_env_context.sh if [ "${COMMIT_OUTPUT:-false}" = true ]; then echo "Pushing output files" - branch="meko-snippets-update-$(date "+%Y%m%d%H%M%S")" + branch="mck-snippets-update-$(date "+%Y%m%d%H%M%S")" git checkout -b "${branch}" git reset git add public/architectures/**/*.out From 35a8dda18dfb7abe3086618202866d951cc72b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Fri, 23 May 2025 13:50:29 +0200 Subject: [PATCH 2/2] Fixed meko to mck --- scripts/code_snippets/cherry_pick_snippet_updates.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/code_snippets/cherry_pick_snippet_updates.sh b/scripts/code_snippets/cherry_pick_snippet_updates.sh index 3ff8f7b65..75b300c12 100755 --- a/scripts/code_snippets/cherry_pick_snippet_updates.sh +++ b/scripts/code_snippets/cherry_pick_snippet_updates.sh @@ -7,8 +7,8 @@ if [[ -z "${release_branch}" ]]; then echo "Usage: $0 " exit 1 fi -current_date=$(date "+%Y%m%d") -branch_pattern="origin/meko-snippets-update-${current_date}*" +current_date=$(date "+%Y%m%d")s +branch_pattern="origin/mck-snippets-update-${current_date}*" new_branch_name="mck-snippets-update-cherry-picked-${current_date}-$(date "+%H%M%S")" echo "Fetching from origin..."