From 2a777cb71bc727836ca9c73ebb193773a99f8f1e Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:29:58 +0000 Subject: [PATCH] hyprctl: add commit date to "hyprctl version" (#4171) * add commit date to "hyprctl version" modified: scripts/generateVersion.sh modified: src/debug/HyprCtl.cpp modified: src/version.h.in * Nix: add date to hyprctl --------- Co-authored-by: Mihai Fufezan --- nix/default.nix | 3 ++- nix/overlays.nix | 9 ++++++--- scripts/generateVersion.sh | 4 +++- src/debug/HyprCtl.cpp | 5 +++-- src/version.h.in | 3 ++- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index d80a42a9..4b1be0e2 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,6 +1,5 @@ { lib, - fetchurl, stdenv, pkg-config, makeWrapper, @@ -35,6 +34,7 @@ wrapRuntimeDeps ? true, version ? "git", commit, + date, # deprecated flags enableNvidiaPatches ? false, nvidiaPatches ? false, @@ -119,6 +119,7 @@ assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been remov --replace "@HASH@" '${commit}' \ --replace "@BRANCH@" "" \ --replace "@MESSAGE@" "" \ + --replace "@DATE@" "${date}" \ --replace "@TAG@" "" \ --replace "@DIRTY@" '${ if commit == "" diff --git a/nix/overlays.nix b/nix/overlays.nix index 3658cdfd..5eb7b082 100644 --- a/nix/overlays.nix +++ b/nix/overlays.nix @@ -28,17 +28,20 @@ in { self.overlays.wlroots-hyprland self.overlays.udis86 # Hyprland packages themselves - (final: prev: { + (final: prev: let + date = mkDate (self.lastModifiedDate or "19700101"); + in { hyprland = final.callPackage ./default.nix { stdenv = final.gcc13Stdenv; - version = "${props.version}+date=${mkDate (self.lastModifiedDate or "19700101")}_${self.shortRev or "dirty"}"; + version = "${props.version}+date=${date}_${self.shortRev or "dirty"}"; wlroots = final.wlroots-hyprland; commit = self.rev or ""; inherit (final) udis86 hyprland-protocols; + inherit date; }; hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;}; hyprland-debug = final.hyprland.override {debug = true;}; - hyprland-legacy-renderer = final.hyprland.override { legacyRenderer = true; }; + hyprland-legacy-renderer = final.hyprland.override {legacyRenderer = true;}; hyprland-nvidia = builtins.trace '' hyprland-nvidia was removed. Please use the hyprland package. diff --git a/scripts/generateVersion.sh b/scripts/generateVersion.sh index c54e2ebd..443c5c54 100755 --- a/scripts/generateVersion.sh +++ b/scripts/generateVersion.sh @@ -4,11 +4,13 @@ cp -fr ./src/version.h.in ./src/version.h HASH=$(git rev-parse HEAD) BRANCH=$(git rev-parse --abbrev-ref HEAD) MESSAGE=$(git show ${GIT_COMMIT_HASH} | head -n 5 | tail -n 1 | sed -e 's/#//g' -e 's/\"//g') +DATE=$(git show ${GIT_COMMIT_HASH} --no-patch --format=%cd --date=local) DIRTY=$(git diff-index --quiet HEAD -- || echo dirty) TAG=$(git describe --tags) sed -i -e "s#@HASH@#${HASH}#" ./src/version.h sed -i -e "s#@BRANCH@#${BRANCH}#" ./src/version.h sed -i -e "s#@MESSAGE@#${MESSAGE}#" ./src/version.h +sed -i -e "s#@DATE@#${DATE}#" ./src/version.h sed -i -e "s#@DIRTY@#${DIRTY}#" ./src/version.h -sed -i -e "s#@TAG@#${TAG}#" ./src/version.h \ No newline at end of file +sed -i -e "s#@TAG@#${TAG}#" ./src/version.h diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 98526ef4..68b74fa7 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -748,7 +748,7 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) { if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) { std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + " " + GIT_DIRTY + " (" + commitMsg + - ").\nTag: " + GIT_TAG + "\n\nflags: (if any)\n"; + ").\nDate: " + GIT_COMMIT_DATE + "\nTag: " + GIT_TAG + "\n\nflags: (if any)\n"; #ifdef LEGACY_RENDERER result += "legacyrenderer\n"; @@ -771,9 +771,10 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) { "commit": "{}", "dirty": {}, "commit_message": "{}", + "commit_date": "{}", "tag": "{}", "flags": [)#", - GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg), GIT_TAG); + GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg), GIT_COMMIT_DATE, GIT_TAG); #ifdef LEGACY_RENDERER result += "\"legacyrenderer\","; diff --git a/src/version.h.in b/src/version.h.in index 6bfd14e5..e0dd8a83 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -2,5 +2,6 @@ #define GIT_COMMIT_HASH "@HASH@" #define GIT_BRANCH "@BRANCH@" #define GIT_COMMIT_MESSAGE "@MESSAGE@" +#define GIT_COMMIT_DATE "@DATE@" #define GIT_DIRTY "@DIRTY@" -#define GIT_TAG "@TAG@" \ No newline at end of file +#define GIT_TAG "@TAG@"