This is an automated email from the ASF dual-hosted git repository.

rshah pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 3878228f041b0ea931a8df8fda82cf0e62e26eeb
Author: Zach Hoffman <[email protected]>
AuthorDate: Thu Jan 11 12:34:08 2024 -0700

    Include commits since last release in RPM build number (#7896)
    
    * Use number of commits since last release in build number
    
    Previously, the number of commits ever was used, to ensure that a build
    from a later child commit will always be considered a higher version
    number.
    
    Because the version number increases each time the release version
    increases, counting only the commits since the last release tag is
    sufficient.
    
    * Set pipefail and escape $() in Makefile
    
    * Include --long to always get relative commit count
    
    * Use pipefail shell option within bash
    
    * Fall back to commit count of 0 in TPv2
    
    (cherry picked from commit 21d7c9a7109652f091d3b03cdadb9a89d4118865)
---
 CHANGELOG.md                                       |  3 ++-
 build/functions.sh                                 | 11 ++++++++++-
 docs/source/api/v3/about.rst                       |  2 +-
 docs/source/api/v4/about.rst                       |  2 +-
 docs/source/api/v5/about.rst                       |  2 +-
 experimental/traffic-portal/server.config.ts       |  5 ++++-
 infrastructure/cdn-in-a-box/Makefile               |  2 +-
 traffic_ops/testing/api/conf/traffic-ops-test.conf |  8 ++++----
 8 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66b5e324f9..da1c64196c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,8 +3,9 @@ All notable changes to this project will be documented in this 
file.
 
 The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
 
-## [8.0.0] - 2024-01-17
+## [8.0.0] - 2024-01-24
 ### Added
+- [#7896](https://github.com/apache/trafficcontrol/pull/7896) *ATC Build 
system*: Count commits since the last release, not commits.
 - [#7672](https://github.com/apache/trafficcontrol/pull/7672) *Traffic Control 
Health Client*: Added peer monitor flag while using `strategies.yaml`.
 - [#7609](https://github.com/apache/trafficcontrol/pull/7609) *Traffic 
Portal*: Added Scope Query Param to SSO login.
 - [#7450](https://github.com/apache/trafficcontrol/pull/7450) *Traffic Ops*: 
Removed hypnotoad section and added listen field to traffic_ops_golang section 
in order to simplify cdn config.
diff --git a/build/functions.sh b/build/functions.sh
index 97355df8ec..718516d833 100755
--- a/build/functions.sh
+++ b/build/functions.sh
@@ -93,7 +93,16 @@ getBuildNumber() {
        local in_git=''
        if isInGitTree; then
                local commits sha
-               commits="$(git rev-list HEAD 2>/dev/null | wc -l | awk '{print 
$1}')" # awk is for BSD compatibility
+               # The number of commits since the last tag
+               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]' \
+                       --match='v[0-9][0-9].[0-9][0-9].[0-9][0-9]' |
+                       awk -F- '{print $(NF-1)}')";
+               then
+                       commits=0
+               fi
                sha="$(git rev-parse --short=8 HEAD)"
                echo "$commits.$sha"
        else
diff --git a/docs/source/api/v3/about.rst b/docs/source/api/v3/about.rst
index 259956146c..39fa050c08 100644
--- a/docs/source/api/v3/about.rst
+++ b/docs/source/api/v3/about.rst
@@ -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 running ``git rev-list 
HEAD | wc -l``.
+: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.
diff --git a/docs/source/api/v4/about.rst b/docs/source/api/v4/about.rst
index f0e56831c3..78b7e38258 100644
--- a/docs/source/api/v4/about.rst
+++ b/docs/source/api/v4/about.rst
@@ -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 running ``git rev-list 
HEAD | wc -l``.
+: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.
diff --git a/docs/source/api/v5/about.rst b/docs/source/api/v5/about.rst
index 7841e66921..62af25b199 100644
--- a/docs/source/api/v5/about.rst
+++ b/docs/source/api/v5/about.rst
@@ -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 running ``git rev-list 
HEAD | wc -l``.
+: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.
diff --git a/experimental/traffic-portal/server.config.ts 
b/experimental/traffic-portal/server.config.ts
index 83657b7f2a..26485be520 100644
--- a/experimental/traffic-portal/server.config.ts
+++ b/experimental/traffic-portal/server.config.ts
@@ -340,9 +340,12 @@ export async function getVersion(path?: string): 
Promise<ServerVersion> {
        };
 
        try {
-               ver.commits = String(execSync("git rev-list HEAD", {encoding: 
"utf8"}).split("\n").length);
                ver.hash = execSync("git rev-parse --short=8 HEAD", {encoding: 
"utf8"}).trimEnd();
+               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]);
        } catch (e) {
+               ver.commits = "0";
                console.warn("getting git parts of version:", e);
        }
 
diff --git a/infrastructure/cdn-in-a-box/Makefile 
b/infrastructure/cdn-in-a-box/Makefile
index 6d9ca65a80..f0890f989c 100644
--- a/infrastructure/cdn-in-a-box/Makefile
+++ b/infrastructure/cdn-in-a-box/Makefile
@@ -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 git rev-list HEAD 2>/dev/null | wc -l | tr -d 
'[[:space:]]').$(shell git rev-parse --short=8 HEAD)
+BUILD_NUMBER := $(shell bash -c 'set -o pipefail -o xtrace; 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)
diff --git a/traffic_ops/testing/api/conf/traffic-ops-test.conf 
b/traffic_ops/testing/api/conf/traffic-ops-test.conf
index 1143dc0979..075e7ba707 100644
--- a/traffic_ops/testing/api/conf/traffic-ops-test.conf
+++ b/traffic_ops/testing/api/conf/traffic-ops-test.conf
@@ -15,7 +15,7 @@
     "use_ims": true,
     "role_based_permissions": false,
     "trafficOps": {
-        "URL": "https://localhost:6443";,
+        "URL": "https://localhost:8443";,
         "password": "twelve",
         "users": {
             "disallowed": "disallowed",
@@ -28,10 +28,10 @@
         }
     },
     "trafficOpsDB": {
-        "dbname": "traffic_ops_development",
-        "description": "dev database traffic_ops_development",
+        "dbname": "to_test",
+        "description": "test database traffic_ops_development",
         "hostname": "localhost",
-        "password": "twelve12",
+        "password": "twelve",
         "port": "5432",
         "type": "Pg",
         "user": "traffic_ops"

Reply via email to