Skip to content

Commit 2f3283d

Browse files
Merge pull request #42 from fledge-iot/FOGL-5932.patch
Fix condition when "git describe" command fails
2 parents 066f908 + 91bf7a3 commit 2f3283d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

others/make_rpm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ PKG_NAME="fledge-${ADDITIONAL_LIB_NAME}"
9292
ARCHITECTURE=`arch`
9393
PACKAGE_NAME="${PKG_NAME}-${VERSION}"
9494
BUILD_ROOT="${GIT_ROOT}/packages/build"
95-
GIT_TAG_INFO=$(git describe --tags | sed 's/-/_/g') && COMMIT_COUNT=$(echo ${GIT_TAG_INFO} | cut -d_ -f2) || { COMMIT_COUNT=$(git rev-list --count HEAD); GIT_TAG_INFO="v$VERSION_$COMMIT_COUNT_g$(git rev-parse --short HEAD)"; }
95+
# Get git tag info from "git describe" cmd and if that fails try another method
96+
# Note: git describe command fails when repo does not have release/tag
97+
GIT_TAG_INFO=$(git describe --tags) && GIT_TAG_INFO=$(echo ${GIT_TAG_INFO} | sed 's/-/_/g') && COMMIT_COUNT=$(echo ${GIT_TAG_INFO} | cut -d_ -f2) || { COMMIT_COUNT=$(git rev-list --count HEAD); GIT_TAG_INFO="v${VERSION}_${COMMIT_COUNT}_g$(git rev-parse --short HEAD)"; }
9698
branch_name=$(git rev-parse --abbrev-ref HEAD)
9799
if [[ ${branch_name} = "main" ]] || [[ ${branch_name} =~ ^[0-9]+\.[0-9]+\.[0-9]+RC ]]; then COMMIT_COUNT=1; fi
98100
PACKAGE_NAME="${PKG_NAME}-${VERSION}-${COMMIT_COUNT}"

plugins/make_rpm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ do
135135
else
136136
pkg_name="fledge-${plugin_type}-${plugin_name}"
137137
fi
138-
git_tag_info=$(git describe --tags | sed 's/-/_/g') && commit_count=$(echo ${git_tag_info} | cut -d_ -f2) || { commit_count=$(git rev-list --count HEAD); git_tag_info="v$version_$commit_count_g$(git rev-parse --short HEAD)"; }
138+
# Get git tag info from "git describe" cmd and if that fails try another method
139+
# Note: git describe command fails when repo does not have release/tag
140+
git_tag_info=$(git describe --tags) && git_tag_info=$(echo ${git_tag_info} | sed 's/-/_/g') && commit_count=$(echo ${git_tag_info} | cut -d_ -f2) || { commit_count=$(git rev-list --count HEAD); git_tag_info="v${version}_${commit_count}_g$(git rev-parse --short HEAD)"; }
139141
if [[ ${BRANCH_NAME} = "main" ]] || [[ ${BRANCH_NAME} =~ ^[0-9]+\.[0-9]+\.[0-9]+RC ]]; then commit_count=1; fi
140142
# Final package name
141143
package_name="${pkg_name}-${version}-${commit_count}"

service/make_rpm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ do
151151
else
152152
pkg_name="fledge-service-${service_name}"
153153
fi
154-
git_tag_info=$(git describe --tags | sed 's/-/_/g') && commit_count=$(echo ${git_tag_info} | cut -d_ -f2) || { commit_count=$(git rev-list --count HEAD); git_tag_info="v$version_$commit_count_g$(git rev-parse --short HEAD)"; }
154+
# Get git tag info from "git describe" cmd and if that fails try another method
155+
# Note: git describe command fails when repo does not have release/tag
156+
git_tag_info=$(git describe --tags) && git_tag_info=$(echo ${git_tag_info} | sed 's/-/_/g') && commit_count=$(echo ${git_tag_info} | cut -d_ -f2) || { commit_count=$(git rev-list --count HEAD); git_tag_info="v${version}_${commit_count}_g$(git rev-parse --short HEAD)"; }
155157
if [[ ${BRANCH_NAME} = "main" ]] || [[ ${BRANCH_NAME} =~ ^[0-9]+\.[0-9]+\.[0-9]+RC ]]; then commit_count=1; fi
156158
package_name="${pkg_name}-${version}-${commit_count}"
157159

0 commit comments

Comments
 (0)