Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 424d7d2

Browse files
author
Ændrew Rininsland
committed
Merge pull request github-tools#169 from aendrew/adding_repo_commit
Adding repo.getCommit method + tests, fixes github-tools#168.
2 parents 20fcff9 + 4d05b74 commit 424d7d2

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ repo.remove('master', 'path/to/file', function(err) {});
132132

133133
Exploring files of a repository is easy too by accessing the top level tree object.
134134

135+
```js
136+
repo.getCommit('master', sha, function(err, commit) {});
137+
```
138+
139+
Get information about a particular commit.
140+
135141
```js
136142
repo.getTree('master', function(err, tree) {});
137143
```
@@ -304,6 +310,7 @@ Include these before github.js :
304310
### 0.10.X
305311

306312
Create and delete repositories
313+
Repos - getCommit
307314

308315
### 0.9.X
309316

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "github-api",
33
"main": "github.js",
4-
"version": "0.10.3",
4+
"version": "0.10.5",
55
"homepage": "https://github.com/michael/github",
66
"authors": [
77
"Sergey Klimov <[email protected]> (http://darvin.github.com/)"

github.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,16 @@
352352
// For a given file path, get the corresponding sha (blob for files, tree for dirs)
353353
// -------
354354

355+
this.getCommit = function(branch, sha, cb) {
356+
_request("GET", repoPath + "/git/commits/"+sha, null, function(err, commit) {
357+
if (err) return cb(err);
358+
cb(null, commit);
359+
});
360+
};
361+
362+
// For a given file path, get the corresponding sha (blob for files, tree for dirs)
363+
// -------
364+
355365
this.getSha = function(branch, path, cb) {
356366
if (!path || path === "") return that.getRef("heads/"+branch, cb);
357367
_request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, pathContent) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-api",
3-
"version": "0.10.4",
3+
"version": "0.10.5",
44
"description": "A higher-level wrapper around the Github API.",
55
"main": "github.js",
66
"dependencies": {

test/test.repo.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ test("Repo API", function(t) {
4949
});
5050
});
5151

52+
t.test('repo.getCommit', function(q) {
53+
repo.getCommit('master', '20fcff9129005d14cc97b9d59b8a3d37f4fb633b', function(err, commit) {
54+
q.error(err, 'get commit' + err);
55+
q.ok(commit.message, 'v0.10.4', 'Returned commit message.');
56+
q.ok(commit.author.date, '2015-03-20T17:01:42Z', 'Got correct date.');
57+
q.end();
58+
});
59+
});
60+
5261
clearTimeout(timeout);
5362
t.end();
5463

0 commit comments

Comments
 (0)