Skip to content

Commit

Permalink
Fix missing git revision when built with Nix. (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
neodix42 authored May 4, 2023
1 parent 1696ebf commit f8b585d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"-static-libstdc++"
]);

GIT_REVISION = if self ? rev then self.rev else "dirty";
GIT_REVISION_DATE = (builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" self.lastModifiedDate)) + " " + (builtins.concatStringsSep ":" (builtins.match "^........(.{2})(.{2})(.{2}).*" self.lastModifiedDate));

postInstall = ''
moveToOutput bin "$bin"
'';
Expand Down
4 changes: 4 additions & 0 deletions git_watcher.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ function(GetGitState _working_dir)
RunGitCommand(show -s "--format=%H" ${object})
if(exit_code EQUAL 0)
set(ENV{GIT_HEAD_SHA1} ${output})
else()
set(ENV{GIT_HEAD_SHA1} "$ENV{GIT_REVISION}")
endif()

RunGitCommand(show -s "--format=%an" ${object})
Expand All @@ -154,6 +156,8 @@ function(GetGitState _working_dir)
RunGitCommand(show -s "--format=%ci" ${object})
if(exit_code EQUAL 0)
set(ENV{GIT_COMMIT_DATE_ISO8601} "${output}")
else()
set(ENV{GIT_COMMIT_DATE_ISO8601} "$ENV{GIT_REVISION_DATE}")
endif()

RunGitCommand(show -s "--format=%s" ${object})
Expand Down

0 comments on commit f8b585d

Please sign in to comment.