1
0
mirror of https://github.com/danog/gift.git synced 2024-11-26 20:04:47 +01:00
gift/README.md

256 lines
5.1 KiB
Markdown
Raw Permalink Normal View History

2012-02-15 15:51:45 +01:00
# Gift
2012-02-15 16:00:43 +01:00
[![Build Status](https://secure.travis-ci.org/sentientwaffle/gift.png?branch=master)](http://travis-ci.org/sentientwaffle/gift)
2012-02-15 15:52:40 +01:00
A simple Node.js wrapper for the Git CLI. The API is based on
2012-02-15 15:51:45 +01:00
[Grit](https://github.com/mojombo/grit)
# Installation
$ npm install gift
# API
git = require 'gift'
repo = git "path/to/repo"
# => #<Repo>
## Repo
2012-03-23 15:39:27 +01:00
### `Repo#path`
2012-02-15 15:51:45 +01:00
`String` - The path to the repository.
2012-03-23 15:39:27 +01:00
### `Repo#commits([treeish, [limit, [skip, ]]]callback)`
2012-02-15 15:51:45 +01:00
Get a list of commits.
* `treeish` - `String` (optional).
* `limit` - `Integer` (optional).
* `skip` - `Integer` (optional).
* `callback` - `Function` which receives `(err, commits)`, where `commits` is
an `Array` of `Commit`s.
Get the 10 most recent commits to master.
repo.commits (err, commits) ->
Or to a different tag or branch.
repo.commits "v0.0.3", (err, commits) ->
Limit the maximum number of commits returned.
repo.commits "master", 30, (err, commits) ->
Skip some (for pagination):
repo.commits "master", 30, 30, (err, commits) ->
2012-03-23 15:39:27 +01:00
### `Repo#tree([treeish]) => Tree`
2012-02-15 15:51:45 +01:00
The `Tree` object for the treeish (which defaults to "master").
repo.tree().contents (err, children) ->
for child in children
console.log child.name
2012-03-23 15:39:27 +01:00
### `Repo#diff(commitA, commitB, [paths, ]callback)`
2012-02-15 15:51:45 +01:00
Get the difference between the trees.
The callback receives `(err, diffs)`.
2012-03-23 15:39:27 +01:00
### `Repo#remotes(callback)`
2012-02-15 15:51:45 +01:00
Get the repository's remotes.
Receives `(err, remotes)`, where each remote is a Ref.
2012-03-23 15:39:27 +01:00
### `Repo#remote_list(callback)`
2012-02-15 15:51:45 +01:00
Get a list of the repository's remote names.
Get the string names of each of the remotes.
2012-03-23 15:39:27 +01:00
### `Repo#remote_add(name, url, callback)`
2012-02-15 15:51:45 +01:00
Equivalent to `git remote add <name> <url>`.
2012-03-23 15:39:27 +01:00
### `Repo#remote_fetch(name, callback)`
2012-02-15 15:51:45 +01:00
`git fetch <name>`
2012-03-23 15:39:27 +01:00
### `Repo#status(callback)`
2012-02-15 15:51:45 +01:00
The callback receives `(err, status)`.
2012-03-23 15:39:27 +01:00
### `Repo#create_branch(name, callback)`
2012-02-15 15:51:45 +01:00
Create a new branch with `name`, and call the callback when complete
with an error, if one occurred.
2012-03-23 15:39:27 +01:00
### `Repo#delete_branch(name, callback)`
2012-02-15 15:51:45 +01:00
Delete the branch `name`, and call the callback with an error, if one occurred.
2012-03-23 15:39:27 +01:00
### `Repo#tags(callback)`
2012-02-15 15:51:45 +01:00
Get a list of `Tag`s.
2012-03-23 15:39:27 +01:00
### `Repo#create_tag(name, [options, ]callback)`
2012-02-15 15:51:45 +01:00
Create a tab with the given name.
2012-03-23 15:39:27 +01:00
### `Repo#delete_tag(name, callback)`
2012-02-15 15:51:45 +01:00
Delete the tag with the given name.
2012-03-23 15:39:27 +01:00
### `Repo#branches(callback)`
2012-02-15 15:51:45 +01:00
`callback` receives `(err, heads)`.
2012-03-23 15:39:27 +01:00
### `Repo#create_branch(name, callback)`
2012-02-15 15:51:45 +01:00
Create a branch with the given name.
2012-03-23 15:39:27 +01:00
### `Repo#delete_branch(delete, callback)`
2012-02-15 15:51:45 +01:00
Delete the branch with the given name.
2012-03-23 15:39:27 +01:00
### `Repo#branch([branch, ]callback)`
2012-02-15 15:51:45 +01:00
Get a branch.
* `branch` - The name of the branch to get. Defaults to the
currently checked out branch.
* `callback` - Receives `(err, head)`.
2012-03-23 15:39:27 +01:00
### `Repo#commit(message, [options, ]callback)`
2012-02-15 15:51:45 +01:00
Commit some changes.
* `message` - `String`
* `options` -
- `all` - `Boolean`
- `amend` - `Boolean`
* `callback` - Receives `(err)`.
2012-03-23 15:39:27 +01:00
### `Repo#add(files, callback)`
2012-02-15 15:51:45 +01:00
`git add <files>`
2012-03-23 15:39:27 +01:00
### `Repo#remove(files, callback)`
2012-02-15 15:51:45 +01:00
`git rm <files>`
2012-03-23 15:39:27 +01:00
### `Repo#checkout(treeish, callback)`
2012-02-15 15:51:45 +01:00
`git checkout <treeish>`
## Commit
2012-03-23 15:39:27 +01:00
### `Commit#id`
2012-02-15 15:51:45 +01:00
`String` - The commit's SHA.
2012-03-23 15:39:27 +01:00
### `Commit#parents`
2012-02-15 15:51:45 +01:00
`Commit[]`
2012-03-23 15:39:27 +01:00
### `Commit#tree(callback)`
2012-02-15 15:51:45 +01:00
* `callback` - Receives `(err, tree)`.
2012-03-23 15:39:27 +01:00
### `Commit#author`
2012-02-15 15:51:45 +01:00
`Actor`
2012-03-23 15:39:27 +01:00
### `Commit#authored_date`
2012-02-15 15:51:45 +01:00
`Date`
2012-03-23 15:39:27 +01:00
### `Commit#committer`
2012-02-15 15:51:45 +01:00
`Actor`
2012-03-23 15:39:27 +01:00
### `Commit#committed_date`
2012-02-15 15:51:45 +01:00
`Date`
2012-03-23 15:39:27 +01:00
### `Commit#message`
2012-02-15 15:51:45 +01:00
`String`
## Head
2012-03-23 15:39:27 +01:00
### `Head#name`
2012-02-15 15:51:45 +01:00
`String`
2012-03-23 15:39:27 +01:00
### `Head#commit`
2012-02-15 15:51:45 +01:00
`Commit`
## Tag
2012-03-23 15:39:27 +01:00
### `Tag#name`
2012-02-15 15:51:45 +01:00
`String`
2012-03-23 15:39:27 +01:00
### `Tag#commit`
2012-02-15 15:51:45 +01:00
`Commit`
2012-03-23 15:39:27 +01:00
### `Tag#message(callback)`
2012-02-15 15:51:45 +01:00
The callback receives `(err, message)` (`message` is a String).
2012-03-23 15:39:27 +01:00
### `Tag#tagger(callback)`
2012-02-15 15:51:45 +01:00
The callback receives `(err, actor)`.
2012-03-23 15:39:27 +01:00
### `Tag#tag_date(callback)`
2012-02-15 15:51:45 +01:00
The callback receives `(err, date)`.
## Status
2012-03-23 15:39:27 +01:00
### `Status#clean`
2012-02-15 15:51:45 +01:00
`Boolean`
2012-03-23 15:39:27 +01:00
### `Status#files`
2012-02-15 15:51:45 +01:00
`Object` - The keys are files, the values objects indicating whether or not
the file is staged, tracked, etc.
Each file has the following properties:
* `type` - "A" for added, "M" for modified, "D" for deleted.
* `staged` - `Boolean`
* `tracked` - `Boolean`
## Actor
2012-03-23 15:39:27 +01:00
### `Actor#name`
2012-02-15 15:51:45 +01:00
`String`
2012-03-23 15:39:27 +01:00
### `Actor#email`
2012-02-15 15:51:45 +01:00
`String`
2012-03-23 15:39:27 +01:00
### `Actor#hash`
2012-02-22 19:44:46 +01:00
`String` - The MD5 hash of the actor's email. Useful for displaying
[Gravatar](http://en.gravatar.com/) avatars.
2012-02-15 15:51:45 +01:00
## Tree
2012-03-23 15:39:27 +01:00
### `Tree#id`
2012-02-15 15:51:45 +01:00
`String` - SHA1
2012-03-23 15:39:27 +01:00
### `Tree#contents(callback)`
2012-02-15 15:51:45 +01:00
* `callback` - Receives `(err, children)`.
* `children` - An array of `Blob`s, `Tree`s, and `Submodule`s.
2012-03-23 15:39:27 +01:00
### `Tree#blobs(callback)`
2012-02-15 15:51:45 +01:00
* `callback` - Receives `(err, child_blobs)`.
* `children` - `[Blob]`
2012-03-23 15:39:27 +01:00
### `Tree#trees(callback)`
2012-02-15 15:51:45 +01:00
* `callback` - Receives `(err, child_trees)`.
* `children` - `[Tree]`
2012-03-23 15:39:27 +01:00
### `Tree#find(directory, callback)`
2012-02-15 15:51:45 +01:00
* `directory` - `String`
* `callback` - Receives `(err, thing)`.
## Blob
2012-03-23 15:39:27 +01:00
### `Blob#id`
2012-02-15 15:51:45 +01:00
`String` - SHA1
2012-03-23 15:39:27 +01:00
### `Blob#mode`
2012-02-15 15:51:45 +01:00
`String`
2012-03-23 15:39:27 +01:00
### `Blob#data(callback)`
2012-02-15 15:51:45 +01:00
* `callback` - `(err, data)`
## Submodule
2012-03-23 15:39:27 +01:00
### `Submodule#id`
2012-02-15 15:51:45 +01:00
`String`
2012-03-23 15:39:27 +01:00
### `Submodule#name`
2012-02-15 15:51:45 +01:00
`String`
2012-03-23 15:39:27 +01:00
### `Submodule#mode`
2012-02-15 15:51:45 +01:00
`String`
2012-03-23 15:39:27 +01:00
### `Submodule#url(callback)`
2012-02-15 15:51:45 +01:00
Get the url the submodule points to.
# License
See LICENSE.