Skip to content

Commit fc6bc9d

Browse files
author
John Haley
committed
Added in an alias to head() on a repo object
1 parent fb6314a commit fc6bc9d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/repository.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ Repository.prototype.getBranchCommit = function(name, callback) {
9494
}, callback);
9595
};
9696

97+
/**
98+
* Gets the branch that HEAD currently points to
99+
* Is an alias to head()
100+
* @return {Reference}
101+
*/
102+
Repository.prototype.getCurrentBranch = function() {
103+
return this.head();
104+
};
105+
97106
/**
98107
* Lookup the reference with the given name.
99108
*

test/tests/repository.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,10 @@ describe("Repository", function() {
5252
assert.equal(remotes.strings(), "origin");
5353
});
5454
});
55+
56+
it("can get the current branch", function() {
57+
return this.repository.getCurrentBranch().then(function(branch) {
58+
assert.equal(branch.shorthand(), "master");
59+
});
60+
});
5561
});

0 commit comments

Comments
 (0)