mirror of
https://github.com/danog/gift.git
synced 2024-11-30 04:19:37 +01:00
- Repo.commit: possibility to specify author
This commit is contained in:
parent
1ed508199f
commit
6fb57d68c7
@ -211,12 +211,15 @@ module.exports = class Repo
|
||||
# options - Object (optional).
|
||||
# "amend" - Boolean
|
||||
# "all" - Boolean
|
||||
# "author"- String formated like: A U Thor <author@example.com>
|
||||
# callback - Receives `(err)`.
|
||||
#
|
||||
commit: (message, options, callback) ->
|
||||
[options, callback] = [callback, options] if !callback
|
||||
options ?= {}
|
||||
options = _.extend options, {m: "\"#{message}\""}
|
||||
# add quotes around author
|
||||
options.author = "\"#{options.author}\"" if options.author?
|
||||
@git "commit", options, callback
|
||||
|
||||
# Public: Add files to the index.
|
||||
|
@ -85,6 +85,41 @@ describe "Repo", ->
|
||||
commits[0].message.should.include "commit 4"
|
||||
|
||||
|
||||
describe "#commit", ->
|
||||
repo = null
|
||||
commit = null
|
||||
git_dir = __dirname + "/fixtures/junk_commit"
|
||||
# given a fresh new repo
|
||||
before (done) ->
|
||||
rimraf git_dir, (err) ->
|
||||
return done err if err
|
||||
fs.mkdir git_dir, '0755', (err) ->
|
||||
return done err if err
|
||||
git.init git_dir, (err) ->
|
||||
return done err if err
|
||||
repo = git(git_dir)
|
||||
fs.writeFileSync "#{git_dir}/foo.txt", "cheese"
|
||||
repo.add "#{git_dir}/foo.txt", (err) ->
|
||||
return done err if err
|
||||
repo.commit 'message with spaces',
|
||||
all:true
|
||||
author: 'Someone <someone@somewhere.com>'
|
||||
, (err) ->
|
||||
return done err if err
|
||||
repo.commits (err, _commits) ->
|
||||
commit = _commits[0]
|
||||
done err
|
||||
|
||||
after (done) ->
|
||||
rimraf git_dir, done
|
||||
|
||||
it "has right message", (done) ->
|
||||
commit.message.should.eql 'message with spaces'
|
||||
commit.author.name.should.eql 'Someone'
|
||||
commit.author.email.should.eql 'someone@somewhere.com'
|
||||
done()
|
||||
|
||||
|
||||
describe "#tree", ->
|
||||
repo = fixtures.branched
|
||||
describe "master", ->
|
||||
|
Loading…
Reference in New Issue
Block a user