Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 lib/repository.js
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 15 test/tests/signature.js
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.