aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt24
-rw-r--r--config/versiondef.h.in3
-rw-r--r--src/nvim/version.c15
-rw-r--r--src/nvim/version.h1
4 files changed, 23 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4e43bbcd41..f11b9995c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,24 +47,26 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
# Version tokens
+# - In a git repo, these tokens are _ignored_.
+# - If the current HEAD is tagged, the tag name is used.
+# - Otherwise the result of `git describe` is used.
+# - If not in a git repo (e.g. a tarball) these tokens set the version string.
set(NVIM_VERSION_MAJOR 0)
set(NVIM_VERSION_MINOR 1)
set(NVIM_VERSION_PATCH 0)
+set(NVIM_VERSION_PRERELEASE "-dev")
file(TO_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git FORCED_GIT_DIR)
include(GetGitRevisionDescription)
-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}")
+get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
+if(NVIM_VERSION_COMMIT) # is a git repo
+ git_get_exact_tag(NVIM_VERSION_MEDIUM)
+ if(NVIM_VERSION_MEDIUM) # is a tagged release
+ unset(NVIM_VERSION_COMMIT)
+ else() # is a dev build
+ git_describe(NVIM_VERSION_MEDIUM)
+ get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
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}")
diff --git a/config/versiondef.h.in b/config/versiondef.h.in
index bef099e55f..7f37ef72fb 100644
--- a/config/versiondef.h.in
+++ b/config/versiondef.h.in
@@ -5,8 +5,9 @@
#define NVIM_VERSION_MINOR @NVIM_VERSION_MINOR@
#define NVIM_VERSION_PATCH @NVIM_VERSION_PATCH@
#define NVIM_VERSION_PRERELEASE "@NVIM_VERSION_PRERELEASE@"
-#define NVIM_VERSION_BUILD "@NVIM_VERSION_BUILD@"
#cmakedefine NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@"
+#cmakedefine NVIM_VERSION_MEDIUM "@NVIM_VERSION_MEDIUM@"
+
#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 c8cbcf2439..5a0f7d524d 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -25,17 +25,18 @@
#define STR_(x) #x
#define STR(x) STR_(x)
-// for the startup-screen ( ":intro" command )
-#define NVIM_VERSION_MEDIUM STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR)
-
-// for the ":version" command and "nvim --version"
-#define NVIM_VERSION_LONG "NVIM " NVIM_VERSION_MEDIUM "." STR(NVIM_VERSION_PATCH) NVIM_VERSION_PRERELEASE NVIM_VERSION_BUILD
+// for ":version", ":intro", and "nvim --version"
+#ifndef NVIM_VERSION_MEDIUM
+#define NVIM_VERSION_MEDIUM STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR)\
+ "." STR(NVIM_VERSION_PATCH) NVIM_VERSION_PRERELEASE
+#endif
+#define NVIM_VERSION_LONG "NVIM " NVIM_VERSION_MEDIUM
char *Version = VIM_VERSION_SHORT;
char *longVersion = NVIM_VERSION_LONG;
-char *longVersionWithDate = NVIM_VERSION_LONG " (compiled " __DATE__ " " __TIME__ ")";
-char *mediumVersion = NVIM_VERSION_MEDIUM;
+char *longVersionWithDate = NVIM_VERSION_LONG \
+ " (compiled " __DATE__ " " __TIME__ ")";
#ifdef NVIM_VERSION_COMMIT
char *version_commit = "Commit: " NVIM_VERSION_COMMIT;
#endif
diff --git a/src/nvim/version.h b/src/nvim/version.h
index c1881250f1..1de809e539 100644
--- a/src/nvim/version.h
+++ b/src/nvim/version.h
@@ -3,7 +3,6 @@
// defined in version.c
extern char* Version;
-extern char* mediumVersion;
extern char* longVersion;
//