An open API service indexing awesome lists of open source software.

https://github.com/charto/ts-git

Compact high-level JavaScript API for git
https://github.com/charto/ts-git

Last synced: 7 months ago
JSON representation

Compact high-level JavaScript API for git

Awesome Lists containing this project

README

          

ts-git
======

[![build status](https://travis-ci.org/charto/ts-git.svg?branch=master)](http://travis-ci.org/charto/ts-git)
[![dependency status](https://david-dm.org/charto/ts-git.svg)](https://david-dm.org/charto/ts-git)
[![npm version](https://img.shields.io/npm/v/ts-git.svg)](https://www.npmjs.com/package/ts-git)

This is a compact high-level JavaScript API for git. No git installation is needed.
It wraps the low-level [js-git](https://github.com/creationix/js-git) API to investigate
working copies of repositories stored in the local filesystem, much like the `git`
command line tool is often used.

Features
--------

The main high-level operations are:

- Get info (hash, message, time and author) for any commit ([`getCommit`](#api-Git-getCommit)).
- Get logs with commit info working backwards from any commit ([`getLog`](#api-Git-getLog)).
- Optionally filtered to only include commits with changes to a particular file (stopping at renames).
- Check if a particular file in the working tree has changed since the latest commit ([`isDirty`](#api-Git-isDirty)).

API
===
Docs generated using [`docts`](https://github.com/charto/docts)
>
>
> ### Interface [`CommitInfo`](#api-CommitInfo)
> Source code: [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L30-L37)
>
> Properties:
> > **.tree** string
> > **.parents** string[]
> > **.author** [UserTimeInfo](#api-UserTimeInfo)
> > **.committer** [UserTimeInfo](#api-UserTimeInfo)
> > **.message** string
> > **.hash** string
>
>
> ### Interface [`FileInfo`](#api-FileInfo)
> Source code: [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L19-L22)
>
> Properties:
> > **.mode** number
> > **.hash** string
>
>
> ### Interface [`GetLogOptions`](#api-GetLogOptions)
> Filtering options for retrieving logs.
> Source code: [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L12-L17)
>
> Properties:
> > **.path**? string
> >  Only match commits where file at path was changed.
> > **.count**? number
> >  Only match up to given number of commits.
>
>
> ### Class [`Git`](#api-Git)
> Source code: [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L59-L252)
>
> Methods:
> > **new( )** [Git](#api-Git) [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L60-L68)
> >  ▪ basePath string
> > **.getWorkingHead( )** Bluebird<[HeadInfo](#api-HeadInfo)> [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L72-L104)
> >  Get promise resolving to the hash of current working tree HEAD commit.
> > **.getCommit( )** Bluebird<[CommitInfo](#api-CommitInfo)> [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L108-L112)
> >  Get info for commit based on its hash.
> >  ▪ commitHash string
> > **.resolve( )** string [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L116-L118)
> >  Get absolute path to file inside working copy.
> >  ▪ pathName string
> > **.relative( )** string [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L122-L124)
> >  Get path to file inside working copy relative to its root.
> >  ▪ pathName string
> > **.findPath( )** Bluebird<[FileInfo](#api-FileInfo)> [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L129-L146)
> >  Get info for file at pathName inside tree. Tree is a hash
> >  pointing to the contents of a commit, defined in the commit's info.
> >  ▪ treeHash string
> >  ▪ pathName string
> > **.isDirty( )** Bluebird<boolean> [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L151-L184)
> >  Get promise resolving to true if file inside working tree is dirty,
> >  false otherwise.
> >  ▪ pathName string
> > **.walkLog( )** Bluebird<void> [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L189-L237)
> >  Walk the commit log from given hash towards the initial commit,
> >  calling handler for each commit matching options.
> >  ▪ commitHash string
> >  ▪ options [GetLogOptions](#api-GetLogOptions)
> >  ▪ handler (entry: CommitInfo) => void
> > **.getLog( )** Bluebird<[CommitInfo](#api-CommitInfo)[]> [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L243-L247)
> >  Get promise resolving to a list of commits matching options,
> >  in reverse topological / chronological order
> >  from given hash towards the initial commit.
> >  ▪ hash string
> >  ▫ options? [GetLogOptions](#api-GetLogOptions)
>
>
> ### Interface [`HeadInfo`](#api-HeadInfo)
> Source code: [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L39-L42)
>
> Properties:
> > **.branch**? string
> > **.hash**? string
>
>
> ### Interface [`UserTimeInfo`](#api-UserTimeInfo)
> Source code: [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L24-L28)
>
> Properties:
> > **.name** string
> > **.email** string
> > **.date** { seconds: number; offset: number; }
>
>
> ### Function [`getHash`](#api-getHash)
> Get promise resolving to desired type of hash (eg. sha1) for contents of stream.
> Optionally prefix contents with an arbitrary header before hashing.
> Source code: [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L47-L57)
> > **getHash( )** Bluebird<string> [`<>`](http://github.com/charto/ts-git/blob/d42cf28/src/Git.ts#L47-L57)
> >  ▪ type string
> >  ▪ dataStream Readable
> >  ▫ prefix? string

License
=======

[The MIT License](https://raw.githubusercontent.com/charto/ts-git/master/LICENSE)

Copyright (c) 2016 BusFaster Ltd