]> dgit.raspbian.org Git - git-annex.git/commitdiff
adjust json field names
authorJoey Hess <joeyh@joeyh.name>
Thu, 29 May 2025 16:42:53 +0000 (12:42 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 29 May 2025 16:42:53 +0000 (12:42 -0400)
Avoid using "name" for what git-annex otherwise refers to as a
description.

(For the remotes in the map, the "remote" field should be the remote
name, but there is a bug preventing it from being that.)

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
Command/Map.hs
doc/todo/map__58___add_--json/comment_2_e9d4957cf5a3d5c015108cb1805df7da._comment

index 0deb5a6029f83b18424db9c4e03aa65d73c4947b..9ecceea2f0f29f4cf053c198489d84728a54d886 100644 (file)
@@ -47,7 +47,7 @@ start = startingNoMessage (ActionItemOther Nothing) $ do
 
        umap <- uuidDescMap
        trustmap <- trustMapLoad
-               
+       
        ifM (outputJSONMap rs trustmap umap)
                ( next $ return True
                , do
@@ -108,8 +108,8 @@ hostname r
 basehostname :: Git.Repo -> String
 basehostname r = fromMaybe "" $ headMaybe $ splitc '.' $ hostname r
 
-{- A name to display for a repo. Uses the name from uuid.log if available,
- - or the remote name if not. -}
+{- A name to display for a repo. Uses the description 
+ - from uuid.log if available, or the remote name if not. -}
 repoName :: UUIDDescMap -> Git.Repo -> String
 repoName umap r
        | repouuid == NoUUID = fallback
@@ -307,14 +307,14 @@ outputJSONMap rs trustmap umap =
                ]
        
        mknode (r, remotes) = JSON.object
-               [ "name" .= packString (repoName umap r)
+               [ "description" .= packString (repoName umap r)
                , "uuid" .= mkuuid (getUncachedUUID r)
                , "url" .= packString (Git.repoLocation r)
                , "remotes" .= map mkremote (filterdead id remotes)
                ]
        
        mkremote r = JSON.object
-               [ "name" .= packString (repoName umap r)
+               [ "remote" .= packString (repoName umap r)
                , "uuid" .= mkuuid (getUncachedUUID r)
                , "url" .= packString (Git.repoLocation r)
                ]
index 15691af27784076af137df95768092befe3cd193..9463fe12f2a6364db7491d13de83a34727adde7f 100644 (file)
@@ -10,10 +10,10 @@ Example output, after being passed through `jq` to pretty-print it:
        {
          "nodes": [
            {
-             "name": "joey@darkstar:~/tmp/mapbench/a",
+             "description": "joey@darkstar:~/tmp/mapbench/a",
              "remotes": [
                {
-                 "name": "joey@darkstar:~/tmp/mapbench/b",
+                 "remote": "b",
                  "url": "/home/joey/tmp/mapbench/b",
                  "uuid": "645d92d8-6461-43c1-b23c-6dd04dc3a015"
                }
@@ -22,10 +22,10 @@ Example output, after being passed through `jq` to pretty-print it:
              "uuid": "3f34e4c2-dd19-433a-ab04-9fd4be959325"
            },
            {
-             "name": "joey@darkstar:~/tmp/mapbench/b",
+             "description": "joey@darkstar:~/tmp/mapbench/b",
              "remotes": [
                {
-                 "name": "joey@darkstar:~/tmp/mapbench/a",
+                 "remote": "a",
                  "url": "/home/joey/tmp/mapbench/a",
                  "uuid": "3f34e4c2-dd19-433a-ab04-9fd4be959325"
                }
@@ -34,10 +34,10 @@ Example output, after being passed through `jq` to pretty-print it:
              "uuid": "645d92d8-6461-43c1-b23c-6dd04dc3a015"
            },
            {
-             "name": "unknown",
+             "description": "unknown",
              "remotes": [
                {
-                 "name": "joey@darkstar:~/tmp/mapbench/b",
+                 "remote": "b",
                  "url": "/home/joey/tmp/mapbench/b",
                  "uuid": "645d92d8-6461-43c1-b23c-6dd04dc3a015"
                }