[pkg-d-commits] [ldc] 149/211: For non-tagged commits, change version string to e.g. "1.1.0git-c693e26" (#1887)

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:36:18 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.1.0
in repository ldc.

commit 23c1749937095600930bd8973980020b09d47528
Author: Johan Engelen <jbc.engelen at gmail.com>
Date:   Thu Nov 17 22:33:36 2016 +0100

    For non-tagged commits, change version string to e.g. "1.1.0git-c693e26" (#1887)
    
    Also appends "-dirty" to version string when the working copy is dirty.
---
 CMakeLists.txt                                | 10 +++++++++-
 cmake/Modules/GetGitRevisionDescription.cmake |  3 +--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a84f4b..eff8730 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -309,7 +309,15 @@ if(NOT TAG MATCHES "NOTFOUND")
 else()
     get_git_head_revision(REFSPEC HASH)
     if(NOT HASH STREQUAL "GITDIR-NOTFOUND")
-        string(SUBSTRING "${HASH}" 0 6 LDC_VERSION)
+        # Append git hash to LDC_VERSION
+        string(SUBSTRING "${HASH}" 0 7 LDC_VERSION_HASH)
+        set(LDC_VERSION "${LDC_VERSION}git-${LDC_VERSION_HASH}")
+
+        # Append "-dirty" when the working copy is dirty
+        git_describe(GIT_DIRTY --dirty)
+        if (GIT_DIRTY MATCHES ".*-dirty")
+            set(LDC_VERSION "${LDC_VERSION}-dirty")
+        endif()
     endif()
 endif()
 message(STATUS "LDC version identifier: ${LDC_VERSION}")
diff --git a/cmake/Modules/GetGitRevisionDescription.cmake b/cmake/Modules/GetGitRevisionDescription.cmake
index 1cd8d86..5bf7f2f 100644
--- a/cmake/Modules/GetGitRevisionDescription.cmake
+++ b/cmake/Modules/GetGitRevisionDescription.cmake
@@ -84,7 +84,6 @@ function(git_describe _var)
 	execute_process(COMMAND
 		git
 		describe
-		HEAD
 		${ARGN}
 		WORKING_DIRECTORY
 		"${CMAKE_SOURCE_DIR}"
@@ -102,6 +101,6 @@ function(git_describe _var)
 endfunction()
 
 function(git_get_exact_tag _var)
-	git_describe(out --exact-match --tag ${ARGN})
+	git_describe(out HEAD --exact-match --tag ${ARGN})
 	set(${_var} "${out}" PARENT_SCOPE)
 endfunction()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list