Skip to content

Commit 309f0fb

Browse files
committed
Merge pull request octokit#194 from rmhartog/commit_statuses
Updated the routes for Statuses
2 parents 4b66368 + e933cd9 commit 309f0fb

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

api/v3.0.0/routes.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,17 @@
15451545

15461546
"statuses": {
15471547
"get": {
1548-
"url": "/repos/:user/:repo/statuses/:sha",
1548+
"url": "/repos/:user/:repo/commits/:sha/statuses",
1549+
"method": "GET",
1550+
"params": {
1551+
"$user": null,
1552+
"$repo": null,
1553+
"$sha": null
1554+
}
1555+
},
1556+
1557+
"get-combined": {
1558+
"url": "/repos/:user/:repo/commits/:sha/status",
15491559
"method": "GET",
15501560
"params": {
15511561
"$user": null,
@@ -1581,6 +1591,13 @@
15811591
"validation": "",
15821592
"invalidmsg": "",
15831593
"description": "Short description of the status."
1594+
},
1595+
"context": {
1596+
"type": "String",
1597+
"required": false,
1598+
"validation": "",
1599+
"invalidmsg": "",
1600+
"description": "A string label to differentiate this status from the status of other systems."
15841601
}
15851602
}
15861603
}

api/v3.0.0/statuses.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,48 @@ var statuses = module.exports = {
6161
});
6262
};
6363

64+
/** section: github
65+
* statuses#getCombined(msg, callback) -> null
66+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
67+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
68+
*
69+
* ##### Params on the `msg` object:
70+
*
71+
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
72+
* - user (String): Required.
73+
* - repo (String): Required.
74+
* - sha (String): Required.
75+
**/
76+
this.getCombined = function(msg, block, callback) {
77+
var self = this;
78+
this.client.httpSend(msg, block, function(err, res) {
79+
if (err)
80+
return self.sendError(err, null, msg, callback);
81+
82+
var ret;
83+
try {
84+
ret = res.data && JSON.parse(res.data);
85+
}
86+
catch (ex) {
87+
if (callback)
88+
callback(new error.InternalServerError(ex.message), res);
89+
return;
90+
}
91+
92+
if (!ret)
93+
ret = {};
94+
if (!ret.meta)
95+
ret.meta = {};
96+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
97+
if (res.headers[header])
98+
ret.meta[header] = res.headers[header];
99+
});
100+
101+
if (callback)
102+
callback(null, ret);
103+
});
104+
};
105+
64106
/** section: github
65107
* statuses#create(msg, callback) -> null
66108
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
@@ -75,6 +117,7 @@ var statuses = module.exports = {
75117
* - state (String): Required. State of the status - can be one of pending, success, error, or failure. Validation rule: ` ^(pending|success|error|failure)$ `.
76118
* - target_url (String): Optional. Target url to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the ‘source’ of the Status.
77119
* - description (String): Optional. Short description of the status.
120+
* - context (String): Optional. A string label to differentiate this status from the status of other systems.
78121
**/
79122
this.create = function(msg, block, callback) {
80123
var self = this;

api/v3.0.0/statusesTest.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("[statuses]", function() {
2626
});
2727
});
2828

29-
it("should successfully execute GET /repos/:user/:repo/statuses/:sha (get)", function(next) {
29+
it("should successfully execute GET /repos/:user/:repo/commits/:sha/statuses (get)", function(next) {
3030
client.statuses.get(
3131
{
3232
user: "mikedeboer",
@@ -41,6 +41,21 @@ describe("[statuses]", function() {
4141
);
4242
});
4343

44+
it("should successfully execute GET /repos/:user/:repo/commits/:sha/status (get)", function(next) {
45+
client.statuses.getCombined(
46+
{
47+
user: "mikedeboer",
48+
repo: "node-github",
49+
sha: "30d607d8fd8002427b61273f25d442c233cbf631"
50+
},
51+
function(err, res) {
52+
Assert.equal(err, null);
53+
// other assertions go here
54+
next();
55+
}
56+
);
57+
});
58+
4459
it("should successfully execute POST /repos/:user/:repo/statuses/:sha (create)", function(next) {
4560
client.statuses.create(
4661
{

0 commit comments

Comments
 (0)