Skip to content

Commit

Permalink
don't use git -C as it depends on later git version support (#3854)
Browse files Browse the repository at this point in the history
* don't use git -C as it depends on later git version support

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* don't use git -C as it depends on later git version support

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

---------

Signed-off-by: Andrew Leonard <anleonar@redhat.com>
  • Loading branch information
andrew-m-leonard authored Jun 17, 2024
1 parent 8ae8d28 commit 21e479e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ addJVMVariant() {
}

addBuildSHA() { # git SHA of the build repository i.e. openjdk-build
local buildSHA=$(git -C "${BUILD_CONFIG[WORKSPACE_DIR]}" rev-parse HEAD 2>/dev/null)
local buildSHA=$(cd "${BUILD_CONFIG[WORKSPACE_DIR]}" && git rev-parse HEAD 2>/dev/null)
if [[ $buildSHA ]]; then
# shellcheck disable=SC2086
echo -e BUILD_SOURCE=\"git:$buildSHA\" >>release
Expand All @@ -2181,7 +2181,7 @@ addBuildSHA() { # git SHA of the build repository i.e. openjdk-build
}

addBuildSourceRepo() { # name of git repo for which BUILD_SOURCE sha is from
local buildSourceRepo=$(git -C "${BUILD_CONFIG[WORKSPACE_DIR]}" config --get remote.origin.url 2>/dev/null)
local buildSourceRepo=$(cd "${BUILD_CONFIG[WORKSPACE_DIR]}" && git config --get remote.origin.url 2>/dev/null)
if [[ $buildSourceRepo ]]; then
# shellcheck disable=SC2086
echo -e BUILD_SOURCE_REPO=\"$buildSourceRepo\" >>release
Expand All @@ -2191,7 +2191,7 @@ addBuildSourceRepo() { # name of git repo for which BUILD_SOURCE sha is from
}

addOpenJDKSourceRepo() { # name of git repo for which SOURCE sha is from
local openjdkSourceRepo=$(git -C "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}" config --get remote.origin.url 2>/dev/null)
local openjdkSourceRepo=$(cd "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}" && git config --get remote.origin.url 2>/dev/null)
if [[ $openjdkSourceRepo ]]; then
# shellcheck disable=SC2086
echo -e SOURCE_REPO=\"$openjdkSourceRepo\" >>release
Expand Down Expand Up @@ -2221,7 +2221,7 @@ addJ9Tag() {
# This code makes sure that a version number is always present in the release file i.e. openj9-0.21.0
local j9Location="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}/openj9"
# Pull the tag associated with the J9 commit being used
J9_TAG=$(git -C $j9Location describe --abbrev=0)
J9_TAG=$(cd "$j9Location" && git describe --abbrev=0)
# shellcheck disable=SC2086
if [ ${BUILD_CONFIG[RELEASE]} = false ]; then
echo -e OPENJ9_TAG=\"$J9_TAG\" >> release
Expand Down Expand Up @@ -2304,9 +2304,9 @@ addVendorToJson(){
}

addSourceToJson(){ # Pulls the origin repo, or uses 'openjdk-build' in rare cases of failure
local repoName=$(git -C "${BUILD_CONFIG[WORKSPACE_DIR]}" config --get remote.origin.url 2>/dev/null)
local repoName=$(cd "${BUILD_CONFIG[WORKSPACE_DIR]}" && git config --get remote.origin.url 2>/dev/null)
local repoNameStr="${repoName:-"ErrorUnknown"}"
local buildSHA=$(git -C "${BUILD_CONFIG[WORKSPACE_DIR]}" rev-parse HEAD 2>/dev/null)
local buildSHA=$(cd "${BUILD_CONFIG[WORKSPACE_DIR]}" && git rev-parse HEAD 2>/dev/null)
if [[ $buildSHA ]]; then
echo -n "${repoNameStr%%.git}/commit/$buildSHA" > "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/buildSource.txt"
else
Expand All @@ -2315,8 +2315,8 @@ addSourceToJson(){ # Pulls the origin repo, or uses 'openjdk-build' in rare case
}

addOpenJDKSourceToJson() { # name of git repo for which SOURCE sha is from
local openjdkSourceRepo=$(git -C "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}" config --get remote.origin.url 2>/dev/null)
local openjdkSHA=$(git -C "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}" rev-parse HEAD 2>/dev/null)
local openjdkSourceRepo=$(cd "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}" && git config --get remote.origin.url 2>/dev/null)
local openjdkSHA=$(cd "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}" && git rev-parse HEAD 2>/dev/null)
if [[ $openjdkSHA ]]; then
echo -n "${openjdkSourceRepo%%.git}/commit/${openjdkSHA}" > "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/openjdkSource.txt"
else
Expand Down
6 changes: 3 additions & 3 deletions sbin/prepareWorkspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,13 @@ applyPatches() {
createSourceTagFile(){
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ]; then
local OpenJDK_TopDir="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}"
local OpenJDK_SHA=$(git -C "$OpenJDK_TopDir" rev-parse --short HEAD)
local OpenJDK_SHA=$(cd "$OpenJDK_TopDir" && git rev-parse --short HEAD)
if [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_OPENJ9}" ]; then
# OpenJ9 list 3 SHA's in their release file: OpenJDK, OpenJ9, and OMR.
local OpenJ9_TopDir="$OpenJDK_TopDir/openj9"
local OMR_TopDir="$OpenJDK_TopDir/omr"
local OpenJ9_SHA=$(git -C "$OpenJ9_TopDir" rev-parse --short HEAD)
local OMR_SHA=$(git -C "$OMR_TopDir" rev-parse --short HEAD)
local OpenJ9_SHA=$(cd "$OpenJ9_TopDir" && git rev-parse --short HEAD)
local OMR_SHA=$(cd "$OMR_TopDir" && git rev-parse --short HEAD)
(printf "OpenJDK: %s OpenJ9: %s OMR: %s" "$OpenJDK_SHA" "$OpenJ9_SHA" "$OMR_SHA") > "$OpenJDK_TopDir/.hgtip"
else # Other variants only list the main repo SHA.
(printf "OpenJDK: %s" "$OpenJDK_SHA") > "$OpenJDK_TopDir/.hgtip"
Expand Down

0 comments on commit 21e479e

Please sign in to comment.