forked from danielmahon/gift
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Repo.commit: possibility to specify author
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,12 +211,15 @@ module.exports = class Repo | |
# options - Object (optional). | ||
# "amend" - Boolean | ||
# "all" - Boolean | ||
# "author"- String formated like: A U Thor <[email protected]> | ||
# 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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]>' | ||
, (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 '[email protected]' | ||
done() | ||
|
||
|
||
describe "#tree", -> | ||
repo = fixtures.branched | ||
describe "master", -> | ||
|