Skip to content

Commit 6aa7016

Browse files
authored
Add built-date to version command (#636)
* Add built-date to version command * Update makefile to avoid parse date and revision from bin * Force UTC timezone for date command
1 parent 7bce2cc commit 6aa7016

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ build:
103103
@echo "-antigen-env-setup" >> ${TARGET}
104104
@echo "${VERSION}" > ${VERSION_FILE}
105105
@$(call ised,"s/{{ANTIGEN_VERSION}}/$$(cat ${VERSION_FILE})/",${TARGET})
106+
@$(call ised,"s/{{ANTIGEN_REVISION}}/$$(git log -n1 --format=%h -- . ':(exclude)bin')/",${TARGET})
107+
@$(call ised,"s/{{ANTIGEN_REVISION_DATE}}/$$(TZ=UTC date -d @$$(git log -n1 --format='%at' -- . ':(exclude)bin') '+%F %T %z')/",${TARGET})
106108
ifeq (${WITH_DEBUG}, no)
107109
@$(call isede,"s/ (WARN|LOG|ERR|TRACE) .*&//",${TARGET})
108110
@$(call isede,"/ (WARN|LOG|ERR|TRACE) .*/d",${TARGET})

Makefile.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ build:
9191
@echo "-antigen-env-setup" >> ${TARGET}
9292
@echo "${VERSION}" > ${VERSION_FILE}
9393
@$(call ised,"s/{{ANTIGEN_VERSION}}/$$(cat ${VERSION_FILE})/",${TARGET})
94+
@$(call ised,"s/{{ANTIGEN_REVISION}}/$$(git log -n1 --format=%h -- . ':(exclude)bin')/",${TARGET})
95+
@$(call ised,"s/{{ANTIGEN_REVISION_DATE}}/$$(TZ=UTC date -d @$$(git log -n1 --format='%at' -- . ':(exclude)bin') '+%F %T %z')/",${TARGET})
9496
ifeq (${WITH_DEBUG}, no)
9597
@$(call isede,"s/ (WARN|LOG|ERR|TRACE) .*&//",${TARGET})
9698
@$(call isede,"/ (WARN|LOG|ERR|TRACE) .*/d",${TARGET})

bin/antigen.zsh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,13 +1383,11 @@ antigen-use () {
13831383
fi
13841384
}
13851385
antigen-version () {
1386-
local version="develop"
1387-
local extensions revision=""
1388-
if [[ -d $_ANTIGEN_INSTALL_DIR/.git ]]; then
1389-
revision=" ($(git --git-dir=$_ANTIGEN_INSTALL_DIR/.git rev-parse --short '@'))"
1390-
fi
1386+
local extensions
1387+
1388+
printf "Antigen %s (%s)\nRevision date: %s\n" "develop" "2f87993" "2017-12-31 02:09:55 +0000"
13911389

1392-
printf "Antigen %s%s\n" $version $revision
1390+
# Show extension information if any is available
13931391
if (( $+functions[antigen-ext] )); then
13941392
typeset -a extensions; extensions=($(antigen-ext-list))
13951393
if [[ $#extensions -gt 0 ]]; then

src/commands/version.zsh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
antigen-version () {
2-
local version="{{ANTIGEN_VERSION}}"
3-
local extensions revision=""
4-
if [[ -d $_ANTIGEN_INSTALL_DIR/.git ]]; then
5-
revision=" ($(git --git-dir=$_ANTIGEN_INSTALL_DIR/.git rev-parse --short '@'))"
6-
fi
2+
local extensions
3+
4+
printf "Antigen %s (%s)\nRevision date: %s\n" "{{ANTIGEN_VERSION}}" "{{ANTIGEN_REVISION}}" "{{ANTIGEN_REVISION_DATE}}"
75

8-
printf "Antigen %s%s\n" $version $revision
6+
# Show extension information if any is available
97
if (( $+functions[antigen-ext] )); then
108
typeset -a extensions; extensions=($(antigen-ext-list))
119
if [[ $#extensions -gt 0 ]]; then

tests/version.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ Antigen version command.
22

33
$ antigen-version
44
Antigen * (glob)
5+
Revision date: * (glob)
56

67
$ antigen version
78
Antigen * (glob)
9+
Revision date: * (glob)

0 commit comments

Comments
 (0)