From 1cdf93de4df24c0f83f5c0da552a6edda598b315 Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Thu, 30 Sep 2021 14:13:14 +0200 Subject: [PATCH] .github: split git repo init part into prepare_git_repo We need to split the beginning of setting up the top-level git repo into a new function prepare_git_repo, and call it in the beginning of each script. That is to prevent some corner cases, where applying multiple patches does not work because the latter overwrites the former patch. So we should not set up the git repo again in each apply_patch, but only in the beggining, prepare_git_repo. --- .../coreos-overlay/.github/workflows/common.sh | 13 ++++++++----- .../.github/workflows/containerd-apply-patch.sh | 2 ++ .../.github/workflows/docker-apply-patch.sh | 2 ++ .../.github/workflows/firmware-apply-patch.sh | 2 ++ .../.github/workflows/go-apply-patch.sh | 2 ++ .../.github/workflows/kernel-apply-patch.sh | 2 ++ .../.github/workflows/runc-apply-patch.sh | 2 ++ .../.github/workflows/rust-apply-patch.sh | 2 ++ 8 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/common.sh b/sdk_container/src/third_party/coreos-overlay/.github/workflows/common.sh index 374ff0f919..79e1fa0d9f 100644 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/common.sh +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/common.sh @@ -31,6 +31,14 @@ function get_ebuild_filename() { fi } +function prepare_git_repo() { + git config user.name "${BUILDBOT_USERNAME}" + git config user.email "${BUILDBOT_USEREMAIL}" + git reset --hard HEAD + git fetch origin + git checkout -B "${BASE_BRANCH}" "origin/${BASE_BRANCH}" +} + # caller needs to set pass a parameter as a branch name to be created. function checkout_branches() { TARGET_BRANCH=$1 @@ -81,11 +89,6 @@ function generate_patches() { } function apply_patches() { - git config user.name "${BUILDBOT_USERNAME}" - git config user.email "${BUILDBOT_USEREMAIL}" - git reset --hard HEAD - git fetch origin - git checkout -B "${BASE_BRANCH}" "origin/${BASE_BRANCH}" git am "${SDK_OUTER_SRCDIR}"/third_party/coreos-overlay/0*.patch rm -f "${SDK_OUTER_SRCDIR}"/third_party/coreos-overlay/0*.patch } diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/containerd-apply-patch.sh b/sdk_container/src/third_party/coreos-overlay/.github/workflows/containerd-apply-patch.sh index ab0906c95c..423083f5e6 100755 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/containerd-apply-patch.sh +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/containerd-apply-patch.sh @@ -6,6 +6,8 @@ UPDATE_NEEDED=1 . .github/workflows/common.sh +prepare_git_repo + if ! checkout_branches "containerd-${VERSION_NEW}-${TARGET}"; then UPDATE_NEEDED=0 exit 0 diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/docker-apply-patch.sh b/sdk_container/src/third_party/coreos-overlay/.github/workflows/docker-apply-patch.sh index 9e53c16e0f..04bea94f4f 100755 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/docker-apply-patch.sh +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/docker-apply-patch.sh @@ -6,6 +6,8 @@ UPDATE_NEEDED=1 . .github/workflows/common.sh +prepare_git_repo + if ! checkout_branches "docker-${VERSION_NEW}-${TARGET}"; then UPDATE_NEEDED=0 exit 0 diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/firmware-apply-patch.sh b/sdk_container/src/third_party/coreos-overlay/.github/workflows/firmware-apply-patch.sh index dbb354f153..1cfb8fcfae 100755 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/firmware-apply-patch.sh +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/firmware-apply-patch.sh @@ -6,6 +6,8 @@ UPDATE_NEEDED=1 . .github/workflows/common.sh +prepare_git_repo + if ! checkout_branches "${VERSION_NEW}-${TARGET}"; then UPDATE_NEEDED=0 exit 0 diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-apply-patch.sh b/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-apply-patch.sh index 3c77618730..d60076d50f 100755 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-apply-patch.sh +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/go-apply-patch.sh @@ -8,6 +8,8 @@ UPDATE_NEEDED=1 . .github/workflows/common.sh +prepare_git_repo + if ! checkout_branches "go-${VERSION_NEW}-${TARGET}"; then UPDATE_NEEDED=0 exit 0 diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/kernel-apply-patch.sh b/sdk_container/src/third_party/coreos-overlay/.github/workflows/kernel-apply-patch.sh index bb699ae73e..34cb256cc2 100755 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/kernel-apply-patch.sh +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/kernel-apply-patch.sh @@ -8,6 +8,8 @@ UPDATE_NEEDED=1 . .github/workflows/common.sh +prepare_git_repo + if ! checkout_branches "linux-${VERSION_NEW}-${TARGET}"; then UPDATE_NEEDED=0 exit 0 diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/runc-apply-patch.sh b/sdk_container/src/third_party/coreos-overlay/.github/workflows/runc-apply-patch.sh index 9ad7a60987..fd90a7d278 100755 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/runc-apply-patch.sh +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/runc-apply-patch.sh @@ -6,6 +6,8 @@ UPDATE_NEEDED=1 . .github/workflows/common.sh +prepare_git_repo + if ! checkout_branches "runc-${VERSION_NEW}-${TARGET}"; then UPDATE_NEEDED=0 exit 0 diff --git a/sdk_container/src/third_party/coreos-overlay/.github/workflows/rust-apply-patch.sh b/sdk_container/src/third_party/coreos-overlay/.github/workflows/rust-apply-patch.sh index f5f646f819..1a740850c6 100755 --- a/sdk_container/src/third_party/coreos-overlay/.github/workflows/rust-apply-patch.sh +++ b/sdk_container/src/third_party/coreos-overlay/.github/workflows/rust-apply-patch.sh @@ -6,6 +6,8 @@ UPDATE_NEEDED=1 . .github/workflows/common.sh +prepare_git_repo + if ! checkout_branches "rust-${VERSION_NEW}-${TARGET}"; then UPDATE_NEEDED=0 exit 0