-2

I using:

 git log --all --pretty=format:'%n{%n%d%n  "commit hash": "%H",%n  "author":     
    "%an",%n  "author_email": "%ae",%n  "date": "%ad",%n  "message": "%f"%n}'

to get the log of all the commits with the differents branches of a github repository, what I need is to transform the output into a .json file to can use as variable in a javascript code.

Simpson G.
  • 111
  • 8

1 Answers1

3

IMO, it is more of a bash command question

git log --all --pretty=format:'%n{%n%d%n  "commit hash": "%H",%n  "author": "%an",%n  "author_email": "%ae",%n  "date": "%ad",%n  "message": "%f"%n}'| grep -v "origin" | tr -d '\n' | sed 's/}{/}, {/g' | sed -e 's/^/[/' |sed -e 's/$/]/' > gitlog.json
D. Seah
  • 4,472
  • 1
  • 12
  • 20
  • Note that if the author name or email address contain double quotes, this will malfunction. It's up to whoever uses this to decide how much to trust those fields. – torek Jul 16 '18 at 04:16
  • How can I get the json file in order? – Simpson G. Jul 18 '18 at 04:13