Skip to content

Commit

Permalink
Include --long to always get relative commit count
Browse files Browse the repository at this point in the history
  • Loading branch information
zrhoffman committed Jan 10, 2024
1 parent f49cf08 commit 36f28ce
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ getBuildNumber() {
if isInGitTree; then
local commits sha
# The number of commits since the last tag
if ! commits="$(git describe --tags \
if ! commits="$(git describe --long --tags \
--match='RELEASE-[0-9].[0-9].[0-9]' \
--match='RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]' \
--match='v[0-9].[0-9].[0-9]' \
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/v3/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ No parameters available.
Response Structure
------------------
:commitHash: The `Git <https://git-scm.com/>`_ commit hash that Traffic Ops was built at.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags``.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags --long``.
:goVersion: The version of `Go <https://golang.org/>`_ that was used to build Traffic Ops.
:release: The major version of CentOS or Red Hat Enterprise Linux that the build environment was running.
:name: The human-readable name of the `RPM <https://rpm-packaging-guide.github.io/#packaging-software>`_ file.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/v4/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ No parameters available.
Response Structure
------------------
:commitHash: The `Git <https://git-scm.com/>`_ commit hash that Traffic Ops was built at.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags``.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags --long``.
:goVersion: The version of `Go <https://golang.org/>`_ that was used to build Traffic Ops.
:release: The major version of CentOS or Red Hat Enterprise Linux that the build environment was running.
:name: The human-readable name of the `RPM <https://rpm-packaging-guide.github.io/#packaging-software>`_ file.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/v5/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ No parameters available.
Response Structure
------------------
:commitHash: The `Git <https://git-scm.com/>`_ commit hash that Traffic Ops was built at.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags``.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags --long``.
:goVersion: The version of `Go <https://golang.org/>`_ that was used to build Traffic Ops.
:release: The major version of CentOS or Red Hat Enterprise Linux that the build environment was running.
:name: The human-readable name of the `RPM <https://rpm-packaging-guide.github.io/#packaging-software>`_ file.
Expand Down
2 changes: 1 addition & 1 deletion experimental/traffic-portal/server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export async function getVersion(path?: string): Promise<ServerVersion> {
};

try {
ver.commits = String(execSync("git describe --tags --match=RELEASE-[0-9].[0-9].[0-9] --match=RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9] --match=v[0-9].[0-9].[0-9] --match=v[0-9][0-9].[0-9][0-9].[0-9][0-9]", {encoding: "utf8"}).split("-").slice(-2)[0]);
ver.commits = String(execSync("git describe --long --tags --match=RELEASE-[0-9].[0-9].[0-9] --match=RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9] --match=v[0-9].[0-9].[0-9] --match=v[0-9][0-9].[0-9][0-9].[0-9][0-9]", {encoding: "utf8"}).split("-").slice(-2)[0]);
ver.hash = execSync("git rev-parse --short=8 HEAD", {encoding: "utf8"}).trimEnd();
} catch (e) {
console.warn("getting git parts of version:", e);
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/cdn-in-a-box/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TC_DIR := $(CIAB_DIR_RELATIVE)../..
PKG_COMMAND := $(TC_DIR)/pkg
PKG_FLAGS := -v -$(RHEL_VERSION)
BUILD_SUFFIX := _build
BUILD_NUMBER := $(shell set -o pipefail; git describe --tags --match='RELEASE-[0-9].[0-9].[0-9]' --match='RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]' --match='v[0-9].[0-9].[0-9]' --match='v[0-9][0-9].[0-9][0-9].[0-9][0-9]' | awk -F- '{print $$(NF-1)}' || echo 0).$(shell git rev-parse --short=8 HEAD)
BUILD_NUMBER := $(shell set -o pipefail; git describe --long --tags --match='RELEASE-[0-9].[0-9].[0-9]' --match='RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]' --match='v[0-9].[0-9].[0-9]' --match='v[0-9][0-9].[0-9][0-9].[0-9][0-9]' | awk -F- '{print $$(NF-1)}' || echo 0).$(shell git rev-parse --short=8 HEAD)
BUILD_ARCH := $(shell docker run --name=ciab-get-$(BASE_IMAGE)-$(RHEL_VERSION)-arch --rm $(BASE_IMAGE):$(RHEL_VERSION) rpm --eval %_arch )
TC_VERSION := $(shell cat "$(TC_DIR)/VERSION")
TOMCAT_VERSION := $(shell grep '^\s*TOMCAT_VERSION=' "$(TC_DIR)/traffic_router/build/build_rpm.sh" | cut -d= -f2)
Expand Down

0 comments on commit 36f28ce

Please sign in to comment.