Sealing time from git commit instead of current build time#24
Open
Sealing time from git commit instead of current build time#24
Conversation
Contributor
|
i tested teamcity build. build time is now correctly set to time at which git commit was made |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
Comment on lines
191
to
+192
| export GIT_HASH=`git rev-parse HEAD` | ||
| export GIT_CURRENT_COMMIT_TIME=`git show -s --format=%ci HEAD` |
There was a problem hiding this comment.
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.