aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Walch <florian@fwalch.com>2015-09-28 12:17:19 +0200
committerFlorian Walch <florian@fwalch.com>2015-11-01 15:41:36 +0100
commita83020922d0dcdde4ca29394342901ea4bc71e8f (patch)
treec24946b59313578b38a31877086d6748fac51672
parentcb87ea7e82f656711de27121bd67cea9afeab40b (diff)
downloadrneovim-a83020922d0dcdde4ca29394342901ea4bc71e8f.tar.gz
rneovim-a83020922d0dcdde4ca29394342901ea4bc71e8f.tar.bz2
rneovim-a83020922d0dcdde4ca29394342901ea4bc71e8f.zip
version: Prepare for releases.
* Hide commit information from --version if we can't find any (e.g. when building from tarball). To define a release in CMake, set NVIM_VERSION_PRERELEASE to "". This will modify --version output to: * Show annotated Git tag instead of commit hash (NVIM_VERSION_COMMIT). * Hide commit date (NVIM_VERSION_BUILD).
-rw-r--r--CMakeLists.txt27
-rw-r--r--config/versiondef.h.in2
-rw-r--r--src/nvim/version.c4
3 files changed, 21 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7dd444105..f4e5e51bcb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,22 +47,27 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
# Version tokens
-include(GetGitRevisionDescription)
-file(TO_NATIVE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git GIT_DIR)
-get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
-if(NOT NVIM_VERSION_COMMIT)
- set(NVIM_VERSION_COMMIT "?")
-endif()
set(NVIM_VERSION_MAJOR 0)
set(NVIM_VERSION_MINOR 0)
set(NVIM_VERSION_PATCH 0)
set(NVIM_VERSION_PRERELEASE "-alpha")
-# TODO(justinmk): UTC time would be nice here #1071
-git_timestamp(GIT_TIMESTAMP)
-# TODO(justinmk): do not set this for "release" builds #1071
-if(GIT_TIMESTAMP)
- set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}")
+
+include(GetGitRevisionDescription)
+file(TO_NATIVE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git GIT_DIR)
+if(NVIM_VERSION_PRERELEASE)
+ get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
+
+ # TODO(justinmk): UTC time would be nice here #1071
+ git_timestamp(GIT_TIMESTAMP)
+ if(GIT_TIMESTAMP)
+ set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}")
+ endif()
+else()
+ # If possible, get the Git tag for the current revision.
+ git_get_exact_tag(NVIM_VERSION_COMMIT)
+ set(NVIM_VERSION_BUILD "")
endif()
+
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
# NVIM_VERSION_CFLAGS set further below.
diff --git a/config/versiondef.h.in b/config/versiondef.h.in
index a177e599ba..bef099e55f 100644
--- a/config/versiondef.h.in
+++ b/config/versiondef.h.in
@@ -6,7 +6,7 @@
#define NVIM_VERSION_PATCH @NVIM_VERSION_PATCH@
#define NVIM_VERSION_PRERELEASE "@NVIM_VERSION_PRERELEASE@"
#define NVIM_VERSION_BUILD "@NVIM_VERSION_BUILD@"
-#define NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@"
+#cmakedefine NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@"
#define NVIM_VERSION_CFLAGS "@NVIM_VERSION_CFLAGS@"
#define NVIM_VERSION_BUILD_TYPE "@NVIM_VERSION_BUILD_TYPE@"
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 7cc72705b6..c8cbcf2439 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -36,7 +36,9 @@ char *Version = VIM_VERSION_SHORT;
char *longVersion = NVIM_VERSION_LONG;
char *longVersionWithDate = NVIM_VERSION_LONG " (compiled " __DATE__ " " __TIME__ ")";
char *mediumVersion = NVIM_VERSION_MEDIUM;
+#ifdef NVIM_VERSION_COMMIT
char *version_commit = "Commit: " NVIM_VERSION_COMMIT;
+#endif
char *version_buildtype = "Build type: " NVIM_VERSION_BUILD_TYPE;
char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS;
@@ -1024,7 +1026,9 @@ void list_version(void)
// When adding features here, don't forget to update the list of
// internal variables in eval.c!
MSG(longVersionWithDate);
+#ifdef NVIM_VERSION_COMMIT
MSG(version_commit);
+#endif
MSG(version_buildtype);
MSG(version_cflags);