fix displaying of version and build number in app

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 <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-04-08 15:06:40 +02:00
parent 55a955d8dd
commit 0cc7ec92bd
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
3 changed files with 16 additions and 9 deletions

View File

@ -3,7 +3,7 @@
# #
{ target-os ? "android", { target-os ? "android",
stdenv, mkFilter, clojure, leiningen, nodejs, stdenv, mkFilter, clojure, leiningen, nodejs, bash, git,
leinProjectDeps, localMavenRepoBuilder, projectNodePackage }: leinProjectDeps, localMavenRepoBuilder, projectNodePackage }:
let let
@ -20,7 +20,12 @@ in stdenv.mkDerivation {
filter = filter =
# Keep this filter as restrictive as possible in order to avoid unnecessary rebuilds and limit closure size # Keep this filter as restrictive as possible in order to avoid unnecessary rebuilds and limit closure size
mkFilter { mkFilter {
root = path;
ignoreVCS = false;
include = [ 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/.*" "src/.*" "prod/.*" "env/prod/.*"
"components/src/.*" "components/src/.*"
"react-native/src" "react-native/src"
@ -36,10 +41,9 @@ in stdenv.mkDerivation {
exclude = [ exclude = [
"resources/fonts/.*" "resources/fonts/.*"
]; ];
root = path;
}; };
}; };
buildInputs = [ clojure leiningen nodejs ]; buildInputs = [ clojure leiningen nodejs bash git ];
LEIN_OFFLINE = "y"; LEIN_OFFLINE = "y";

View File

@ -15,7 +15,10 @@ let
# primary path under which all files are included, unless excluded # primary path under which all files are included, unless excluded
root, root,
# list of regex expressions to match files to include/exclude # 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 let
# removes superfluous slashes from the path # removes superfluous slashes from the path
@ -44,13 +47,13 @@ let
isRootSubdir = hasPrefix cleanRoot path; isRootSubdir = hasPrefix cleanRoot path;
isIncluded = checkRegexes (includeSubdirs include); isIncluded = checkRegexes (includeSubdirs include);
isExcluded = checkRegexes exclude; isExcluded = checkRegexes exclude;
isSCV = !cleanSourceFilter path type; isVCS = ignoreVCS && !cleanSourceFilter path type;
in in
if !isRootSubdir then if !isRootSubdir then
# everything outside of root is excluded # everything outside of root is excluded
false false
else if isExcluded || isSCV then else if isExcluded || isVCS then
# isExcluded has precedence over isIncluded # isExcluded has precedence over isIncluded
false false
else else

View File

@ -28,7 +28,7 @@
(defmacro get-current-sha [] (defmacro get-current-sha []
"fetches the latest commit sha from the current branch" "fetches the latest commit sha from the current branch"
(-> (shell/sh "bash" "-c" "git describe --always") (-> (shell/sh "git" "rev-parse" "--short" "HEAD")
:out :out
(string/replace "\n" ""))) (string/replace "\n" "")))
@ -37,6 +37,6 @@
version-file (io/file version-file-path)] version-file (io/file version-file-path)]
(if (.exists version-file) (if (.exists version-file)
(string/trim (slurp version-file-path)) (string/trim (slurp version-file-path))
(-> (shell/sh "bash" "-c" "git describe --always") (-> (shell/sh "git" "rev-parse" "--short" "HEAD")
:out :out
(string/replace "\n" ""))))) (string/replace "\n" "")))))