adjust json field names

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
This commit is contained in:
Joey Hess 2025-05-29 12:42:53 -04:00
parent 52a8b5b117
commit a44638ca73
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 11 additions and 11 deletions

View file

@ -47,7 +47,7 @@ start = startingNoMessage (ActionItemOther Nothing) $ do
umap <- uuidDescMap umap <- uuidDescMap
trustmap <- trustMapLoad trustmap <- trustMapLoad
ifM (outputJSONMap rs trustmap umap) ifM (outputJSONMap rs trustmap umap)
( next $ return True ( next $ return True
, do , do
@ -108,8 +108,8 @@ hostname r
basehostname :: Git.Repo -> String basehostname :: Git.Repo -> String
basehostname r = fromMaybe "" $ headMaybe $ splitc '.' $ hostname r basehostname r = fromMaybe "" $ headMaybe $ splitc '.' $ hostname r
{- A name to display for a repo. Uses the name from uuid.log if available, {- A name to display for a repo. Uses the description
- or the remote name if not. -} - from uuid.log if available, or the remote name if not. -}
repoName :: UUIDDescMap -> Git.Repo -> String repoName :: UUIDDescMap -> Git.Repo -> String
repoName umap r repoName umap r
| repouuid == NoUUID = fallback | repouuid == NoUUID = fallback
@ -307,14 +307,14 @@ outputJSONMap rs trustmap umap =
] ]
mknode (r, remotes) = JSON.object mknode (r, remotes) = JSON.object
[ "name" .= packString (repoName umap r) [ "description" .= packString (repoName umap r)
, "uuid" .= mkuuid (getUncachedUUID r) , "uuid" .= mkuuid (getUncachedUUID r)
, "url" .= packString (Git.repoLocation r) , "url" .= packString (Git.repoLocation r)
, "remotes" .= map mkremote (filterdead id remotes) , "remotes" .= map mkremote (filterdead id remotes)
] ]
mkremote r = JSON.object mkremote r = JSON.object
[ "name" .= packString (repoName umap r) [ "remote" .= packString (repoName umap r)
, "uuid" .= mkuuid (getUncachedUUID r) , "uuid" .= mkuuid (getUncachedUUID r)
, "url" .= packString (Git.repoLocation r) , "url" .= packString (Git.repoLocation r)
] ]

View file

@ -10,10 +10,10 @@ Example output, after being passed through `jq` to pretty-print it:
{ {
"nodes": [ "nodes": [
{ {
"name": "joey@darkstar:~/tmp/mapbench/a", "description": "joey@darkstar:~/tmp/mapbench/a",
"remotes": [ "remotes": [
{ {
"name": "joey@darkstar:~/tmp/mapbench/b", "remote": "b",
"url": "/home/joey/tmp/mapbench/b", "url": "/home/joey/tmp/mapbench/b",
"uuid": "645d92d8-6461-43c1-b23c-6dd04dc3a015" "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" "uuid": "3f34e4c2-dd19-433a-ab04-9fd4be959325"
}, },
{ {
"name": "joey@darkstar:~/tmp/mapbench/b", "description": "joey@darkstar:~/tmp/mapbench/b",
"remotes": [ "remotes": [
{ {
"name": "joey@darkstar:~/tmp/mapbench/a", "remote": "a",
"url": "/home/joey/tmp/mapbench/a", "url": "/home/joey/tmp/mapbench/a",
"uuid": "3f34e4c2-dd19-433a-ab04-9fd4be959325" "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" "uuid": "645d92d8-6461-43c1-b23c-6dd04dc3a015"
}, },
{ {
"name": "unknown", "description": "unknown",
"remotes": [ "remotes": [
{ {
"name": "joey@darkstar:~/tmp/mapbench/b", "remote": "b",
"url": "/home/joey/tmp/mapbench/b", "url": "/home/joey/tmp/mapbench/b",
"uuid": "645d92d8-6461-43c1-b23c-6dd04dc3a015" "uuid": "645d92d8-6461-43c1-b23c-6dd04dc3a015"
} }