Skip to content
Browse files

add new repo merging API

  • Loading branch information...
1 parent f3d26b9 commit 534ed08caa0baa236073a46021ce854340449826 Tim Walling committed Aug 31, 2012
Showing with 83 additions and 0 deletions.
  1. +43 −0 api/v3.0.0/repos.js
  2. +22 −0 api/v3.0.0/reposTest.js
  3. +18 −0 api/v3.0.0/routes.json
View
43 api/v3.0.0/repos.js
@@ -324,6 +324,49 @@ var repos = module.exports = {
};
/** section: github
+ * repos#merge(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - base (String): Required. The name of the base branch that the head will be merged into.
+ * - head (String): Required. The head to merge. This can be a branch name or a commit SHA1.
+ * - commit_message (String): Optional. Commit message to use for the merge commit. If omitted, a default message will be used.
+ **/
+ this.merge = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = res.data && JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ }
+
+ /** section: github
* repos#getContributors(msg, callback) -> null
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
View
22 api/v3.0.0/reposTest.js
@@ -179,6 +179,28 @@ var test = module.exports = {
);
},
+ "test: POST /repos/:user/:repo/merges (merge)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.repos.merge(
+ {
+ user: "String",
+ repo: "String",
+ base: "String",
+ head: "String",
+ commit_message: "String"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
"test: GET /repos/:user/:repo/contributors (getContributors)": function(next) {
var self = this;
this.client.authenticate({
View
18 api/v3.0.0/routes.json
@@ -1648,6 +1648,24 @@
}
},
+ "merge": {
+ "url": "/repos/:user/:repo/merges",
+ "method": "POST",
+ "params": {
+ "$user": null,
+ "$repo": null,
+ "$base": null,
+ "$head": null,
+ "commit_message": {
+ "type": "String",
+ "required": false,
+ "validation": "",
+ "invalidmsg": "",
+ "description": "Optional string - Commit message to use for the merge commit. If omitted, a default message will be used."
+ }
+ }
+ },
+
"get-contributors": {
"url": "/repos/:user/:repo/contributors",
"method": "GET",

0 comments on commit 534ed08

Please sign in to comment.
Something went wrong with that request. Please try again.