Skip to content

Commit

Permalink
introduced ErrorVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Zak committed Nov 5, 2020
1 parent 237e9e4 commit c11dc4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tasks/nimbscript.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ template getContext(name: untyped): TaskContext =
getOrAddContext(taskName)

template call*(name: untyped) =
if not globalContext().stop:
if not globalContext().stop:
var taskContext = getContext(name)
let before = getTicks()
`name Task`()
Expand Down
8 changes: 7 additions & 1 deletion tasks/version.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import strutils
import ../tools/runner

type
Version* = object
Version* = object of RootObj
major* : string
minor* : string
patch* : string
hash* : string
isDirty* : bool

ErrorVersion* = object of Version
errors*: seq[string]

proc `$`* (version: Version): string =
result = "$1.$2.$3-$4" % [version.major, version.minor, version.patch, version.hash]
if version.isDirty:
Expand All @@ -28,6 +31,9 @@ proc getVersion*(): Version =
var errors: seq[string] = @[]
let output = runAbs("git -C $1 describe --abbrev=64 --first-parent --long --dirty --always" % scriptPath, errors)

if errors.len > 0:
return ErrorVersion(errors: errors)

let splitMajor = output.split('.')

if splitMajor.len()>1:
Expand Down

0 comments on commit c11dc4f

Please sign in to comment.