Skip to content

Commit

Permalink
Fix commit tree and add test on tree content
Browse files Browse the repository at this point in the history
  • Loading branch information
feugy committed Sep 15, 2012
1 parent 3adb046 commit bfddb70
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 39 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Commit some changes.
* `options` -
- `all` - `Boolean`
- `amend` - `Boolean`
- `author` - `String` that must match "Au thor Author <[email protected]>"
* `callback` - Receives `(err)`.

### `Repo#add(files, callback)`
Expand All @@ -135,9 +136,8 @@ Commit some changes.
### `Commit#parents`
`Commit[]`

### `Commit#tree(callback)`

* `callback` - Receives `(err, tree)`.
### `Commit#tree()`
`Tree` - The commit's content tree.

### `Commit#author`
`Actor`
Expand Down
2 changes: 1 addition & 1 deletion src/commit.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class Commit
# Public: Get the commit's Tree.
#
# Returns Tree.
@tree = _.memoize => (new Tree this, tree)
@tree = _.memoize => (new Tree @repo, tree)

# Public: Get the Commit's parent Commits.
#
Expand Down
70 changes: 35 additions & 35 deletions test/commit.test.coffee
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
should = require('chai').should()
fixtures = require './fixtures'
git = require '../src'
Commit = require '../src/commit'
Tree = require '../src/tree'

describe "Commit", ->
describe "#tree", ->
repo = git "#{__dirname}/fixtures/branched"
tree = null
before (done) ->
repo.commits "master", (err, commits) ->
tree = commits[0].tree()
done err

it "passes a tree", ->
tree.should.be.an.instanceof Tree


describe "#parents", ->
repo = fixtures.branched
parents = null
parent = null
before (done) ->
repo.commits "something", (err, commits) ->
parents = commits[0].parents()
parent = commits[1]
done err

it "is an Array of Commits", ->
parents.should.be.an.instanceof Array
parents[0].should.be.an.instanceof Commit

it "has the parent commit", ->
parents[0].id.should.eql parent.id
should = require('chai').should()
fixtures = require './fixtures'
git = require '../src'
Commit = require '../src/commit'
Tree = require '../src/tree'

describe "Commit", ->
describe "#tree", ->
repo = git "#{__dirname}/fixtures/branched"
tree = null
before (done) ->
repo.commits "master", (err, commits) ->
tree = commits[0].tree()
done err

it "passes a tree", ->
tree.should.be.an.instanceof Tree


describe "#parents", ->
repo = fixtures.branched
parents = null
parent = null
before (done) ->
repo.commits "something", (err, commits) ->
parents = commits[0].parents()
parent = commits[1]
done err

it "is an Array of Commits", ->
parents.should.be.an.instanceof Array
parents[0].should.be.an.instanceof Commit

it "has the parent commit", ->
parents[0].id.should.eql parent.id
7 changes: 7 additions & 0 deletions test/repo.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ describe "Repo", ->
commit.author.email.should.eql '[email protected]'
done()

it "has a tree", (done) ->
commit.tree().should.be.an.instanceof Tree
commit.tree().contents (err, child) ->
return done err if err
child.length.should.eql 1
child[0].name.should.eql 'foo.txt'
done()

describe "#tree", ->
repo = fixtures.branched
Expand Down

0 comments on commit bfddb70

Please sign in to comment.