Skip to content

Commit

Permalink
Use committer date for commit date and year
Browse files Browse the repository at this point in the history
Quoting CMakeLists.txt: "[...] of latest commit"

"Latest commit" is better served by using the committer date %cd
instead of the author date %ad: The author date could be some time
last year with committer date being today.

Note this affects both autotools and cmake buildsystems to keep
the generated version message dates and year in sync.
  • Loading branch information
ndim committed Feb 19, 2024
1 parent bccad9d commit f8bb561
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ if(Git_FOUND)
)

execute_process(
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%ad --date=format:%Y%m%d
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=format:%Y%m%d
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_COMMIT_DATE
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)

execute_process(
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%ad --date=format:%Y
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=format:%Y
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_COMMIT_YEAR
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
Expand Down
2 changes: 1 addition & 1 deletion src/build-helpers/package-version
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if test -d "$GIT_DIR"; then
echo "version_error_71" | ${TR-tr} -d '\012'; \
exit 2; \
}
GIT_COMMIT_DATE="$(${GIT-git} log -1 --format=%ad --date=format:%Y%m%d)" || { \
GIT_COMMIT_DATE="$(${GIT-git} log -1 --format=%cd --date=format:%Y%m%d)" || { \
echo "$prog: Error: Cannot run 'git log' for commit date" >&2; \
echo "version_error_72" | ${TR-tr} -d '\012'; \
exit 2; \
Expand Down

0 comments on commit f8bb561

Please sign in to comment.