Skip to content

Commit f294c43

Browse files
committed
Friendly toString methods for Signature and Commit
1 parent 25ae260 commit f294c43

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ for (var key in rawApi) {
1919
require('./lib/commit.js');
2020
require('./lib/blob.js');
2121
require('./lib/object.js');
22+
require('./lib/signature.js');
2223
require('./lib/odb.js');
2324
require('./lib/oid.js');
2425
require('./lib/index.js');

lib/commit.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,8 @@ Commit.prototype.getDiff = function(callback) {
158158
});
159159
});
160160
};
161+
162+
Commit.prototype.toString = function() {
163+
return this.sha();
164+
}
165+

lib/signature.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var git = require('../'),
2+
Signature = git.Signature;
3+
4+
/**
5+
* Standard string representation of an author.
6+
*/
7+
Signature.prototype.toString = function() {
8+
return this.name().toString() + " <" + this.email().toString() + ">";
9+
};

lib/tree_entry.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ TreeEntry.prototype.getBlob = function(callback) {
6161
TreeEntry.prototype.path = function(callback) {
6262
return path.join(this.parent.path(), this.name());
6363
};
64+
65+
TreeEntry.prototype.toString = function() {
66+
return this.name();
67+
};

0 commit comments

Comments
 (0)