Joined May 2016
·

dreamyguy

Frontend Developer at ABC Startsiden AS
·
Oslo, Norway
·
·
·

Posted to Git can do JSON (almost) over 1 year ago

That was a good take!

The most straight-forward way to output stats (through --shortstat) is cumbersome as it gets printed on a new line. As some commits don't have any stats, the new line pattern breaks, making it difficult to port the data reliably. To compensate for that, I had to use several bash commands besides the git log (sed, tr, paste), as you also realised was necessary to use awk...

My solution involves two scripts and is a bit too lengthy to post here, so I'm posting a link instead:

https://github.com/dreamyguy/gitlogg

Some of Gitlogg's features are:

  • Parse the git log of multiple repositories into one JSON file.
  • Introduced repository key/value.
  • Introduced files changed, insertions and deletions keys/values.
  • Introduced impact key/value, which represents the cumulative changes for the commit (insertions - deletions).
  • Sanitise double quotes " by converting them to single quotes ' on all values that allow or are created by user input, like subject.
  • Nearly all the pretty=format: placeholders are available.
  • Easily include / exclude which keys/values will be parsed to JSON by commenting out/uncommenting the available ones.
  • Easy to read code that's thoroughly commented.
  • Script execution feedback on console.
  • Error handling (since path to repositories needs to be set correctly).
Achievements
1 Karma
0 Total ProTip Views