.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.
This commit is contained in:
Dongsu Park 2021-09-30 14:13:14 +02:00 committed by Dongsu Park
parent b1e2d22d03
commit 1cdf93de4d
8 changed files with 22 additions and 5 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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