Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including git-trail with all npm packages installed. Try it out:

var gitTrail = require("git-trail")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

git-trail v0.1.0

Provides a readable stream alternative to `git-log`, so you can access your git history through Node.

git-trail

Provides a readable stream alternative to git-log, so you can access your git history through Node.

Installation

npm install git-trail

Usage

trail(directory, [options]).

var trail = require('git-trail')
  , project = __dirname + '/../synthesis'

trail(project, { until: new Date }).on('data', function(commit) {
  commit.sha             // "bfceb052d8d08db882e75aa0444fe9c51eda76e2"
  commit.body            // "update URLs for new repo name"

  commit.author.email    // "hughskennedy@gmail.com"
  commit.author.name     // "Hugh Kennedy"
  commit.author.date     // Wed Dec 12 20:55:49 2012 +1100

  commit.committer.email // "hughskennedy@gmail.com"
  commit.committer.name  // "Hugh Kennedy"
  commit.committer.date  // Wed Dec 12 20:55:49 2012 +1100
})

Options include:

  • since: The starting date to stream logs from
  • until: The last date to stream logs from
  • format: Specifiy the format of each commit object.

You can use any git-log placeholder when using options.format. For example:

trail(project, {
  format: {
    hash: '%H',
    slug: '%f',
    emails: { author: '%ae', committer: '%ce' }
  }
}).on('data', function(commit) {
  commit.hash // "bfceb052d8d08db882e75aa0444fe9c51eda76e2"
  commit.slug // "update-URLs-for-new-repo-name"

  commit.emails.author    // "hughskennedy@gmail.com"
  commit.emails.committer // "hughskennedy@gmail.com"
})

All options are, well, optional. Enjoy!

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free