From: Sangwook Ha Date: Thu, 15 Sep 2022 01:12:12 +0000 (-0700) Subject: Fix: Address submodule update issues X-Git-Tag: v0.81.1^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F48%2F70648%2F1;p=releng%2Fglobal-jjb.git Fix: Address submodule update issues There are two issues affecting the autorelease-update-submodules jobs: - git-review tries to copy commit-msg hook to submodules with incorrect source file path (.git/hooks/commit-msg) and fails - the path should be ../.git/hooks/commit-msg if a relative path is used since the copy command is run in the submodule directory - lf-activate-venv creates a virtual environment in the current working directory where lf-activate-venv is run. This clutters the repository and all the files for the virtual environment are added for update. To address the bug of git-review set 'core.hooksPath' with the absolute path of the top-level hooks directory so that the correct source path can be used regardless of the working directory. The reason why a virtual environment is created in the working directory is because the following command $python -m venv "$install_args" "$lf_venv" is not equivalent to $python -m venv "$lf_venv" even when $install_args is empty. Hence the first command creates two virtual environments, one in the current working directory and another one in $lf_venv. Use the correct command depending on the $install_args value to avoid the issue. Signed-off-by: Sangwook Ha Change-Id: I445d010c5f5b9e3576bdafb0335ada1092de9d0c --- diff --git a/jenkins-init-scripts/lf-env.sh b/jenkins-init-scripts/lf-env.sh index bd9f7807..91aa80c6 100644 --- a/jenkins-init-scripts/lf-env.sh +++ b/jenkins-init-scripts/lf-env.sh @@ -227,12 +227,16 @@ lf-activate-venv () { # 1. --venv-file as lf_venv # 2. default: "/tmp/.os_lf_venv" # - Create new venv when 1. and 2. is absent - if [ -f "$venv_file" ]; then + if [[ -f "$venv_file" ]]; then lf_venv=$(cat "$venv_file") echo "${FUNCNAME[0]}(): INFO: Reuse venv:$lf_venv from" \ "file:$venv_file" - elif [ ! -f "$venv_file" ]; then - $python -m venv "$install_args" "$lf_venv" || return 1 + elif [[ ! -f "$venv_file" ]]; then + if [[ -n "$install_args" ]]; then + $python -m venv "$install_args" "$lf_venv" || return 1 + else + $python -m venv "$lf_venv" || return 1 + fi echo "${FUNCNAME[0]}(): INFO: Creating $python venv at $lf_venv" echo "$lf_venv" > "$venv_file" echo "${FUNCNAME[0]}(): INFO: Save venv in file: $venv_file" diff --git a/releasenotes/notes/submodule-update-9bd82d3c05ec4148.yaml b/releasenotes/notes/submodule-update-9bd82d3c05ec4148.yaml new file mode 100644 index 00000000..2a430eb1 --- /dev/null +++ b/releasenotes/notes/submodule-update-9bd82d3c05ec4148.yaml @@ -0,0 +1,19 @@ +--- +issues: + - | + git-review tries to copy commit-msg hook to submodules with incorrect + source file path (.git/hooks/commit-msg) and fails - the path should + be ../.git/hooks/commit-msg if a relative path is used since the copy + command is run in the submodule directory + - | + lf-activate-venv creates a virtual environment in the current working + directory where lf-activate-venv is run. This clutters the repository + and all the files for the virtual environment are added for update. + +fixes: + - | + Set 'core.hooksPath' with the absolute path of the top-level hooks directory + so that the correct source path can be used regardless of the working directory. + - | + Use the correct command depending on the $install_args value to avoid + creating an additional virtual environment in the current working directory. diff --git a/shell/gerrit-push-patch.sh b/shell/gerrit-push-patch.sh index a1d67e64..09453f43 100644 --- a/shell/gerrit-push-patch.sh +++ b/shell/gerrit-push-patch.sh @@ -75,4 +75,7 @@ git remote add gerrit "ssh://$GERRIT_USER@$GERRIT_HOST:29418/$PROJECT.git" # If the reviewers email is unset/empty then use a default reviewers_email=${REVIEWERS_EMAIL:-"$GERRIT_USER@$GERRIT_HOST"} +# Workaround for git-review failing to copy the commit-msg hook to submodules +git config core.hooksPath "$(git rev-parse --show-toplevel)/.git/hooks" + git review --yes -t "$GERRIT_TOPIC" --reviewers "$reviewers_email"