summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2023-05-28 18:18:30 +0200
committerGitHub <noreply@github.com>2023-05-28 18:18:30 +0200
commit7ebb042f79b6c796e08e6ff89eaba3a9a67f9d6d (patch)
tree4cb5d51dae559ad53e6e2d3168d68ae59a90bc75
parent5997324709788aaf0e5a17aaa1ccfce208f84ce1 (diff)
downloadNim-7ebb042f79b6c796e08e6ff89eaba3a9a67f9d6d.tar.gz
Atlas: some final cleanups (#21947)
-rw-r--r--doc/atlas.md20
-rw-r--r--doc/tools.md4
-rw-r--r--tools/atlas/atlas.nim19
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:
02 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502