google / git-appraise

Distributed code review system for Git repos
Apache License 2.0
5.12k stars 145 forks source link

Raw Content of Review Request not in json format #108

Closed byterazor closed 2 years ago

byterazor commented 2 years ago

Hello,

I am trying to parse the review requests with another tool and found out that the raw content of the review request blob is not in json format but it is just the concatenation of json objects.

Is that indented behavior? Why not generate an array of json object?

Thank you for clarification.

best regards Dominik

jonjohnsonjr commented 2 years ago

From https://github.com/google/git-appraise/blob/d586cafb9af9a91db2b93139ee9e73143bc7a8b0/README.md#metadata

The code review data is stored in git-notes, using the formats described below. Each item stored is written as a single line of JSON, and is written with at most one such item per line. This allows the git notes to be automatically merged using the "cat_sort_uniq" strategy.

See https://git-scm.com/docs/git-notes#Documentation/git-notes.txt---strategyltstrategygt

Also https://jsonlines.org/

byterazor commented 2 years ago

Thanks

ojarjur commented 2 years ago

The answer from @jonjohnsonjr is exactly right.

I'll add that you can run git appraise show --json ${REVIEW_HASH} to have git-appraise combine the multiple JSON entries for you and to print the full code review as a JSON object.

Additionally, if you don't want to shell out to git-appriase and your code is written in Go, then you could also call the git-appraise codebase as a library by doing something like this:

import "github.com/google/git-appraise/review"

...
    r, err = review.Get(repo, id)
    ...
    json, err := r.GetJSON()
...