From 8af2619b8634ab8c884fe2d3b7e092d1435ca891 Mon Sep 17 00:00:00 2001 From: ZhongyiTong Date: Thu, 26 Nov 2015 18:56:30 +0800 Subject: [PATCH 1/2] Add projects fork. --- lib/Models/BaseModel.js | 32 -------------------------------- lib/Models/Projects.js | 16 ++++++++++++++++ src/Models/Projects.coffee | 4 ++++ 3 files changed, 20 insertions(+), 32 deletions(-) delete mode 100644 lib/Models/BaseModel.js diff --git a/lib/Models/BaseModel.js b/lib/Models/BaseModel.js deleted file mode 100644 index c02febc..0000000 --- a/lib/Models/BaseModel.js +++ /dev/null @@ -1,32 +0,0 @@ -// Generated by CoffeeScript 1.6.3 -(function() { - var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - module.exports = (function() { - function exports(client) { - this.client = client; - this._init = __bind(this._init, this); - this.load = __bind(this.load, this); - this._init(); - } - - exports.prototype.load = function(model) { - return require("./" + model)(this.client); - }; - - exports.prototype._init = function() { - this.debug = this.client.debug; - this.get = this.client.get; - this.post = this.client.post; - this.put = this.client.put; - this["delete"] = this.client["delete"]; - if (this.init != null) { - return this.init(); - } - }; - - return exports; - - })(); - -}).call(this); diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index dc23466..86afc23 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -13,6 +13,7 @@ function Projects() { this.search = bind(this.search, this); + this.fork = bind(this.fork, this); this.remove = bind(this.remove, this); this.listTags = bind(this.listTags, this); this.listCommits = bind(this.listCommits, this); @@ -233,6 +234,21 @@ })(this)); }; + Projects.prototype.fork = function(params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Projects::fork()"); + return this.post("projects/" + params.id + "/" + params.namespace_id, params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + Projects.prototype.search = function(projectName, params, fn) { if (params == null) { params = {}; diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 017e7cf..789df96 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -76,6 +76,10 @@ class Projects extends BaseModel @debug "Projects::remove()" @delete "projects/#{Utils.parseProjectId projectId}", (data) => fn data if fn + fork: (params={}, fn=null) => + @debug "Projects::fork()" + @post "projects/#{params.id}/#{params.namespace_id}", params, (data) -> fn data if fn + search: (projectName, params={}, fn=null) => if 'function' is typeof params fn = params From dde8dc8ab13805b9fb1658692a7f53fdf667b346 Mon Sep 17 00:00:00 2001 From: ZhongyiTong Date: Thu, 26 Nov 2015 19:05:48 +0800 Subject: [PATCH 2/2] Fix --- lib/Models/Projects.js | 2 +- src/Models/Projects.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index 86afc23..bf00e1e 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -242,7 +242,7 @@ fn = null; } this.debug("Projects::fork()"); - return this.post("projects/" + params.id + "/" + params.namespace_id, params, function(data) { + return this.post("projects/fork/" + params.id, params, function(data) { if (fn) { return fn(data); } diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 789df96..573c8f1 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -78,7 +78,7 @@ class Projects extends BaseModel fork: (params={}, fn=null) => @debug "Projects::fork()" - @post "projects/#{params.id}/#{params.namespace_id}", params, (data) -> fn data if fn + @post "projects/fork/#{params.id}", params, (data) -> fn data if fn search: (projectName, params={}, fn=null) => if 'function' is typeof params