nit: Added link to `CONTRIBUTING.md` from the README
[nit.git] / src / platform / app_annotations.nit
index ab0b067..1d60f15 100644 (file)
@@ -68,9 +68,9 @@ class AppProject
        end
 
        redef fun to_s do return """
-name: {{{name or else "null"}}}
-namespace: {{{namespace or else "null"}}}
-version: {{{version or else "null"}}}"""
+name: {{{name}}}
+namespace: {{{namespace}}}
+version: {{{version}}}"""
 end
 
 redef class AAnnotation
@@ -84,12 +84,10 @@ redef class AAnnotation
 
                var args = n_args
                if args.length < 1 then
-                       modelbuilder.error(self, "Annotation error: \"{name}\" expects at least a single argument.")
+                       modelbuilder.error(self, "Syntax Error: `{name}` expects at least one argument.")
                        return ""
                else
                        for arg in args do
-                               var format_error = "Annotation error: \"{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
@@ -107,7 +105,13 @@ redef class AAnnotation
                                        # 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
 
@@ -122,6 +126,7 @@ redef class AAnnotation
                                        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