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 | |
parent | 5997324709788aaf0e5a17aaa1ccfce208f84ce1 (diff) | |
download | Nim-7ebb042f79b6c796e08e6ff89eaba3a9a67f9d6d.tar.gz |
Atlas: some final cleanups (#21947)
-rw-r--r-- | doc/atlas.md | 20 | ||||
-rw-r--r-- | doc/tools.md | 4 | ||||
-rw-r--r-- | tools/atlas/atlas.nim | 19 |
3 files changed, 22 insertions, 21 deletions
diff --git a/doc/atlas.md b/doc/atlas.md index d0a45c866..2a4171a8b 100644 --- a/doc/atlas.md +++ b/doc/atlas.md @@ -1,7 +1,7 @@ # Atlas Package Cloner -Atlas is a simple package cloner tool that automates some of the -workflows and needs for Nim's stdlib evolution. +Atlas is a simple package cloner tool. It manages an isolated workspace that +contains projects and dependencies. Atlas is compatible with Nimble in the sense that it supports the Nimble file format. @@ -103,7 +103,7 @@ For example: ``` -### Clone/Update <url> +### Clone/Update <url>/<package name> Clones a URL and all of its dependencies (recursively) into the workspace. Creates or patches a `nim.cfg` file with the required `--path` entries. @@ -111,12 +111,8 @@ Creates or patches a `nim.cfg` file with the required `--path` entries. **Note**: Due to the used algorithms an `update` is the same as a `clone`. -### Clone/Update <package name> - -The `<package name>` is translated into an URL via `packages.json` and -then `clone <url>` is performed. - -**Note**: Due to the used algorithms an `update` is the same as a `clone`. +If a `<package name>` is given instead the name is first translated into an URL +via `packages.json` or via a github search. ### Search <term term2 term3 ...> @@ -129,10 +125,10 @@ in its description (or name or list of tags). Use the .nimble file to setup the project's dependencies. -### UpdateWorkspace [filter] +### UpdateProjects / updateDeps [filter] -Update every package in the workspace that has a remote URL that -matches `filter` if a filter is given. The package is only updated +Update every project / dependency in the workspace that has a remote URL that +matches `filter` if a filter is given. The project / dependency is only updated if there are no uncommitted changes. ### Others diff --git a/doc/tools.md b/doc/tools.md index f3fa9eb0c..43b7f6651 100644 --- a/doc/tools.md +++ b/doc/tools.md @@ -42,5 +42,5 @@ The standard distribution ships with the following tools: so can be useful to run your tests, even the most complex ones. - | [atlas](atlas.html) - | `atlas`:cmd: is a simple package cloner tool that automates some of the - workflows and needs for Nim's stdlib evolution. + | `atlas`:cmd: is a simple package cloner tool. It manages an isolated workspace that + contains projects and dependencies. 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: |