Creating a line diff with isomorphic-git

Viewed 201

I am trying to get output from isomorphic-git that is similar to git diff for a GitHub action.

I took a look at the map function on the git.walk implementation in isomorphic-git here but I'm having trouble using it.

I'm successfully able to walk the tree using the following code:

async function main() {
  const ref = 'HEAD'
  const trees = [git.TREE({ref}), git.WORKDIR()]
  const walk = await git.walk({
    fs,
    dir: '.github',
    trees,
    map: (filepath, [workdir, tree]) => [filepath, !!workdir, !!tree]
  })

  console.log(walk)
}

main()

How can I improve the map function here and use jsdiff to output the changes in the files between my current worktree and HEAD to stdout?

0 Answers
Related