From 0cc7ec92bd028affa2a35b4d5658f18614fa1b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 8 Apr 2020 15:06:40 +0200 Subject: [PATCH] fix displaying of version and build number in app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Includes `VERSION` file in source for `jsbundle` derivation - Includes `BUILD_NUMBER` file and it's generation scripts - Includes minimal `.git` files to make `git rev-parse --short HEAD` work - Implements `ignoreVCS` for `mkFilter` to be able to include `.git` files - Adds missing `git` and `bash` to `buildInputs` for `jsbundle` derivation - Dropped `bash -c` from Clojure code calling `git` Signed-off-by: Jakub SokoĊ‚owski --- nix/mobile/android/jsbundle/default.nix | 10 +++++++--- nix/tools/mkFilter.nix | 11 +++++++---- src/status_im/utils/build.clj | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/nix/mobile/android/jsbundle/default.nix b/nix/mobile/android/jsbundle/default.nix index e1835f4a8e..6c5b44f657 100644 --- a/nix/mobile/android/jsbundle/default.nix +++ b/nix/mobile/android/jsbundle/default.nix @@ -3,7 +3,7 @@ # { target-os ? "android", - stdenv, mkFilter, clojure, leiningen, nodejs, + stdenv, mkFilter, clojure, leiningen, nodejs, bash, git, leinProjectDeps, localMavenRepoBuilder, projectNodePackage }: let @@ -20,7 +20,12 @@ in stdenv.mkDerivation { filter = # Keep this filter as restrictive as possible in order to avoid unnecessary rebuilds and limit closure size mkFilter { + root = path; + ignoreVCS = false; include = [ + "VERSION" "BUILD_NUMBER" "scripts/version/.*" + # I want to avoid including the whole .git directory + ".git/HEAD" ".git/objects" ".git/refs/heads/.*" "src/.*" "prod/.*" "env/prod/.*" "components/src/.*" "react-native/src" @@ -36,10 +41,9 @@ in stdenv.mkDerivation { exclude = [ "resources/fonts/.*" ]; - root = path; }; }; - buildInputs = [ clojure leiningen nodejs ]; + buildInputs = [ clojure leiningen nodejs bash git ]; LEIN_OFFLINE = "y"; diff --git a/nix/tools/mkFilter.nix b/nix/tools/mkFilter.nix index b8f2ebc4e3..36b95de831 100644 --- a/nix/tools/mkFilter.nix +++ b/nix/tools/mkFilter.nix @@ -15,8 +15,11 @@ let # primary path under which all files are included, unless excluded root, # list of regex expressions to match files to include/exclude - include ? [ ], exclude ? [ ], # has precedence over include - }: + include ? [ ], + exclude ? [ ], # has precedence over include + # by default we ignore Version Control System files + ignoreVCS ? true, + }: let # removes superfluous slashes from the path cleanRoot = "${toString (/. + root)}/"; @@ -44,13 +47,13 @@ let isRootSubdir = hasPrefix cleanRoot path; isIncluded = checkRegexes (includeSubdirs include); isExcluded = checkRegexes exclude; - isSCV = !cleanSourceFilter path type; + isVCS = ignoreVCS && !cleanSourceFilter path type; in if !isRootSubdir then # everything outside of root is excluded false - else if isExcluded || isSCV then + else if isExcluded || isVCS then # isExcluded has precedence over isIncluded false else diff --git a/src/status_im/utils/build.clj b/src/status_im/utils/build.clj index e0f5618ece..e8dd88e986 100644 --- a/src/status_im/utils/build.clj +++ b/src/status_im/utils/build.clj @@ -28,7 +28,7 @@ (defmacro get-current-sha [] "fetches the latest commit sha from the current branch" - (-> (shell/sh "bash" "-c" "git describe --always") + (-> (shell/sh "git" "rev-parse" "--short" "HEAD") :out (string/replace "\n" ""))) @@ -37,6 +37,6 @@ version-file (io/file version-file-path)] (if (.exists version-file) (string/trim (slurp version-file-path)) - (-> (shell/sh "bash" "-c" "git describe --always") + (-> (shell/sh "git" "rev-parse" "--short" "HEAD") :out (string/replace "\n" "")))))