Skip to content

Simple tool to get a JSON from your git log.

Notifications You must be signed in to change notification settings

carlorivera/git2json

 
 

Repository files navigation

git2json

Build Status Code Climate Issue Count Test Coverage npm version

Simple tool to get a JSON from your git log.

CLI usage

  1. Install package globally -> npm i -g @fabien0102/git2json or yarn global add @fabien0102/git2json
  2. Navigate to your local git repository folder
  3. Do git2json > export.json
  4. Voilà!

Lib usage

  1. Add dependency -> npm i -s @fabien0102/git2json or yarn add @fabien0102/git2json
  2. Use it!
const git2json = require('@fabien0102/git2json');

git2json
  .run()
  .then(myGitLogJSON => console.log(myGitLogJSON));

Advanced usage

If needed, you have access to parsers and defaultFields for easy overriding.

Example:

const git2json = require('@fabien0102/git2json');
const exportedFields = {
  author: git2json.defaultFields['author.name'],
  commit: git2json.defaultFields.commit,
  shortTree: { value: '%T', parser: a => a.slice(0, 5)}
};

git2json
  .run({fields: exportedFields})
  .then(json => console.log(json));

You can also specify a path, or paths, for the git repository. Just like the above options, doing so is optional with sane defaults. Multiple paths results in a flattened combined log output.

Example specifying path:

const git2json = require('@fabien0102/git2json');
const path = '~/src/hack/git2json';

git2json
  .run({ path })
  .then(console.log);

Example specifying paths:

const git2json = require('@fabien0102/git2json');
const paths = ['~/etc', '~/src/hack/git2json'];

git2json
  .run({ paths })
  .then(console.log);

About

Simple tool to get a JSON from your git log.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%