Skip to content

Sealing time from git commit instead of current build time#24

Open
voodoo144 wants to merge 5 commits intomasterfrom
sc-15875/time-from-git-commit
Open

Sealing time from git commit instead of current build time#24
voodoo144 wants to merge 5 commits intomasterfrom
sc-15875/time-from-git-commit

Conversation

@voodoo144
Copy link
Collaborator

No description provided.

@igorniebylski
Copy link
Contributor

i tested teamcity build. build time is now correctly set to time at which git commit was made

@voodoo144 voodoo144 requested review from Copilot and solatis June 12, 2025 01:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the build process to use the commit time from git rather than the current build time when sealing the build metadata.

  • Update the version file in 20.build.sh to substitute BuildTime using GIT_CURRENT_COMMIT_TIME
  • Export a new variable, GIT_CURRENT_COMMIT_TIME, in common.sh using git show

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/teamcity/20.build.sh Uses commit time for BuildTime instead of build time
scripts/common.sh Introduces export for GIT_CURRENT_COMMIT_TIME


sed -i -e 's/const GitHash string = .*/const GitHash string = "'${GIT_HASH}'"/' ${BASE_DIR}/meta/version.go
sed -i -e 's/const BuildTime string = .*/const BuildTime string = "'${CURRENT_DATETIME}'"/' ${BASE_DIR}/meta/version.go
sed -i -e 's/const BuildTime string = .*/const BuildTime string = "'${GIT_CURRENT_COMMIT_TIME}'"/' ${BASE_DIR}/meta/version.go
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider ensuring that GIT_CURRENT_COMMIT_TIME is properly escaped for any special characters or spaces, to avoid issues during the sed substitution.

Suggested change
sed -i -e 's/const BuildTime string = .*/const BuildTime string = "'${GIT_CURRENT_COMMIT_TIME}'"/' ${BASE_DIR}/meta/version.go
ESCAPED_COMMIT_TIME=$(printf '%s' "${GIT_CURRENT_COMMIT_TIME}" | sed 's/[&/\]/\\&/g')
sed -i -e 's|const BuildTime string = .*|const BuildTime string = "'"${ESCAPED_COMMIT_TIME}"'"|' ${BASE_DIR}/meta/version.go

Copilot uses AI. Check for mistakes.
Comment on lines 191 to +192
export GIT_HASH=`git rev-parse HEAD`
export GIT_CURRENT_COMMIT_TIME=`git show -s --format=%ci HEAD`
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using the $(...) command substitution syntax instead of backticks for improved readability and maintainability.

Suggested change
export GIT_HASH=`git rev-parse HEAD`
export GIT_CURRENT_COMMIT_TIME=`git show -s --format=%ci HEAD`
export GIT_HASH=$(git rev-parse HEAD)
export GIT_CURRENT_COMMIT_TIME=$(git show -s --format=%ci HEAD)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants