Skip to content

Commit 9febf24

Browse files
Allow getOpenJDKTag() to default to version of checked out BRANCH if no tags in repo (#4265)
* Allow getOpenJDKTag() to default to version of checked out BRANCH if no tags in repo Signed-off-by: Andrew Leonard <[email protected]> * Allow getOpenJDKTag() to default to version of checked out BRANCH if no tags in repo Signed-off-by: Andrew Leonard <[email protected]> * Allow getOpenJDKTag() to default to version of checked out BRANCH if no tags in repo Signed-off-by: Andrew Leonard <[email protected]> * Allow getOpenJDKTag() to default to version of checked out BRANCH if no tags in repo Signed-off-by: Andrew Leonard <[email protected]> --------- Signed-off-by: Andrew Leonard <[email protected]>
1 parent 7587dc2 commit 9febf24

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

sbin/build.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,23 +2053,27 @@ getLatestTagJDK11plus() {
20532053

20542054
createDefaultTag() {
20552055
if [ "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" == "8" ]; then
2056-
echo "WARNING: Could not identify latest tag but the ADOPT_BRANCH_SAFETY flag is off so defaulting to 8u000-b00" 1>&2
2056+
echo "WARNING: Could not identify latest tag, defaulting to 8u000-b00" 1>&2
20572057
echo "8u000-b00"
20582058
else
2059-
echo "WARNING: Could not identify the latest tag, but the ADOPT_BRANCH_SAFETY flag is off, so defaulting to jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}.0.0+0" 1>&2
2059+
echo "WARNING: Could not identify the latest tag, defaulting to jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}.0.0+0" 1>&2
20602060
echo "jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}.0.0+0"
20612061
fi
20622062
}
20632063

2064-
# Get the build "tag" being built, either specified via TAG or BRANCH, otherwise get latest from the git repo
2064+
# Get the build "tag" being built, either specified via TAG or BRANCH, otherwise get latest from the git repo, or default to BRANCH name if set
20652065
getOpenJDKTag() {
2066+
echo "getOpenJDKTag(): Determining OpenJDK tag to use for 'version'" 1>&2
20662067
if [ -n "${BUILD_CONFIG[TAG]}" ]; then
20672068
# Checked out TAG specified
2069+
echo " getOpenJDKTag(): Using specified BUILD_CONFIG[TAG] (${BUILD_CONFIG[TAG]})" 1>&2
20682070
echo "${BUILD_CONFIG[TAG]}"
20692071
elif cd "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}" && git show-ref -q --verify "refs/tags/${BUILD_CONFIG[BRANCH]}"; then
20702072
# Checked out BRANCH is a tag
2073+
echo " getOpenJDKTag(): Using tag specified by BUILD_CONFIG[BRANCH] (${BUILD_CONFIG[BRANCH]})" 1>&2
20712074
echo "${BUILD_CONFIG[BRANCH]}"
20722075
else
2076+
echo " getOpenJDKTag(): Determining tag from checked out repository.." 1>&2
20732077
getFirstTagFromOpenJDKGitRepo
20742078
fi
20752079
}
@@ -2122,14 +2126,8 @@ getFirstTagFromOpenJDKGitRepo() {
21222126

21232127
if [ -z "$firstMatchingNameFromRepo" ]; then
21242128
echo "WARNING: Failed to identify latest tag in the repository" 1>&2
2125-
# If the ADOPT_BRANCH_SAFETY flag is set, we may be building from an alternate
2126-
# repository that doesn't have the same tags, so allow defaults. For a better
2127-
# options see https://github.com/adoptium/temurin-build/issues/2671
2128-
if [ "${BUILD_CONFIG[DISABLE_ADOPT_BRANCH_SAFETY]}" == "true" ]; then
2129-
createDefaultTag
2130-
else
2131-
echo "WARNING: Failed to identify latest tag in the repository" 1>&2
2132-
fi
2129+
# We may be building from an alternate non-adoptium repository, or from a personal branch with no tags, so use a default tag name
2130+
createDefaultTag
21332131
else
21342132
echo "$firstMatchingNameFromRepo"
21352133
fi

sbin/prepareWorkspace.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ checkoutRequiredCodeToBuild() {
225225
git fetch --tags || rc=$?
226226
if [ $rc -eq 0 ]; then
227227
if git show-ref -q --verify "refs/tags/${BUILD_CONFIG[BRANCH]}"; then
228-
echo "looks like the scm ref given is a valid tag, so treat it as a tag"
228+
echo "looks like the BUILD_CONFIG[BRANCH] (${BUILD_CONFIG[BRANCH]}) scm ref given is a valid tag, so treat it as a tag"
229229
tag="${BUILD_CONFIG[BRANCH]}"
230230
BUILD_CONFIG[TAG]="${tag}"
231231
BUILD_CONFIG[SHALLOW_CLONE_OPTION]=""
232-
elif git cat-file commit "${BUILD_CONFIG[BRANCH]}"; then
233-
echo "look like the scm ref given is a valid sha, so treat it as a sha"
232+
elif git cat-file commit "${BUILD_CONFIG[BRANCH]}" 2>/dev/null; then
233+
echo "looks like the BUILD_CONFIG[BRANCH] (${BUILD_CONFIG[BRANCH]}) scm ref given is a valid sha, so treat it as a sha"
234234
sha="${BUILD_CONFIG[BRANCH]}"
235235
BUILD_CONFIG[SHALLOW_CLONE_OPTION]=""
236236
fi
@@ -274,6 +274,7 @@ checkoutRequiredCodeToBuild() {
274274
else
275275
git remote set-branches --add origin "${BUILD_CONFIG[BRANCH]}" || rc=$?
276276
if [ $rc -eq 0 ]; then
277+
echo "BUILD_CONFIG[BRANCH] (${BUILD_CONFIG[BRANCH]}) is a valid branch, fetching and resetting to branch"
277278
# shellcheck disable=SC2086
278279
git fetch --all ${BUILD_CONFIG[SHALLOW_CLONE_OPTION]} || rc=$?
279280
if [ $rc -eq 0 ]; then

0 commit comments

Comments
 (0)