Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

satellytes/diffy-experiments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A repository where we tinker around with diffs.

  1. Create a way to display diff + comments (like in github)
  2. Provide a way to author comments
  3. Provide a simple role model to display comments only to specific users

Read the Notion Docs for more insights about the plan


Experiments

Click for details

Lost & Found

Some stuff I needed to fetch data from github or whatever comes.

Fetch latest github comments from an example repo so we have some standardized format to merge with the local diffs. The comment format is okay but the comments on the "right" side can be context or addition changes and we have to find out ourselves by searchign the hunk for the matching lines to find out where the comment belongs.

# fetch a first I prepared with some example data PR
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/georgiee/temporary-comment-api/pulls/2/comments >| comments-github.json

# fetch second PR comments and diff
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/satellytes/diffy/pulls/1/comments >| comments-github-v2.json
curl \
    https://patch-diff.githubusercontent.com/raw/satellytes/diffy/pull/1.diff  >| patch-v2.diff

# pick only the interesting fields (requires jq)
cat comments-github-v2.json | jq '.[] | {body, diff_hunk, position, original_position, created_at, start_line, original_start_line, start_side, line, original_line, side}'
# or combine

curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/satellytes/diffy/pulls/1/comments | jq '.[] | {body, diff_hunk, position, original_position, created_at, start_line, original_start_line, start_side, line, original_line, side}' | jq '[inputs]' >| comments-github-v2.json
  

Interesting. Two comments on the same line but on the right and left side (addition and removal) are not

Resources

The interesting things I found: