FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Check for existence to avoid throwing an error when there is no default signature by tomruggs · Pull Request #577 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion lib/repository.js
This file contains hidden or 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
Expand Up @@ -541,7 +541,7 @@ Repository.prototype.treeBuilder = function() {
Repository.prototype.defaultSignature = function() {
var result = NodeGit.Signature.default(this);

if (!result.name()) {
if (!result || !result.name()) {
result = NodeGit.Signature.now("unknown", "unknown@unknown.com");
}

Expand Down
15 changes: 5 additions & 10 deletions test/tests/signature.js
This file contains hidden or 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
Expand Up @@ -45,17 +45,14 @@ describe("Signature", function() {
assert.equal(when.offset(), -now.getTimezoneOffset());
});

it("can get a default signature when no user name is set", function() {
it("can get a default signature when no user name is set", function(done) {
var savedUserName;
var savedUserEmail;

var cleanUp = function() {
return exec("git config --global user.name \"" + savedUserName + "\"")
.then(function() {
return exec(
"git config --global user.email \"" +
savedUserEmail +
"\"");
exec("git config --global user.email \"" + savedUserEmail + "\"");
});
};

Expand All @@ -78,17 +75,15 @@ describe("Signature", function() {
})
.then(function(repo) {
var sig = repo.defaultSignature();

assert.equal(sig.name(), "unknown");
assert.equal(sig.email(), "unknown@unknown.com");

})
.then(function() {
cleanUp();
})
.then(cleanUp)
.then(done)
.catch(function(e) {
cleanUp()
.then(function() {
done(e);
return Promise.reject(e);
});
});
Expand Down

Back | FazBrowse Home | New Git URL