The _app.nit_ annotation `version` sets the version of mobile app packages (.apk and .app). For example, `version(1, 5, git_revision)` may produce the version string "1.5.6b42a7c".
This PR fixes an error when asking for a `git_revision` but the call to `git rev-parse` fails.
Note that the normal git error is printed before the nitc warning message, so debugging should be easy.
Close #2111
Pull-Request: #2113
Reviewed-by: Jean Privat <jean@pryen.org>
return ""
else
for arg in args do
- var format_error = "Syntax Eror: `{name}` expects its arguments to be of type Int or a call to `git_revision`."
-
var value
value = arg.as_int
if value != null then
# Get Git short revision
var proc = new ProcessReader("git", "rev-parse", "--short", "HEAD")
proc.wait
- assert proc.status == 0
+ if proc.status != 0 then
+ # Fallback if this is not a git repository or git bins are missing
+ version_fields.add "0"
+ modelbuilder.warning(self, "git_revision", "Warning: `git_revision` used outside of a git repository or git binaries not available")
+ continue
+ end
+
var lines = proc.read_all
var revision = lines.split("\n").first
continue
end
+ var format_error = "Syntax Error: `{name}` expects its arguments to be of type Int or a call to `git_revision`."
modelbuilder.error(self, format_error)
return ""
end