diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2023-05-28 18:18:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-28 18:18:30 +0200 |
commit | 7ebb042f79b6c796e08e6ff89eaba3a9a67f9d6d (patch) | |
tree | 4cb5d51dae559ad53e6e2d3168d68ae59a90bc75 /tools | |
parent | 5997324709788aaf0e5a17aaa1ccfce208f84ce1 (diff) | |
download | Nim-7ebb042f79b6c796e08e6ff89eaba3a9a67f9d6d.tar.gz |
Atlas: some final cleanups (#21947)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/atlas/atlas.nim | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/atlas/atlas.nim b/tools/atlas/atlas.nim index dc38c4e5b..a8b737103 100644 --- a/tools/atlas/atlas.nim +++ b/tools/atlas/atlas.nim @@ -106,7 +106,7 @@ type keepCommits: bool cfgHere: bool p: Table[string, string] # name -> url mapping - errors: int + errors, warnings: int lockOption: LockOption lockFileToWrite: seq[LockFileEntry] lockFileToUse: Table[string, LockFileEntry] @@ -224,7 +224,7 @@ proc warn(c: var AtlasContext; p: PackageName; arg: string) = message(c, "[Warning] ", p, arg) else: stdout.styledWriteLine(fgYellow, styleBright, "[Warning] ", resetStyle, fgCyan, "(", p.string, ")", resetStyle, " ", arg) - inc c.errors + inc c.warnings proc error(c: var AtlasContext; p: PackageName; arg: string) = if c.noColors: @@ -239,6 +239,8 @@ proc info(c: var AtlasContext; p: PackageName; arg: string) = else: stdout.styledWriteLine(fgGreen, styleBright, "[Info] ", resetStyle, fgCyan, "(", p.string, ")", resetStyle, " ", arg) +template projectFromCurrentDir(): PackageName = PackageName(getCurrentDir().splitPath.tail) + proc sameVersionAs(tag, ver: string): bool = const VersionChars = {'0'..'9', '.'} @@ -317,14 +319,16 @@ proc pushTag(c: var AtlasContext; tag: string) = else: info(c, c.projectDir.PackageName, "successfully pushed tag: " & tag) -proc incrementTag(lastTag: string; field: Natural): string = +proc incrementTag(c: var AtlasContext; lastTag: string; field: Natural): string = var startPos = if lastTag[0] in {'0'..'9'}: 0 else: 1 var endPos = lastTag.find('.', startPos) if field >= 1: for i in 1 .. field: - assert endPos != -1, "the last tag '" & lastTag & "' is missing . periods" + if endPos == -1: + error c, projectFromCurrentDir(), "the last tag '" & lastTag & "' is missing . periods" + return "" startPos = endPos + 1 endPos = lastTag.find('.', startPos) if endPos == -1: @@ -344,7 +348,7 @@ proc incrementLastTag(c: var AtlasContext; field: Natural): string = info c, c.projectDir.PackageName, "the current commit '" & currentCommit & "' is already tagged '" & lastTag & "'" lastTag else: - incrementTag(lastTag, field) + incrementTag(c, lastTag, field) else: "v0.0.1" # assuming no tags have been made yet proc tag(c: var AtlasContext; tag: string) = @@ -602,8 +606,6 @@ const configPatternBegin = "############# begin Atlas config section ##########\n" configPatternEnd = "############# end Atlas config section ##########\n" -template projectFromCurrentDir(): PackageName = PackageName(getCurrentDir().splitPath.tail) - proc patchNimCfg(c: var AtlasContext; deps: seq[CfgPath]; cfgPath: string) = var paths = "--noNimblePath\n" for d in deps: @@ -936,6 +938,9 @@ proc main = elif args[0].len == 1 and args[0][0] in {'a'..'z'}: let field = ord(args[0][0]) - ord('a') tag(c, field) + elif args[0].len == 1 and args[0][0] in {'A'..'Z'}: + let field = ord(args[0][0]) - ord('A') + tag(c, field) elif '.' in args[0]: tag(c, args[0]) else: |