From e148b622047611e4560e345b69c0ee7390fbaf36 Mon Sep 17 00:00:00 2001 From: Vinicius Senna Date: Sun, 14 Sep 2014 20:41:41 -0300 Subject: [PATCH 001/135] Pass all parameters to add hook API. --- examples/reset-hooks.coffee | 4 ++++ examples/reset-hooks.js | 9 +++++++-- lib/Models/ProjectHooks.js | 8 ++------ src/Models/ProjectHooks.coffee | 4 +--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/reset-hooks.coffee b/examples/reset-hooks.coffee index b679cfd..1186ac2 100644 --- a/examples/reset-hooks.coffee +++ b/examples/reset-hooks.coffee @@ -27,5 +27,9 @@ gitlab.projects.all (projects) -> console.log ret console.log "#{url} is already OK" else + params = + url:url + issues_events: true + merge_requests_events: true gitlab.projects.hooks.add project.id, url, -> console.log "#{url} has been added" diff --git a/examples/reset-hooks.js b/examples/reset-hooks.js index 91612dc..643e0ab 100644 --- a/examples/reset-hooks.js +++ b/examples/reset-hooks.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; @@ -22,7 +22,7 @@ var project; project = _project; return gitlab.projects.hooks.list(project.id, function(hooks) { - var hook, url, _j, _len1; + var hook, params, url, _j, _len1; url = "" + credentials.service_hook_base + project.path_with_namespace; if (hooks.length > 1) { return console.log("" + url + " too much hooks"); @@ -37,6 +37,11 @@ } return console.log("" + url + " is already OK"); } else { + params = { + url: url, + issues_events: true, + merge_requests_events: true + }; return gitlab.projects.hooks.add(project.id, url, function() { return console.log("" + url + " has been added"); }); diff --git a/lib/Models/ProjectHooks.js b/lib/Models/ProjectHooks.js index c2c210c..e2f7560 100644 --- a/lib/Models/ProjectHooks.js +++ b/lib/Models/ProjectHooks.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectHooks, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, @@ -49,15 +49,11 @@ })(this)); }; - ProjectHooks.prototype.add = function(projectId, url, fn) { - var params; + ProjectHooks.prototype.add = function(projectId, params, fn) { if (fn == null) { fn = null; } this.debug("Projects::addHook()"); - params = { - url: url - }; return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/hooks", params, (function(_this) { return function(data) { if (fn) { diff --git a/src/Models/ProjectHooks.coffee b/src/Models/ProjectHooks.coffee index ab13603..4725f37 100644 --- a/src/Models/ProjectHooks.coffee +++ b/src/Models/ProjectHooks.coffee @@ -10,10 +10,8 @@ class ProjectHooks extends BaseModel @debug "Projects::hook()" @get "projects/#{Utils.parseProjectId projectId}/hooks/#{parseInt hookId}", (data) => fn data if fn - add: (projectId, url, fn = null) => + add: (projectId, params, fn = null) => @debug "Projects::addHook()" - params = - url: url @post "projects/#{Utils.parseProjectId projectId}/hooks", params, (data) => fn data if fn update: (projectId, hookId, url, fn = null) => From 16c45bfd948253d6021fef5212b5ea38037902c8 Mon Sep 17 00:00:00 2001 From: Christian Bankester Date: Sun, 5 Oct 2014 15:01:23 -0500 Subject: [PATCH 002/135] Build with new coffee, fix repo.showFile --- examples/example.credentials.js | 2 +- examples/list-projects.js | 2 +- examples/list-users.js | 2 +- examples/reset-hooks.js | 2 +- examples/show-project.js | 2 +- examples/show-user.js | 2 +- lib/ApiBase.js | 2 +- lib/ApiBaseHTTP.js | 2 +- lib/ApiV3.js | 2 +- lib/BaseModel.js | 2 +- lib/Models/Groups.js | 2 +- lib/Models/Issues.js | 2 +- lib/Models/ProjectDeployKeys.js | 2 +- lib/Models/ProjectHooks.js | 2 +- lib/Models/ProjectIssues.js | 2 +- lib/Models/ProjectMembers.js | 2 +- lib/Models/ProjectMergeRequests.js | 2 +- lib/Models/ProjectMilestones.js | 2 +- lib/Models/ProjectRepository.js | 8 ++++---- lib/Models/Projects.js | 2 +- lib/Models/Users.js | 2 +- lib/Utils.js | 2 +- lib/index.js | 2 +- src/Models/ProjectRepository.coffee | 6 +++--- tests/mock.js | 2 +- tests/test.js | 2 +- tests/validators.js | 2 +- 27 files changed, 32 insertions(+), 32 deletions(-) diff --git a/examples/example.credentials.js b/examples/example.credentials.js index f1dcef6..f3c5c56 100755 --- a/examples/example.credentials.js +++ b/examples/example.credentials.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { module.exports = { url: 'http://demo.gitlab.com', diff --git a/examples/list-projects.js b/examples/list-projects.js index c388fdf..934a7ae 100755 --- a/examples/list-projects.js +++ b/examples/list-projects.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; diff --git a/examples/list-users.js b/examples/list-users.js index 3787886..79e84ea 100644 --- a/examples/list-users.js +++ b/examples/list-users.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; diff --git a/examples/reset-hooks.js b/examples/reset-hooks.js index 91612dc..47eb0dc 100644 --- a/examples/reset-hooks.js +++ b/examples/reset-hooks.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; diff --git a/examples/show-project.js b/examples/show-project.js index 2cdf52b..e06b388 100755 --- a/examples/show-project.js +++ b/examples/show-project.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab, projectId; diff --git a/examples/show-user.js b/examples/show-user.js index d692363..12306e4 100755 --- a/examples/show-user.js +++ b/examples/show-user.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab, userId; diff --git a/lib/ApiBase.js b/lib/ApiBase.js index 631134d..65c20ec 100644 --- a/lib/ApiBase.js +++ b/lib/ApiBase.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index 52ae2c8..ee3a192 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var ApiBase, debug, querystring, slumber, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/ApiV3.js b/lib/ApiV3.js index 61f9ee7..dd0dd8c 100644 --- a/lib/ApiV3.js +++ b/lib/ApiV3.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var ApiBaseHTTP, debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/BaseModel.js b/lib/BaseModel.js index d621e47..acc7730 100644 --- a/lib/BaseModel.js +++ b/lib/BaseModel.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index d29e3f2..4c45352 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, Groups, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/Issues.js b/lib/Models/Issues.js index c1dab62..748cdfe 100644 --- a/lib/Models/Issues.js +++ b/lib/Models/Issues.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, Issues, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectDeployKeys.js b/lib/Models/ProjectDeployKeys.js index ec366b0..61a9b1f 100644 --- a/lib/Models/ProjectDeployKeys.js +++ b/lib/Models/ProjectDeployKeys.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectKeys, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectHooks.js b/lib/Models/ProjectHooks.js index c2c210c..aed125a 100644 --- a/lib/Models/ProjectHooks.js +++ b/lib/Models/ProjectHooks.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectHooks, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectIssues.js b/lib/Models/ProjectIssues.js index 35fccec..cb56cd7 100644 --- a/lib/Models/ProjectIssues.js +++ b/lib/Models/ProjectIssues.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectIssues, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectMembers.js b/lib/Models/ProjectMembers.js index 815103d..a31c4d1 100644 --- a/lib/Models/ProjectMembers.js +++ b/lib/Models/ProjectMembers.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectMembers, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectMergeRequests.js b/lib/Models/ProjectMergeRequests.js index 43f2ca4..622aa67 100644 --- a/lib/Models/ProjectMergeRequests.js +++ b/lib/Models/ProjectMergeRequests.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectMergeRequests, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectMilestones.js b/lib/Models/ProjectMilestones.js index 3e25fef..3e4400c 100644 --- a/lib/Models/ProjectMilestones.js +++ b/lib/Models/ProjectMilestones.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectMilestones, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 2440a18..567b1cf 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectRepository, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, @@ -194,13 +194,13 @@ })(this)); }; - ProjectRepository.prototype.showFile = function(projectId, params, fn) { + ProjectRepository.prototype.showFile = function(params, fn) { if (fn == null) { fn = null; } this.debug("Projects::showFile()", params); - if (params.file_path && params.ref) { - return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/files", params, (function(_this) { + if (params.projectId && params.file_path && params.ref) { + return this.get("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/files", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index 837686e..f53be11 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, Projects, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/Users.js b/lib/Models/Users.js index b11498d..f3c0553 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, Users, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Utils.js b/lib/Utils.js index 8b895fa..06dfb64 100644 --- a/lib/Utils.js +++ b/lib/Utils.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Utils; diff --git a/lib/index.js b/lib/index.js index dd2ccc8..a16e7a0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var ApiV3; diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index e6777b9..7774875 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -57,10 +57,10 @@ class ProjectRepository extends BaseModel @get "projects/#{Utils.parseProjectId projectId}/repository/tree", params, (data) => fn data if fn # == Files - showFile: (projectId, params, fn = null) => + showFile: (params, fn = null) => @debug "Projects::showFile()", params - if params.file_path and params.ref - @post "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn + if params.projectId and params.file_path and params.ref + @get "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn createFile: (params = {}, fn = null) => @debug "Projects::createFile()", params diff --git a/tests/mock.js b/tests/mock.js index 37e9aa8..0e7aabb 100644 --- a/tests/mock.js +++ b/tests/mock.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Mock, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; diff --git a/tests/test.js b/tests/test.js index 3b98b84..6382115 100644 --- a/tests/test.js +++ b/tests/test.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, assert, credentials, gitlab, mock, projectId, userId, validate_project; diff --git a/tests/validators.js b/tests/validators.js index 3b46e7a..d00b135 100644 --- a/tests/validators.js +++ b/tests/validators.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var assert; From 869a73cd05c30bab4b70fb61e85be6bdc71de61c Mon Sep 17 00:00:00 2001 From: Christian Bankester Date: Sun, 5 Oct 2014 16:45:03 -0500 Subject: [PATCH 003/135] Adds a showFile test and example file --- examples/show-file.coffee | 20 ++++++++++++++++++++ examples/show-file.js | 28 ++++++++++++++++++++++++++++ tests/test.coffee | 6 ++++++ tests/test.js | 15 ++++++++++++++- 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 examples/show-file.coffee create mode 100644 examples/show-file.js diff --git a/examples/show-file.coffee b/examples/show-file.coffee new file mode 100644 index 0000000..34b4646 --- /dev/null +++ b/examples/show-file.coffee @@ -0,0 +1,20 @@ +#!/usr/bin/env coffee + +# clear terminal +process.stdout.write '\u001B[2J\u001B[0;0f' + + +Gitlab = require('..') + +credentials = require './credentials' + +gitlab = new Gitlab + url: credentials.url + token: credentials.token + +projectId = parseInt process.argv[2] + +gitlab.projects.repository.showFile {projectId: projectId, ref: 'master', file_path: 'README.md'}, (file) -> + console.log + console.log "=== File ===" + console.log file diff --git a/examples/show-file.js b/examples/show-file.js new file mode 100644 index 0000000..b1734ce --- /dev/null +++ b/examples/show-file.js @@ -0,0 +1,28 @@ +// Generated by CoffeeScript 1.8.0 +(function() { + var Gitlab, credentials, gitlab, projectId; + + process.stdout.write('\u001B[2J\u001B[0;0f'); + + Gitlab = require('..'); + + credentials = require('./credentials'); + + gitlab = new Gitlab({ + url: credentials.url, + token: credentials.token + }); + + projectId = parseInt(process.argv[2]); + + gitlab.projects.repository.showFile({ + projectId: projectId, + ref: 'master', + file_path: 'README.md' + }, function(file) { + console.log; + console.log("=== File ==="); + return console.log(file); + }); + +}).call(this); diff --git a/tests/test.coffee b/tests/test.coffee index 7165515..6889f56 100644 --- a/tests/test.coffee +++ b/tests/test.coffee @@ -99,6 +99,12 @@ describe 'Project', -> gitlab.projects.repository.listTree projectId, (result) -> done() + describe '#showFile()', -> + it 'should retrieve specified file', (done) -> + opts = projectId: projectId, file_path: 'README.md', ref: 'master' + gitlab.projects.repository.showFile opts, (result) -> + done() + describe 'Issue', -> describe '#all()', -> diff --git a/tests/test.js b/tests/test.js index 6382115..f7e8b8e 100644 --- a/tests/test.js +++ b/tests/test.js @@ -130,13 +130,26 @@ }); }); }); - return describe('#listTree()', function() { + describe('#listTree()', function() { return it('should retrieve tree of a given project', function(done) { return gitlab.projects.repository.listTree(projectId, function(result) { return done(); }); }); }); + return describe('#showFile()', function() { + return it('should retrieve specified file', function(done) { + var opts; + opts = { + projectId: projectId, + file_path: 'README.md', + ref: 'master' + }; + return gitlab.projects.repository.showFile(opts, function(result) { + return done(); + }); + }); + }); }); }); From a0d250e93bcfd08c8dd9df22110ccc9a3e6aa63a Mon Sep 17 00:00:00 2001 From: Christian Bankester Date: Sun, 5 Oct 2014 16:54:02 -0500 Subject: [PATCH 004/135] Updates showFile example to demonstrate base64 conversion --- examples/show-file.coffee | 4 ++++ examples/show-file.js | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/show-file.coffee b/examples/show-file.coffee index 34b4646..1f1adef 100644 --- a/examples/show-file.coffee +++ b/examples/show-file.coffee @@ -18,3 +18,7 @@ gitlab.projects.repository.showFile {projectId: projectId, ref: 'master', file_p console.log console.log "=== File ===" console.log file + if file + console.log + console.log "=== Content ===" + console.log (new Buffer(file.content, 'base64')).toString() diff --git a/examples/show-file.js b/examples/show-file.js index b1734ce..ea4e8b1 100644 --- a/examples/show-file.js +++ b/examples/show-file.js @@ -22,7 +22,12 @@ }, function(file) { console.log; console.log("=== File ==="); - return console.log(file); + console.log(file); + if (file) { + console.log; + console.log("=== Content ==="); + return console.log((new Buffer(file.content, 'base64')).toString()); + } }); }).call(this); From 0bba435999d3a9e2f326edfecdab52b5d5e9bc88 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Sun, 5 Oct 2014 20:54:05 -0300 Subject: [PATCH 005/135] returns the response error message in case the result is empty --- src/ApiBaseHTTP.coffee | 2 +- src/Models/Projects.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ApiBaseHTTP.coffee b/src/ApiBaseHTTP.coffee index dcacdcf..13d881c 100644 --- a/src/ApiBaseHTTP.coffee +++ b/src/ApiBaseHTTP.coffee @@ -40,7 +40,7 @@ class module.exports.ApiBaseHTTP extends ApiBase arity = fn.length switch arity when 1 then fn ret - when 2 then fn err, ret + when 2 then fn err, ret || JSON.parse(response.body).message when 3 then fn err, response, ret get: (path, query={}, fn=null) => diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 2cb34c7..8305d12 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -24,7 +24,7 @@ class Projects extends BaseModel data = [] cb = (err, retData) => if err - return fn data if fn + return fn(retData || data) if fn else if retData.length == params.per_page @debug "Recurse Projects::all()" data = data.concat(retData) From 85cc17320be9c2198504f381d74eb5e44a46ac47 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Sun, 5 Oct 2014 23:49:52 -0300 Subject: [PATCH 006/135] uses projectId argument in case it was passed to the showFile function --- src/Models/ProjectRepository.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index 2b3d8c4..2bb82ce 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -46,7 +46,7 @@ class ProjectRepository extends BaseModel showFile: (projectId, params, fn = null) => @debug "Projects::showFile()", params if params.file_path and params.ref - @post "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn + @post "projects/#{Utils.parseProjectId(projectId || params.projectId)}/repository/files", params, (data) => fn data if fn createFile: (params = {}, fn = null) => @debug "Projects::createFile()", params From f0a02f3237b86aaf7a45cf421791636dfa1e322a Mon Sep 17 00:00:00 2001 From: nalabjp Date: Tue, 7 Oct 2014 09:56:28 +0900 Subject: [PATCH 007/135] Added Number#toString for projectId --- lib/Models/Issues.js | 2 +- src/Models/Issues.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Models/Issues.js b/lib/Models/Issues.js index c1dab62..a9cbe24 100644 --- a/lib/Models/Issues.js +++ b/lib/Models/Issues.js @@ -63,7 +63,7 @@ fn = null; } this.debug("Issues::show()"); - if (projectId.indexOf("/") !== -1) { + if (projectId.toString().indexOf("/") !== -1) { projectId = encodeURIComponent(projectId); } else { projectId = parseInt(projectId); diff --git a/src/Models/Issues.coffee b/src/Models/Issues.coffee index 4a1c783..899e51e 100644 --- a/src/Models/Issues.coffee +++ b/src/Models/Issues.coffee @@ -27,7 +27,7 @@ class Issues extends BaseModel show: (projectId, issueId, fn = null) => @debug "Issues::show()" - if projectId.indexOf("/") isnt -1 + if projectId.toString().indexOf("/") isnt -1 projectId = encodeURIComponent(projectId) else projectId = parseInt(projectId) From ed8bd0f35b16aa1eeb58449c241f889b22ac7a56 Mon Sep 17 00:00:00 2001 From: John Vaghi Date: Fri, 10 Oct 2014 14:14:24 -0400 Subject: [PATCH 008/135] add params to listCommits --- 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 837686e..ca4e4fc 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -161,7 +161,7 @@ fn = null; } this.debug("Projects::listCommits()"); - return this.get("projects/" + params.id + "/repository/commits", (function(_this) { + return this.get("projects/" + params.id + "/repository/commits", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 2cb34c7..3ed2b3d 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -59,7 +59,7 @@ class Projects extends BaseModel listCommits: (params={}, fn=null) => @debug "Projects::listCommits()" - @get "projects/#{params.id}/repository/commits", (data) => fn data if fn + @get "projects/#{params.id}/repository/commits", params, (data) => fn data if fn listTags: (params={}, fn=null) => @debug "Projects::listTags()" From 0b8a33a8458a207cffdb77f20de969a3d5d0d896 Mon Sep 17 00:00:00 2001 From: Pavel Akhmetchanov Date: Thu, 16 Oct 2014 16:20:15 +0400 Subject: [PATCH 009/135] update Models/User.js funciton all used params for request users.all; for used page=1, page=2 --- lib/Models/Users.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Models/Users.js b/lib/Models/Users.js index b11498d..a29526d 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -19,10 +19,16 @@ return Users.__super__.constructor.apply(this, arguments); } - Users.prototype.all = function(fn) { + Users.prototype.all = function(params, fn) { + if (fn == null) { - fn = null; + fn = typeof params == "function" ? params : null; + } + + if (params) { + params = typeof params == "object" ? params : {}; } + this.debug("Users::all()"); return this.get("users", (function(_this) { return function(data) { From e5c5db4ea2aac2bc5a8379b2e7f130234dbe8269 Mon Sep 17 00:00:00 2001 From: hereandnow Date: Wed, 22 Oct 2014 11:29:34 +0200 Subject: [PATCH 010/135] fix HttpMethod in ProjectRepository.showFile --- lib/Models/ProjectRepository.js | 2 +- src/Models/ProjectRepository.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 2440a18..494f925 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -200,7 +200,7 @@ } this.debug("Projects::showFile()", params); if (params.file_path && params.ref) { - return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/files", params, (function(_this) { + return this.get("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/files", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index e6777b9..3ebcb9e 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -60,7 +60,7 @@ class ProjectRepository extends BaseModel showFile: (projectId, params, fn = null) => @debug "Projects::showFile()", params if params.file_path and params.ref - @post "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn + @get "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn createFile: (params = {}, fn = null) => @debug "Projects::createFile()", params From 3956213ac3f51203e915b69097029ba7397e884b Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 4 Nov 2014 18:39:38 +0100 Subject: [PATCH 011/135] Removed broken shippable icon --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6b9cccf..8d5c7dd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ node-gitlab =========== [![Build Status (Travis)](https://travis-ci.org/moul/node-gitlab.png?branch=master)](https://travis-ci.org/moul/node-gitlab) -[![Build Status (Shippable)](https://api.shippable.com/projects/5371096b93ac868700b434d9/badge/develop)](https://www.shippable.com/projects/5371096b93ac868700b434d9) [![Dependency Status](https://david-dm.org/moul/node-gitlab.png?theme=shields.io)](https://david-dm.org/moul/node-gitlab) [![authors](https://sourcegraph.com/api/repos/github.com/moul/node-gitlab/badges/authors.png)](https://sourcegraph.com/github.com/moul/node-gitlab) [![library users](https://sourcegraph.com/api/repos/github.com/moul/node-gitlab/badges/library-users.png)](https://sourcegraph.com/github.com/moul/node-gitlab) From 926b446d6f8163813ecf60e0d175fda3ddc1f92c Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Sun, 5 Oct 2014 20:54:05 -0300 Subject: [PATCH 012/135] returns the response error message in case the result is empty --- src/ApiBaseHTTP.coffee | 2 +- src/Models/Projects.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ApiBaseHTTP.coffee b/src/ApiBaseHTTP.coffee index dcacdcf..13d881c 100644 --- a/src/ApiBaseHTTP.coffee +++ b/src/ApiBaseHTTP.coffee @@ -40,7 +40,7 @@ class module.exports.ApiBaseHTTP extends ApiBase arity = fn.length switch arity when 1 then fn ret - when 2 then fn err, ret + when 2 then fn err, ret || JSON.parse(response.body).message when 3 then fn err, response, ret get: (path, query={}, fn=null) => diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 2cb34c7..8305d12 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -24,7 +24,7 @@ class Projects extends BaseModel data = [] cb = (err, retData) => if err - return fn data if fn + return fn(retData || data) if fn else if retData.length == params.per_page @debug "Recurse Projects::all()" data = data.concat(retData) From 0ee66f4afec4f04534d22cb86da9dd757d48f258 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Sun, 5 Oct 2014 23:49:52 -0300 Subject: [PATCH 013/135] uses projectId argument in case it was passed to the showFile function --- src/Models/ProjectRepository.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index e6777b9..611e017 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -60,7 +60,7 @@ class ProjectRepository extends BaseModel showFile: (projectId, params, fn = null) => @debug "Projects::showFile()", params if params.file_path and params.ref - @post "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn + @post "projects/#{Utils.parseProjectId(projectId || params.projectId)}/repository/files", params, (data) => fn data if fn createFile: (params = {}, fn = null) => @debug "Projects::createFile()", params From 5e5be328e4e7b2f07f6ecc9bad36f4d0b2c2782e Mon Sep 17 00:00:00 2001 From: nalabjp Date: Tue, 7 Oct 2014 09:56:28 +0900 Subject: [PATCH 014/135] Added Number#toString for projectId --- lib/Models/Issues.js | 2 +- src/Models/Issues.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Models/Issues.js b/lib/Models/Issues.js index c1dab62..a9cbe24 100644 --- a/lib/Models/Issues.js +++ b/lib/Models/Issues.js @@ -63,7 +63,7 @@ fn = null; } this.debug("Issues::show()"); - if (projectId.indexOf("/") !== -1) { + if (projectId.toString().indexOf("/") !== -1) { projectId = encodeURIComponent(projectId); } else { projectId = parseInt(projectId); diff --git a/src/Models/Issues.coffee b/src/Models/Issues.coffee index 4a1c783..899e51e 100644 --- a/src/Models/Issues.coffee +++ b/src/Models/Issues.coffee @@ -27,7 +27,7 @@ class Issues extends BaseModel show: (projectId, issueId, fn = null) => @debug "Issues::show()" - if projectId.indexOf("/") isnt -1 + if projectId.toString().indexOf("/") isnt -1 projectId = encodeURIComponent(projectId) else projectId = parseInt(projectId) From 8f897d91ff3b28e00b7de81e9b8d554861fc82a8 Mon Sep 17 00:00:00 2001 From: John Vaghi Date: Fri, 10 Oct 2014 14:14:24 -0400 Subject: [PATCH 015/135] add params to listCommits --- 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 837686e..ca4e4fc 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -161,7 +161,7 @@ fn = null; } this.debug("Projects::listCommits()"); - return this.get("projects/" + params.id + "/repository/commits", (function(_this) { + return this.get("projects/" + params.id + "/repository/commits", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 8305d12..d8cf2c6 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -59,7 +59,7 @@ class Projects extends BaseModel listCommits: (params={}, fn=null) => @debug "Projects::listCommits()" - @get "projects/#{params.id}/repository/commits", (data) => fn data if fn + @get "projects/#{params.id}/repository/commits", params, (data) => fn data if fn listTags: (params={}, fn=null) => @debug "Projects::listTags()" From 9a5b5e9b35ad4082f5bb567ac91e2f883ffc8bc0 Mon Sep 17 00:00:00 2001 From: hereandnow Date: Wed, 22 Oct 2014 11:29:34 +0200 Subject: [PATCH 016/135] fix HttpMethod in ProjectRepository.showFile --- lib/Models/ProjectRepository.js | 2 +- src/Models/ProjectRepository.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 2440a18..494f925 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -200,7 +200,7 @@ } this.debug("Projects::showFile()", params); if (params.file_path && params.ref) { - return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/files", params, (function(_this) { + return this.get("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/files", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index 611e017..13cf09a 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -60,7 +60,7 @@ class ProjectRepository extends BaseModel showFile: (projectId, params, fn = null) => @debug "Projects::showFile()", params if params.file_path and params.ref - @post "projects/#{Utils.parseProjectId(projectId || params.projectId)}/repository/files", params, (data) => fn data if fn + @get "projects/#{Utils.parseProjectId(projectId || params.projectId)}/repository/files", params, (data) => fn data if fn createFile: (params = {}, fn = null) => @debug "Projects::createFile()", params From 1e19c28ccb5468187121bcc4c7b723f2507a7998 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 4 Nov 2014 20:27:05 +0100 Subject: [PATCH 017/135] Rebuilt .js files --- examples/example.credentials.js | 2 +- examples/list-projects.js | 2 +- examples/list-users.js | 2 +- examples/reset-hooks.js | 2 +- examples/show-project.js | 2 +- examples/show-user.js | 2 +- lib/ApiBase.js | 2 +- lib/ApiBaseHTTP.js | 4 ++-- lib/ApiV3.js | 2 +- lib/BaseModel.js | 2 +- lib/Models/Groups.js | 2 +- lib/Models/Issues.js | 2 +- lib/Models/ProjectDeployKeys.js | 2 +- lib/Models/ProjectHooks.js | 2 +- lib/Models/ProjectIssues.js | 2 +- lib/Models/ProjectMembers.js | 2 +- lib/Models/ProjectMergeRequests.js | 2 +- lib/Models/ProjectMilestones.js | 2 +- lib/Models/ProjectRepository.js | 4 ++-- lib/Models/Projects.js | 4 ++-- lib/Models/Users.js | 2 +- lib/Utils.js | 2 +- lib/index.js | 2 +- tests/mock.js | 2 +- tests/test.js | 2 +- tests/validators.js | 2 +- 26 files changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/example.credentials.js b/examples/example.credentials.js index f1dcef6..f3c5c56 100755 --- a/examples/example.credentials.js +++ b/examples/example.credentials.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { module.exports = { url: 'http://demo.gitlab.com', diff --git a/examples/list-projects.js b/examples/list-projects.js index c388fdf..934a7ae 100755 --- a/examples/list-projects.js +++ b/examples/list-projects.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; diff --git a/examples/list-users.js b/examples/list-users.js index 3787886..79e84ea 100644 --- a/examples/list-users.js +++ b/examples/list-users.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; diff --git a/examples/reset-hooks.js b/examples/reset-hooks.js index 91612dc..47eb0dc 100644 --- a/examples/reset-hooks.js +++ b/examples/reset-hooks.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; diff --git a/examples/show-project.js b/examples/show-project.js index 2cdf52b..e06b388 100755 --- a/examples/show-project.js +++ b/examples/show-project.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab, projectId; diff --git a/examples/show-user.js b/examples/show-user.js index d692363..12306e4 100755 --- a/examples/show-user.js +++ b/examples/show-user.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab, userId; diff --git a/lib/ApiBase.js b/lib/ApiBase.js index 631134d..65c20ec 100644 --- a/lib/ApiBase.js +++ b/lib/ApiBase.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index 52ae2c8..21d01b8 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var ApiBase, debug, querystring, slumber, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, @@ -80,7 +80,7 @@ case 1: return fn(ret); case 2: - return fn(err, ret); + return fn(err, ret || JSON.parse(response.body).message); case 3: return fn(err, response, ret); } diff --git a/lib/ApiV3.js b/lib/ApiV3.js index 61f9ee7..dd0dd8c 100644 --- a/lib/ApiV3.js +++ b/lib/ApiV3.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var ApiBaseHTTP, debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/BaseModel.js b/lib/BaseModel.js index d621e47..acc7730 100644 --- a/lib/BaseModel.js +++ b/lib/BaseModel.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index d29e3f2..4c45352 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, Groups, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/Issues.js b/lib/Models/Issues.js index a9cbe24..d249dd7 100644 --- a/lib/Models/Issues.js +++ b/lib/Models/Issues.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, Issues, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectDeployKeys.js b/lib/Models/ProjectDeployKeys.js index ec366b0..61a9b1f 100644 --- a/lib/Models/ProjectDeployKeys.js +++ b/lib/Models/ProjectDeployKeys.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectKeys, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectHooks.js b/lib/Models/ProjectHooks.js index c2c210c..aed125a 100644 --- a/lib/Models/ProjectHooks.js +++ b/lib/Models/ProjectHooks.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectHooks, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectIssues.js b/lib/Models/ProjectIssues.js index 35fccec..cb56cd7 100644 --- a/lib/Models/ProjectIssues.js +++ b/lib/Models/ProjectIssues.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectIssues, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectMembers.js b/lib/Models/ProjectMembers.js index 815103d..a31c4d1 100644 --- a/lib/Models/ProjectMembers.js +++ b/lib/Models/ProjectMembers.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectMembers, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectMergeRequests.js b/lib/Models/ProjectMergeRequests.js index 43f2ca4..622aa67 100644 --- a/lib/Models/ProjectMergeRequests.js +++ b/lib/Models/ProjectMergeRequests.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectMergeRequests, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectMilestones.js b/lib/Models/ProjectMilestones.js index 3e25fef..3e4400c 100644 --- a/lib/Models/ProjectMilestones.js +++ b/lib/Models/ProjectMilestones.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectMilestones, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 494f925..55bbd85 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, ProjectRepository, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, @@ -200,7 +200,7 @@ } this.debug("Projects::showFile()", params); if (params.file_path && params.ref) { - return this.get("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/files", params, (function(_this) { + return this.get("projects/" + (Utils.parseProjectId(projectId || params.projectId)) + "/repository/files", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index ca4e4fc..beec0ba 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, Projects, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, @@ -60,7 +60,7 @@ return function(err, retData) { if (err) { if (fn) { - return fn(data); + return fn(retData || data); } } else if (retData.length === params.per_page) { _this.debug("Recurse Projects::all()"); diff --git a/lib/Models/Users.js b/lib/Models/Users.js index b11498d..f3c0553 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var BaseModel, Users, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Utils.js b/lib/Utils.js index 8b895fa..06dfb64 100644 --- a/lib/Utils.js +++ b/lib/Utils.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Utils; diff --git a/lib/index.js b/lib/index.js index dd2ccc8..a16e7a0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var ApiV3; diff --git a/tests/mock.js b/tests/mock.js index 37e9aa8..0e7aabb 100644 --- a/tests/mock.js +++ b/tests/mock.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Mock, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; diff --git a/tests/test.js b/tests/test.js index 3b98b84..6382115 100644 --- a/tests/test.js +++ b/tests/test.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, assert, credentials, gitlab, mock, projectId, userId, validate_project; diff --git a/tests/validators.js b/tests/validators.js index 3b46e7a..d00b135 100644 --- a/tests/validators.js +++ b/tests/validators.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.7.1 +// Generated by CoffeeScript 1.8.0 (function() { var assert; From 21f07653995197b4883fa00b2bda80efb60090a3 Mon Sep 17 00:00:00 2001 From: Pavel Akhmetchanov Date: Thu, 16 Oct 2014 16:20:15 +0400 Subject: [PATCH 018/135] update Models/User.js funciton all used params for request users.all; for used page=1, page=2 --- lib/Models/Users.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Models/Users.js b/lib/Models/Users.js index f3c0553..e6b563c 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -19,10 +19,16 @@ return Users.__super__.constructor.apply(this, arguments); } - Users.prototype.all = function(fn) { + Users.prototype.all = function(params, fn) { + if (fn == null) { - fn = null; + fn = typeof params == "function" ? params : null; + } + + if (params) { + params = typeof params == "object" ? params : {}; } + this.debug("Users::all()"); return this.get("users", (function(_this) { return function(data) { From 71d5254bd1f9b2becf8cf32d7d76c753244a3bc6 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 4 Nov 2014 21:04:26 +0100 Subject: [PATCH 019/135] Coffee-ized + Fixed PR#59 --- lib/Models/Users.js | 15 ++++++++------- src/Models/Users.coffee | 7 +++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/Models/Users.js b/lib/Models/Users.js index e6b563c..968d60e 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -20,17 +20,18 @@ } Users.prototype.all = function(params, fn) { - + if (params == null) { + params = {}; + } if (fn == null) { - fn = typeof params == "function" ? params : null; + fn = null; } - - if (params) { - params = typeof params == "object" ? params : {}; + if ('function' === typeof params) { + fn = params; + params = {}; } - this.debug("Users::all()"); - return this.get("users", (function(_this) { + return this.get("users", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/Users.coffee b/src/Models/Users.coffee index 81cef07..03b05b1 100644 --- a/src/Models/Users.coffee +++ b/src/Models/Users.coffee @@ -1,9 +1,12 @@ BaseModel = require '../BaseModel' class Users extends BaseModel - all: (fn = null) => + all: (params = {}, fn = null) => + if 'function' is typeof params + fn = params + params = {} @debug "Users::all()" - @get "users", (data) => fn data if fn + @get "users", params, (data) => fn data if fn current: (fn = null) => @debug "Users::current()" From 087ba418fb0ec8fe2a6eef77fa1cb54e33676cd7 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 4 Nov 2014 22:12:43 +0100 Subject: [PATCH 020/135] Fixed showFile + added retro compatibility --- lib/Models/ProjectRepository.js | 13 +++++++++++-- src/Models/ProjectRepository.coffee | 12 ++++++++---- tests/test.coffee | 7 ++++++- tests/test.js | 12 +++++++++++- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 514d73f..0ad86c0 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -194,13 +194,22 @@ })(this)); }; - ProjectRepository.prototype.showFile = function(params, fn) { + ProjectRepository.prototype.showFile = function(projectId, params, fn) { + if (params == null) { + params = {}; + } if (fn == null) { fn = null; } + if ('function' === typeof params) { + fn = params; + params = projectId; + } else { + params.projectId = projectId; + } this.debug("Projects::showFile()", params); if (params.file_path && params.ref) { - return this.get("projects/" + (Utils.parseProjectId(projectId || params.projectId)) + "/repository/files", params, (function(_this) { + return this.get("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/files", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index fa630a2..48c1e8c 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -28,8 +28,6 @@ class ProjectRepository extends BaseModel @debug "Projects::deleteBranch()" @delete "projects/#{Utils.parseProjectId projectId}/repository/branches/#{encodeURI branchId}", (data) => fn data if fn - - # === Tags listTags: (projectId, fn = null) => @debug "Projects::listTags()" @@ -57,10 +55,16 @@ class ProjectRepository extends BaseModel @get "projects/#{Utils.parseProjectId projectId}/repository/tree", params, (data) => fn data if fn # == Files - showFile: (params, fn = null) => + showFile: (projectId, params = {}, fn = null) => + if 'function' is typeof params + fn = params + params = projectId + else + params.projectId = projectId + @debug "Projects::showFile()", params if params.file_path and params.ref - @get "projects/#{Utils.parseProjectId(projectId || params.projectId)}/repository/files", params, (data) => fn data if fn + @get "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn createFile: (params = {}, fn = null) => @debug "Projects::createFile()", params diff --git a/tests/test.coffee b/tests/test.coffee index 6889f56..f2b90ae 100644 --- a/tests/test.coffee +++ b/tests/test.coffee @@ -100,7 +100,12 @@ describe 'Project', -> done() describe '#showFile()', -> - it 'should retrieve specified file', (done) -> + it 'should retrieve specified file with arity=3', (done) -> + opts = file_path: 'README.md', ref: 'master' + gitlab.projects.repository.showFile projectId, opts, (result) -> + done() + + it 'should retrieve specified file with arity=2', (done) -> opts = projectId: projectId, file_path: 'README.md', ref: 'master' gitlab.projects.repository.showFile opts, (result) -> done() diff --git a/tests/test.js b/tests/test.js index f7e8b8e..e4e1178 100644 --- a/tests/test.js +++ b/tests/test.js @@ -138,7 +138,17 @@ }); }); return describe('#showFile()', function() { - return it('should retrieve specified file', function(done) { + it('should retrieve specified file with arity=3', function(done) { + var opts; + opts = { + file_path: 'README.md', + ref: 'master' + }; + return gitlab.projects.repository.showFile(projectId, opts, function(result) { + return done(); + }); + }); + return it('should retrieve specified file with arity=2', function(done) { var opts; opts = { projectId: projectId, From e1b328f55b08d0c90d751b20604f306fa59846b3 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 4 Nov 2014 22:23:21 +0100 Subject: [PATCH 021/135] added bad-token --- examples/bad-token.coffee | 19 +++++++++++++++++++ examples/bad-token.js | 27 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 examples/bad-token.coffee create mode 100644 examples/bad-token.js diff --git a/examples/bad-token.coffee b/examples/bad-token.coffee new file mode 100644 index 0000000..1052d56 --- /dev/null +++ b/examples/bad-token.coffee @@ -0,0 +1,19 @@ +#!/usr/bin/env coffee + +# clear terminal +process.stdout.write '\u001B[2J\u001B[0;0f' + + +Gitlab = require('..') + +credentials = + url: 'http://demo.gitlab.com' + token: 'bad-token' + +gitlab = new Gitlab + url: credentials.url + token: credentials.token + +gitlab.projects.all (err, resp, result) -> + console.log "having: ", err: err, resp: resp, result: result + console.log "should get: { err: '401 Unauthorized', resp: undefined, result: undefined }" diff --git a/examples/bad-token.js b/examples/bad-token.js new file mode 100644 index 0000000..1a9287f --- /dev/null +++ b/examples/bad-token.js @@ -0,0 +1,27 @@ +// Generated by CoffeeScript 1.8.0 +(function() { + var Gitlab, credentials, gitlab; + + process.stdout.write('\u001B[2J\u001B[0;0f'); + + Gitlab = require('..'); + + credentials = { + url: 'http://demo.gitlab.com', + token: 'bad-token' + }; + + gitlab = new Gitlab({ + url: credentials.url, + token: credentials.token + }); + + gitlab.projects.all(function(err, resp, result) { + return console.log({ + err: err, + resp: resp, + result: result + }); + }); + +}).call(this); From f0e11cd479fa70fab36f8137b1f854a20c9c3199 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 4 Nov 2014 22:42:15 +0100 Subject: [PATCH 022/135] rebuild example --- examples/bad-token.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/bad-token.js b/examples/bad-token.js index 1a9287f..1105c9c 100644 --- a/examples/bad-token.js +++ b/examples/bad-token.js @@ -17,11 +17,12 @@ }); gitlab.projects.all(function(err, resp, result) { - return console.log({ + console.log("having: ", { err: err, resp: resp, result: result }); + return console.log("should get: { err: '401 Unauthorized', resp: undefined, result: undefined }"); }); }).call(this); From 6d3a2562ea4eb981dcfe81eb43e691413b62ebb9 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 4 Nov 2014 22:42:31 +0100 Subject: [PATCH 023/135] v1.1.0 --- README.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d5c7dd..53abb8c 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,14 @@ MIT Changelog ========= +1.1.0 (2014-11-04) +------------------ + +- Added project branch support +- Improved compatibility with API +- Improved global error handling +- Rebuilt javascript using latest Coffee-Script + 1.0.0 (2014-08-19) ------------------ diff --git a/package.json b/package.json index 9d411ce..859eee7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.0.0", + "version": "1.1.0", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From e8416866623b72dfa62aab52668f10b8924b2a5c Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 5 Nov 2014 09:09:25 +0100 Subject: [PATCH 024/135] Added Makefile --- Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5c7f01a --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +build: + cake build + +watch: + cake watch + +doc: + cake doc + +test: + npm test From 162d7827a305f99cea094c15d8eb50de8af58c57 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 5 Nov 2014 09:44:39 +0100 Subject: [PATCH 025/135] Fixed 'make doc' --- .gitignore | 2 ++ Cakefile | 7 ------- Makefile | 7 +++++-- package.json | 3 ++- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 61495c9..ef1ae4c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ npm-debug.log .idea *.iml + +/docs \ No newline at end of file diff --git a/Cakefile b/Cakefile index 2d5d61f..e9a74e5 100644 --- a/Cakefile +++ b/Cakefile @@ -27,10 +27,3 @@ task 'watch', 'continually build the JavaScript code', -> task 'build', 'build the JavaScript code', -> build -> console.log "Done !" - -task 'doc', 'rebuild the Docco documentation', -> - exec([ - 'docco src/*.coffee' - ].join(' && '), (err) -> - throw err if err - ) diff --git a/Makefile b/Makefile index 5c7f01a..653b8f5 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,10 @@ watch: cake watch doc: - cake doc + ./node_modules/docco/bin/docco $(shell find src -name "*.coffee") -test: +test: build npm test + +release: test + npm publish diff --git a/package.json b/package.json index 859eee7..940dfcb 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ }, "devDependencies": { "coffee-script": "*", - "mocha": "" + "mocha": "", + "docco": "" }, "keywords": [ "gitlab", From 8ab535c12f1ac75c590aabc176edfb56f73994c0 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 5 Nov 2014 09:53:41 +0100 Subject: [PATCH 026/135] Added make tag --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 653b8f5..16743cb 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +PACKAGE_VERSION = $(shell node -e 'console.log(require("./package.json").version);') + build: cake build @@ -7,6 +9,12 @@ watch: doc: ./node_modules/docco/bin/docco $(shell find src -name "*.coffee") +tag: + git commit -am "v$(PACKAGE_VERSION)" + git tag v$(PACKAGE_VERSION) + git push + git push --tags + test: build npm test From 83453a6084e2c1f451972027da2cc1f14b58cb68 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 5 Nov 2014 10:10:18 +0100 Subject: [PATCH 027/135] Added make develop --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 16743cb..e7ef105 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ PACKAGE_VERSION = $(shell node -e 'console.log(require("./package.json").version);') +develop: + npm install + npm install -g coffee-script + build: cake build From cafd330f997d6455db66bf0bad7d460b25d6f38d Mon Sep 17 00:00:00 2001 From: Vinicius Senna Date: Wed, 5 Nov 2014 10:23:29 -0200 Subject: [PATCH 028/135] Removing unnecessary code and adding retro-compatibility. --- examples/reset-hooks.coffee | 4 ---- examples/reset-hooks.js | 7 +------ lib/Models/ProjectHooks.js | 5 +++++ src/Models/ProjectHooks.coffee | 5 ++++- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/reset-hooks.coffee b/examples/reset-hooks.coffee index 1186ac2..b679cfd 100644 --- a/examples/reset-hooks.coffee +++ b/examples/reset-hooks.coffee @@ -27,9 +27,5 @@ gitlab.projects.all (projects) -> console.log ret console.log "#{url} is already OK" else - params = - url:url - issues_events: true - merge_requests_events: true gitlab.projects.hooks.add project.id, url, -> console.log "#{url} has been added" diff --git a/examples/reset-hooks.js b/examples/reset-hooks.js index 643e0ab..47eb0dc 100644 --- a/examples/reset-hooks.js +++ b/examples/reset-hooks.js @@ -22,7 +22,7 @@ var project; project = _project; return gitlab.projects.hooks.list(project.id, function(hooks) { - var hook, params, url, _j, _len1; + var hook, url, _j, _len1; url = "" + credentials.service_hook_base + project.path_with_namespace; if (hooks.length > 1) { return console.log("" + url + " too much hooks"); @@ -37,11 +37,6 @@ } return console.log("" + url + " is already OK"); } else { - params = { - url: url, - issues_events: true, - merge_requests_events: true - }; return gitlab.projects.hooks.add(project.id, url, function() { return console.log("" + url + " has been added"); }); diff --git a/lib/Models/ProjectHooks.js b/lib/Models/ProjectHooks.js index e2f7560..61f2c6c 100644 --- a/lib/Models/ProjectHooks.js +++ b/lib/Models/ProjectHooks.js @@ -53,6 +53,11 @@ if (fn == null) { fn = null; } + if ('string' === typeof params) { + params = { + url: params + }; + } this.debug("Projects::addHook()"); return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/hooks", params, (function(_this) { return function(data) { diff --git a/src/Models/ProjectHooks.coffee b/src/Models/ProjectHooks.coffee index 4725f37..c005581 100644 --- a/src/Models/ProjectHooks.coffee +++ b/src/Models/ProjectHooks.coffee @@ -11,6 +11,9 @@ class ProjectHooks extends BaseModel @get "projects/#{Utils.parseProjectId projectId}/hooks/#{parseInt hookId}", (data) => fn data if fn add: (projectId, params, fn = null) => + if 'string' is typeof params + params = + url: params @debug "Projects::addHook()" @post "projects/#{Utils.parseProjectId projectId}/hooks", params, (data) => fn data if fn @@ -24,4 +27,4 @@ class ProjectHooks extends BaseModel @debug "Projects::removeHook()" @delete "projects/#{Utils.parseProjectId projectId}/hooks/#{parseInt hookId}", (data) => fn data if fn -module.exports = (client) -> new ProjectHooks client \ No newline at end of file +module.exports = (client) -> new ProjectHooks client From 4ba6093453517ba109ec1f9638329535acf6570d Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 5 Nov 2014 14:20:22 +0100 Subject: [PATCH 029/135] Removed docco from dependencies (broke tests on node 0.8) --- Makefile | 1 + package.json | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e7ef105..71452a3 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ watch: cake watch doc: + npm install docco ./node_modules/docco/bin/docco $(shell find src -name "*.coffee") tag: diff --git a/package.json b/package.json index 940dfcb..859eee7 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,7 @@ }, "devDependencies": { "coffee-script": "*", - "mocha": "", - "docco": "" + "mocha": "" }, "keywords": [ "gitlab", From 06817468a387f6aa3e6738ab9f7458141a1ba228 Mon Sep 17 00:00:00 2001 From: Vinicius Senna Date: Sun, 14 Sep 2014 20:41:41 -0300 Subject: [PATCH 030/135] Pass all parameters to add hook API. --- examples/reset-hooks.coffee | 4 ++++ examples/reset-hooks.js | 7 ++++++- lib/Models/ProjectHooks.js | 6 +----- src/Models/ProjectHooks.coffee | 4 +--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/reset-hooks.coffee b/examples/reset-hooks.coffee index b679cfd..1186ac2 100644 --- a/examples/reset-hooks.coffee +++ b/examples/reset-hooks.coffee @@ -27,5 +27,9 @@ gitlab.projects.all (projects) -> console.log ret console.log "#{url} is already OK" else + params = + url:url + issues_events: true + merge_requests_events: true gitlab.projects.hooks.add project.id, url, -> console.log "#{url} has been added" diff --git a/examples/reset-hooks.js b/examples/reset-hooks.js index 47eb0dc..643e0ab 100644 --- a/examples/reset-hooks.js +++ b/examples/reset-hooks.js @@ -22,7 +22,7 @@ var project; project = _project; return gitlab.projects.hooks.list(project.id, function(hooks) { - var hook, url, _j, _len1; + var hook, params, url, _j, _len1; url = "" + credentials.service_hook_base + project.path_with_namespace; if (hooks.length > 1) { return console.log("" + url + " too much hooks"); @@ -37,6 +37,11 @@ } return console.log("" + url + " is already OK"); } else { + params = { + url: url, + issues_events: true, + merge_requests_events: true + }; return gitlab.projects.hooks.add(project.id, url, function() { return console.log("" + url + " has been added"); }); diff --git a/lib/Models/ProjectHooks.js b/lib/Models/ProjectHooks.js index aed125a..e2f7560 100644 --- a/lib/Models/ProjectHooks.js +++ b/lib/Models/ProjectHooks.js @@ -49,15 +49,11 @@ })(this)); }; - ProjectHooks.prototype.add = function(projectId, url, fn) { - var params; + ProjectHooks.prototype.add = function(projectId, params, fn) { if (fn == null) { fn = null; } this.debug("Projects::addHook()"); - params = { - url: url - }; return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/hooks", params, (function(_this) { return function(data) { if (fn) { diff --git a/src/Models/ProjectHooks.coffee b/src/Models/ProjectHooks.coffee index ab13603..4725f37 100644 --- a/src/Models/ProjectHooks.coffee +++ b/src/Models/ProjectHooks.coffee @@ -10,10 +10,8 @@ class ProjectHooks extends BaseModel @debug "Projects::hook()" @get "projects/#{Utils.parseProjectId projectId}/hooks/#{parseInt hookId}", (data) => fn data if fn - add: (projectId, url, fn = null) => + add: (projectId, params, fn = null) => @debug "Projects::addHook()" - params = - url: url @post "projects/#{Utils.parseProjectId projectId}/hooks", params, (data) => fn data if fn update: (projectId, hookId, url, fn = null) => From 96d2ed443991939df88d69f575f4a56fc058b355 Mon Sep 17 00:00:00 2001 From: Vinicius Senna Date: Wed, 5 Nov 2014 10:23:29 -0200 Subject: [PATCH 031/135] Removing unnecessary code and adding retro-compatibility. --- examples/reset-hooks.coffee | 4 ---- examples/reset-hooks.js | 7 +------ lib/Models/ProjectHooks.js | 5 +++++ src/Models/ProjectHooks.coffee | 5 ++++- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/reset-hooks.coffee b/examples/reset-hooks.coffee index 1186ac2..b679cfd 100644 --- a/examples/reset-hooks.coffee +++ b/examples/reset-hooks.coffee @@ -27,9 +27,5 @@ gitlab.projects.all (projects) -> console.log ret console.log "#{url} is already OK" else - params = - url:url - issues_events: true - merge_requests_events: true gitlab.projects.hooks.add project.id, url, -> console.log "#{url} has been added" diff --git a/examples/reset-hooks.js b/examples/reset-hooks.js index 643e0ab..47eb0dc 100644 --- a/examples/reset-hooks.js +++ b/examples/reset-hooks.js @@ -22,7 +22,7 @@ var project; project = _project; return gitlab.projects.hooks.list(project.id, function(hooks) { - var hook, params, url, _j, _len1; + var hook, url, _j, _len1; url = "" + credentials.service_hook_base + project.path_with_namespace; if (hooks.length > 1) { return console.log("" + url + " too much hooks"); @@ -37,11 +37,6 @@ } return console.log("" + url + " is already OK"); } else { - params = { - url: url, - issues_events: true, - merge_requests_events: true - }; return gitlab.projects.hooks.add(project.id, url, function() { return console.log("" + url + " has been added"); }); diff --git a/lib/Models/ProjectHooks.js b/lib/Models/ProjectHooks.js index e2f7560..61f2c6c 100644 --- a/lib/Models/ProjectHooks.js +++ b/lib/Models/ProjectHooks.js @@ -53,6 +53,11 @@ if (fn == null) { fn = null; } + if ('string' === typeof params) { + params = { + url: params + }; + } this.debug("Projects::addHook()"); return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/hooks", params, (function(_this) { return function(data) { diff --git a/src/Models/ProjectHooks.coffee b/src/Models/ProjectHooks.coffee index 4725f37..c005581 100644 --- a/src/Models/ProjectHooks.coffee +++ b/src/Models/ProjectHooks.coffee @@ -11,6 +11,9 @@ class ProjectHooks extends BaseModel @get "projects/#{Utils.parseProjectId projectId}/hooks/#{parseInt hookId}", (data) => fn data if fn add: (projectId, params, fn = null) => + if 'string' is typeof params + params = + url: params @debug "Projects::addHook()" @post "projects/#{Utils.parseProjectId projectId}/hooks", params, (data) => fn data if fn @@ -24,4 +27,4 @@ class ProjectHooks extends BaseModel @debug "Projects::removeHook()" @delete "projects/#{Utils.parseProjectId projectId}/hooks/#{parseInt hookId}", (data) => fn data if fn -module.exports = (client) -> new ProjectHooks client \ No newline at end of file +module.exports = (client) -> new ProjectHooks client From 5a64707c3be9890bd2c1d33278bc6e476fa609c6 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 5 Nov 2014 14:34:26 +0100 Subject: [PATCH 032/135] esthetics --- src/Models/ProjectHooks.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Models/ProjectHooks.coffee b/src/Models/ProjectHooks.coffee index c005581..36f3e74 100644 --- a/src/Models/ProjectHooks.coffee +++ b/src/Models/ProjectHooks.coffee @@ -12,8 +12,8 @@ class ProjectHooks extends BaseModel add: (projectId, params, fn = null) => if 'string' is typeof params - params = - url: params + params = + url: params @debug "Projects::addHook()" @post "projects/#{Utils.parseProjectId projectId}/hooks", params, (data) => fn data if fn From 739d8394fbc451c93a22ef19a25eb48e63b9d957 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 17 Nov 2014 11:52:47 +0100 Subject: [PATCH 033/135] Switched from github.com/moul/node-gitlab to github.com/node-gitlab/node-gitlab --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 53abb8c..371d4bc 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ node-gitlab =========== -[![Build Status (Travis)](https://travis-ci.org/moul/node-gitlab.png?branch=master)](https://travis-ci.org/moul/node-gitlab) -[![Dependency Status](https://david-dm.org/moul/node-gitlab.png?theme=shields.io)](https://david-dm.org/moul/node-gitlab) -[![authors](https://sourcegraph.com/api/repos/github.com/moul/node-gitlab/badges/authors.png)](https://sourcegraph.com/github.com/moul/node-gitlab) -[![library users](https://sourcegraph.com/api/repos/github.com/moul/node-gitlab/badges/library-users.png)](https://sourcegraph.com/github.com/moul/node-gitlab) -[![Total views](https://sourcegraph.com/api/repos/github.com/moul/node-gitlab/counters/views.png)](https://sourcegraph.com/github.com/moul/node-gitlab) -[![Views in the last 24 hours](https://sourcegraph.com/api/repos/github.com/moul/node-gitlab/counters/views-24h.png)](https://sourcegraph.com/github.com/moul/node-gitlab) -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/moul/node-gitlab/trend.png)](https://bitdeli.com/free "Bitdeli Badge") +[![Build Status (Travis)](https://travis-ci.org/node-gitlab/node-gitlab.png?branch=master)](https://travis-ci.org/node-gitlab/node-gitlab) +[![Dependency Status](https://david-dm.org/node-gitlab/node-gitlab.png?theme=shields.io)](https://david-dm.org/node-gitlab/node-gitlab) +[![authors](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/badges/authors.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) +[![library users](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/badges/library-users.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) +[![Total views](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/counters/views.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) +[![Views in the last 24 hours](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/counters/views-24h.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/node-gitlab/node-gitlab/trend.png)](https://bitdeli.com/free "Bitdeli Badge") [![NPM Badge](https://nodei.co/npm/gitlab.png?downloads=true&stars=true)](https://npmjs.org/package/gitlab) -- [GitLab](https://github.com/gitlabhq/gitlabhq) API Nodejs library. -It wraps the HTTP api library described [here](https://github.com/moul/gitlabhq/tree/master/doc/api). +It wraps the HTTP api library described [here](https://github.com/node-gitlab/gitlabhq/tree/master/doc/api). Maintained by [Manfred Touron](https://github.com/moul) and [Dave Irvine](https://github.com/dave-irvine) @@ -71,12 +71,12 @@ gitlab.projects.all(function(projects) { }); ``` -See [Examples directory](https://github.com/moul/node-gitlab/tree/master/examples) for more examples +See [Examples directory](https://github.com/node-gitlab/node-gitlab/tree/master/examples) for more examples Develop ======= -[![Gitter chat](https://badges.gitter.im/moul/node-gitlab.png)](https://gitter.im/moul/node-gitlab) +[![Gitter chat](https://badges.gitter.im/node-gitlab/node-gitlab.png)](https://gitter.im/node-gitlab/node-gitlab) Edit the Coffee-Script files in `src`, then build them using `cake build`. Use `cake watch` to build files continuously while developing. From 9220aaae557dec1ec1c87e8fa775c22ea73c7caa Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 17 Nov 2014 11:55:20 +0100 Subject: [PATCH 034/135] Switched from github.com/moul/node-gitlab to github.com/node-gitlab/node-gitlab --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 859eee7..0786c64 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/moul/node-gitlab" + "url": "https://github.com/node-gitlab/node-gitlab" }, "dependencies": { "debug": "*", From 79eecdb39d4a90e57a6de74449b9e1a11902ac86 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 24 Dec 2014 07:20:02 +0100 Subject: [PATCH 035/135] 1.2.0 --- README.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 371d4bc..1855c54 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,15 @@ MIT Changelog ========= +1.2.0 (2014-12-24) +------------------ + +- Switched to new organization, some urls changed +- Improve development tools +- Cleaned code +- Changed AddHook parameters +- Happy Christmas + 1.1.0 (2014-11-04) ------------------ diff --git a/package.json b/package.json index 0786c64..b103d7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.1.0", + "version": "1.2.0", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 5020504fa098589c8fd2686d0a92722f1f994dbe Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Wed, 24 Dec 2014 11:54:03 +0000 Subject: [PATCH 036/135] Check for an authorisation failure and throw it, rather than silently erroring. Depends on https://github.com/moul/node-slumber/pull/2 landing. --- lib/ApiBaseHTTP.js | 5 ++++- package.json | 2 +- src/ApiBaseHTTP.coffee | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index 21d01b8..09f4a9d 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -71,9 +71,12 @@ ApiBaseHTTP.prototype.fn_wrapper = function(fn) { return (function(_this) { return function(err, response, ret) { - var arity; + var arity, _ref; if (err) { debug('an error has occured', err); + if ((400 <= (_ref = err.statusCode) && _ref <= 499)) { + throw "Authorisation error. " + err.statusCode + ". Check your key."; + } } arity = fn.length; switch (arity) { diff --git a/package.json b/package.json index b103d7a..95430e3 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "debug": "*", - "slumber": "0.4.1" + "slumber": ">=0.5.0" }, "devDependencies": { "coffee-script": "*", diff --git a/src/ApiBaseHTTP.coffee b/src/ApiBaseHTTP.coffee index 13d881c..9f9a843 100644 --- a/src/ApiBaseHTTP.coffee +++ b/src/ApiBaseHTTP.coffee @@ -37,6 +37,8 @@ class module.exports.ApiBaseHTTP extends ApiBase return (err, response, ret) => if err debug 'an error has occured', err + if 400 <= err.statusCode <= 499 + throw "Authorisation error. #{err.statusCode}. Check your key." arity = fn.length switch arity when 1 then fn ret From d14bd2dbd5e777807778d5381bc2202ca9cb9f6a Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Wed, 24 Dec 2014 13:14:16 +0000 Subject: [PATCH 037/135] Added addMember() to Groups, and an access_levels property to Groups. --- lib/Models/Groups.js | 45 ++++++++++++++++++++++++++++++++++++++++ src/Models/Groups.coffee | 26 +++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index 4c45352..94e0b28 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -11,13 +11,25 @@ __extends(Groups, _super); function Groups() { + this.addMember = __bind(this.addMember, this); this.listMembers = __bind(this.listMembers, this); this.listProjects = __bind(this.listProjects, this); this.show = __bind(this.show, this); this.all = __bind(this.all, this); + this.init = __bind(this.init, this); return Groups.__super__.constructor.apply(this, arguments); } + Groups.prototype.init = function() { + return this.access_levels = { + GUEST: 10, + REPORTER: 20, + DEVELOPER: 30, + MASTER: 40, + OWNER: 50 + }; + }; + Groups.prototype.all = function(params, fn) { if (params == null) { params = {}; @@ -84,6 +96,39 @@ })(this)); }; + Groups.prototype.addMember = function(groupId, userId, accessLevel, fn) { + var checkAccessLevel, params; + if (fn == null) { + fn = null; + } + this.debug("addMember(" + groupId + ", " + userId + ", " + accessLevel + ")"); + checkAccessLevel = (function(_this) { + return function() { + var access_level, k, _ref; + _ref = _this.access_levels; + for (k in _ref) { + access_level = _ref[k]; + if (accessLevel === access_level) { + return true; + } + } + return false; + }; + })(this); + if (!checkAccessLevel()) { + throw "`accessLevel` must be one of " + (JSON.stringify(this.access_levels)); + } + params = { + user_id: userId, + access_level: accessLevel + }; + return this.post("groups/" + (parseInt(groupId)) + "/members", params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + return Groups; })(BaseModel); diff --git a/src/Models/Groups.coffee b/src/Models/Groups.coffee index 683a5cb..85d4893 100644 --- a/src/Models/Groups.coffee +++ b/src/Models/Groups.coffee @@ -1,6 +1,14 @@ BaseModel = require '../BaseModel' class Groups extends BaseModel + init: => + @access_levels = + GUEST: 10 + REPORTER: 20 + DEVELOPER: 30 + MASTER: 40 + OWNER: 50 + all: (params = {}, fn = null) => if 'function' is typeof params fn = params @@ -21,4 +29,22 @@ class Groups extends BaseModel @debug "Groups::listMembers()" @get "groups/#{parseInt groupId}/members", (data) => fn data if fn + addMember: (groupId, userId, accessLevel, fn=null) => + @debug "addMember(#{groupId}, #{userId}, #{accessLevel})" + + checkAccessLevel = => + for k, access_level of @access_levels + return true if accessLevel == access_level + false + + unless do checkAccessLevel + throw "`accessLevel` must be one of #{JSON.stringify @access_levels}" + + params = + user_id: userId + access_level: accessLevel + + @post "groups/#{parseInt groupId}/members", params, (data) -> fn data if fn + + module.exports = (client) -> new Groups client From 698d5d7970fae9f9b1e4522acd029f3662b965aa Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Thu, 25 Dec 2014 10:20:26 +0000 Subject: [PATCH 038/135] Dropped an unnecessary do and bind clause. --- lib/Models/Projects.js | 44 ++++++++++++++++++-------------------- src/Models/Projects.coffee | 28 +++++++++++------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index beec0ba..f778c13 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -36,6 +36,7 @@ }; Projects.prototype.all = function(params, fn) { + var cb, data; if (params == null) { params = {}; } @@ -53,30 +54,27 @@ if (params.per_page == null) { params.per_page = 100; } - return (function() { - var cb, data; - data = []; - cb = (function(_this) { - return function(err, retData) { - if (err) { - if (fn) { - return fn(retData || data); - } - } else if (retData.length === params.per_page) { - _this.debug("Recurse Projects::all()"); - data = data.concat(retData); - params.page++; - return _this.get("projects", params, cb); - } else { - data = data.concat(retData); - if (fn) { - return fn(data); - } + data = []; + cb = (function(_this) { + return function(err, retData) { + if (err) { + if (fn) { + return fn(retData || data); } - }; - })(this); - return this.get("projects", params, cb); - }).bind(this)(); + } else if (retData.length === params.per_page) { + _this.debug("Recurse Projects::all()"); + data = data.concat(retData); + params.page++; + return _this.get("projects", params, cb); + } else { + data = data.concat(retData); + if (fn) { + return fn(data); + } + } + }; + })(this); + return this.get("projects", params, cb); }; Projects.prototype.show = function(projectId, fn) { diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index d8cf2c6..b95cbeb 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -20,22 +20,20 @@ class Projects extends BaseModel params.page ?= 1 params.per_page ?= 100 - do (-> - data = [] - cb = (err, retData) => - if err - return fn(retData || data) if fn - else if retData.length == params.per_page - @debug "Recurse Projects::all()" - data = data.concat(retData) - params.page++ - return @get "projects", params, cb - else - data = data.concat(retData) - return fn data if fn + data = [] + cb = (err, retData) => + if err + return fn(retData || data) if fn + else if retData.length == params.per_page + @debug "Recurse Projects::all()" + data = data.concat(retData) + params.page++ + return @get "projects", params, cb + else + data = data.concat(retData) + return fn data if fn - @get "projects", params, cb - ).bind(@) + @get "projects", params, cb show: (projectId, fn=null) => @debug "Projects::show()" From 2187678f5bd8aa09dd702a14528be62e24037d31 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Thu, 25 Dec 2014 12:07:27 +0000 Subject: [PATCH 039/135] Add recursion for all() in Users and Groups --- lib/Models/Groups.js | 24 ++++++++++++++++++++++++ lib/Models/Users.js | 27 +++++++++++++++++++++++++++ src/Models/Groups.coffee | 16 ++++++++++++++++ src/Models/Users.coffee | 17 +++++++++++++++++ 4 files changed, 84 insertions(+) diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index 94e0b28..89f40ff 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -31,6 +31,7 @@ }; Groups.prototype.all = function(params, fn) { + var cb, data; if (params == null) { params = {}; } @@ -42,9 +43,32 @@ params = {}; } this.debug("Groups::all()"); + if (params.page == null) { + params.page = 1; + } if (params.per_page == null) { params.per_page = 100; } + data = []; + cb = (function(_this) { + return function(err, retData) { + if (err) { + if (fn) { + return fn(retData || data); + } + } else if (retData.length === params.per_page) { + _this.debug("Recurse Groups::all()"); + data = data.concat(retData); + params.page++; + return _this.get("groups", params, cb); + } else { + data = data.concat(retData); + if (fn) { + return fn(data); + } + } + }; + })(this); return this.get("groups", params, (function(_this) { return function(data) { if (fn) { diff --git a/lib/Models/Users.js b/lib/Models/Users.js index 968d60e..ca3a932 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -20,6 +20,7 @@ } Users.prototype.all = function(params, fn) { + var cb, data; if (params == null) { params = {}; } @@ -31,6 +32,32 @@ params = {}; } this.debug("Users::all()"); + if (params.page == null) { + params.page = 1; + } + if (params.per_page == null) { + params.per_page = 100; + } + data = []; + cb = (function(_this) { + return function(err, retData) { + if (err) { + if (fn) { + return fn(retData || data); + } + } else if (retData.length === params.per_page) { + _this.debug("Recurse Users::all()"); + data = data.concat(retData); + params.page++; + return _this.get("users", params, cb); + } else { + data = data.concat(retData); + if (fn) { + return fn(data); + } + } + }; + })(this); return this.get("users", params, (function(_this) { return function(data) { if (fn) { diff --git a/src/Models/Groups.coffee b/src/Models/Groups.coffee index 85d4893..6da1eba 100644 --- a/src/Models/Groups.coffee +++ b/src/Models/Groups.coffee @@ -14,7 +14,23 @@ class Groups extends BaseModel fn = params params = {} @debug "Groups::all()" + + params.page ?= 1 params.per_page ?= 100 + + data = [] + cb = (err, retData) => + if err + return fn(retData || data) if fn + else if retData.length == params.per_page + @debug "Recurse Groups::all()" + data = data.concat(retData) + params.page++ + return @get "groups", params, cb + else + data = data.concat(retData) + return fn data if fn + @get "groups", params, (data) => fn data if fn show: (groupId, fn = null) => diff --git a/src/Models/Users.coffee b/src/Models/Users.coffee index 03b05b1..2e61b74 100644 --- a/src/Models/Users.coffee +++ b/src/Models/Users.coffee @@ -6,6 +6,23 @@ class Users extends BaseModel fn = params params = {} @debug "Users::all()" + + params.page ?= 1 + params.per_page ?= 100 + + data = [] + cb = (err, retData) => + if err + return fn(retData || data) if fn + else if retData.length == params.per_page + @debug "Recurse Users::all()" + data = data.concat(retData) + params.page++ + return @get "users", params, cb + else + data = data.concat(retData) + return fn data if fn + @get "users", params, (data) => fn data if fn current: (fn = null) => From 0f635872a1db841c6c960f5a539829eecb447729 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Sat, 27 Dec 2014 14:56:27 +0000 Subject: [PATCH 040/135] Tests! Happy new year. --- package.json | 6 +- tests/ProjectMembers.test.coffee | 80 +++++++++++++++++++++ tests/ProjectMembers.test.js | 86 ++++++++++++++++++++++ tests/ProjectRepository.test.coffee | 69 ++++++++++++++++++ tests/ProjectRepository.test.js | 79 ++++++++++++++++++++ tests/Projects.test.coffee | 89 +++++++++++++++++++++++ tests/Projects.test.js | 108 ++++++++++++++++++++++++++++ tests/Utils.test.coffee | 21 ++++++ tests/Utils.test.js | 33 +++++++++ 9 files changed, 570 insertions(+), 1 deletion(-) create mode 100644 tests/ProjectMembers.test.coffee create mode 100644 tests/ProjectMembers.test.js create mode 100644 tests/ProjectRepository.test.coffee create mode 100644 tests/ProjectRepository.test.js create mode 100644 tests/Projects.test.coffee create mode 100644 tests/Projects.test.js create mode 100644 tests/Utils.test.coffee create mode 100644 tests/Utils.test.js diff --git a/package.json b/package.json index 95430e3..917b1d0 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,11 @@ }, "devDependencies": { "coffee-script": "*", - "mocha": "" + "mocha": "", + "proxyquire": "~1.0.1", + "chai": "~1.9.2", + "sinon": "~1.10.3", + "sinon-chai": "~2.6.0" }, "keywords": [ "gitlab", diff --git a/tests/ProjectMembers.test.coffee b/tests/ProjectMembers.test.coffee new file mode 100644 index 0000000..2b057e1 --- /dev/null +++ b/tests/ProjectMembers.test.coffee @@ -0,0 +1,80 @@ +chai = require 'chai' +expect = chai.expect +sinon = require 'sinon' +sinonChai = require 'sinon-chai' + +chai.use sinonChai + +describe "ProjectMembers", -> + gitlab = null + projects = null + members = null + + before -> + gitlab = (require '../') + url: 'test' + token: 'test' + + projects = gitlab.projects + members = projects.members + + beforeEach -> + + describe "list()", -> + it "should use GET verb", -> + getStub = sinon.stub members, "get" + + members.list 1 + + getStub.restore() + expect(getStub).to.have.been.called + + it "should pass Numeric projectIDs to Utils.parseProjectId", -> + getStub = sinon.stub members, "get" + + members.list 1 + + getStub.restore() + expect(getStub).to.have.been.calledWith "projects/1/members" + + it "should pass Namespaced projectIDs to Utils.parseProjectId", -> + getStub = sinon.stub members, "get" + + members.list "abc/def" + + getStub.restore() + expect(getStub).to.have.been.calledWith "projects/abc%2Fdef/members" + + describe "show()", -> + it "should use GET verb", -> + getStub = sinon.stub members, "get" + + members.show 1, 2 + + getStub.restore() + expect(getStub).to.have.been.called + + it "should pass Numeric projectIDs to Utils.parseProjectId", -> + getStub = sinon.stub members, "get" + + members.show 1, 2 + + getStub.restore() + expect(getStub).to.have.been.calledWith "projects/1/members/2" + + it "should pass Namespaced projectIDs to Utils.parseProjectId", -> + getStub = sinon.stub members, "get" + + members.show "abc/def", 2 + + getStub.restore() + expect(getStub).to.have.been.calledWith "projects/abc%2Fdef/members/2" + + describe "add()", -> + it "should use POST verb", -> + postStub = sinon.stub members, "post" + + members.add 1, 1, 30 + + postStub.restore() + expect(postStub).to.have.been.called diff --git a/tests/ProjectMembers.test.js b/tests/ProjectMembers.test.js new file mode 100644 index 0000000..cf43d3a --- /dev/null +++ b/tests/ProjectMembers.test.js @@ -0,0 +1,86 @@ +// Generated by CoffeeScript 1.8.0 +(function() { + var chai, expect, sinon, sinonChai; + + chai = require('chai'); + + expect = chai.expect; + + sinon = require('sinon'); + + sinonChai = require('sinon-chai'); + + chai.use(sinonChai); + + describe("ProjectMembers", function() { + var gitlab, members, projects; + gitlab = null; + projects = null; + members = null; + before(function() { + gitlab = (require('../'))({ + url: 'test', + token: 'test' + }); + projects = gitlab.projects; + return members = projects.members; + }); + beforeEach(function() {}); + describe("list()", function() { + it("should use GET verb", function() { + var getStub; + getStub = sinon.stub(members, "get"); + members.list(1); + getStub.restore(); + return expect(getStub).to.have.been.called; + }); + it("should pass Numeric projectIDs to Utils.parseProjectId", function() { + var getStub; + getStub = sinon.stub(members, "get"); + members.list(1); + getStub.restore(); + return expect(getStub).to.have.been.calledWith("projects/1/members"); + }); + return it("should pass Namespaced projectIDs to Utils.parseProjectId", function() { + var getStub; + getStub = sinon.stub(members, "get"); + members.list("abc/def"); + getStub.restore(); + return expect(getStub).to.have.been.calledWith("projects/abc%2Fdef/members"); + }); + }); + describe("show()", function() { + it("should use GET verb", function() { + var getStub; + getStub = sinon.stub(members, "get"); + members.show(1, 2); + getStub.restore(); + return expect(getStub).to.have.been.called; + }); + it("should pass Numeric projectIDs to Utils.parseProjectId", function() { + var getStub; + getStub = sinon.stub(members, "get"); + members.show(1, 2); + getStub.restore(); + return expect(getStub).to.have.been.calledWith("projects/1/members/2"); + }); + return it("should pass Namespaced projectIDs to Utils.parseProjectId", function() { + var getStub; + getStub = sinon.stub(members, "get"); + members.show("abc/def", 2); + getStub.restore(); + return expect(getStub).to.have.been.calledWith("projects/abc%2Fdef/members/2"); + }); + }); + return describe("add()", function() { + return it("should use POST verb", function() { + var postStub; + postStub = sinon.stub(members, "post"); + members.add(1, 1, 30); + postStub.restore(); + return expect(postStub).to.have.been.called; + }); + }); + }); + +}).call(this); diff --git a/tests/ProjectRepository.test.coffee b/tests/ProjectRepository.test.coffee new file mode 100644 index 0000000..49dfd9f --- /dev/null +++ b/tests/ProjectRepository.test.coffee @@ -0,0 +1,69 @@ +chai = require 'chai' +expect = chai.expect +sinon = require 'sinon' +sinonChai = require 'sinon-chai' + +chai.use sinonChai + +describe "ProjectRepository", -> + gitlab = null + projects = null + repository = null + + before -> + gitlab = (require '../') + url: 'test' + token: 'test' + + projects = gitlab.projects + repository = projects.repository + + beforeEach -> + + describe "listBranches()", -> + it "should use GET verb", -> + getStub = sinon.stub repository, "get" + + repository.listBranches 1 + + getStub.restore() + expect(getStub).to.have.been.called + + describe "listCommits()", -> + it "should use GET verb", -> + getStub = sinon.stub repository, "get" + + repository.listCommits 1 + + getStub.restore() + expect(getStub).to.have.been.called + + describe "listTags()", -> + it "should use GET verb", -> + getStub = sinon.stub repository, "get" + + repository.listTags 1 + + getStub.restore() + expect(getStub).to.have.been.called + + describe "listTree()", -> + it "should use GET verb", -> + getStub = sinon.stub repository, "get" + + repository.listTree 1 + + getStub.restore() + expect(getStub).to.have.been.called + + describe "showFile()", -> + it "should use GET verb", -> + getStub = sinon.stub repository, "get" + + repository.showFile 1, { + file_path: "test", + ref: "test" + } + + getStub.restore() + expect(getStub).to.have.been.called \ No newline at end of file diff --git a/tests/ProjectRepository.test.js b/tests/ProjectRepository.test.js new file mode 100644 index 0000000..0b6a4c5 --- /dev/null +++ b/tests/ProjectRepository.test.js @@ -0,0 +1,79 @@ +// Generated by CoffeeScript 1.8.0 +(function() { + var chai, expect, sinon, sinonChai; + + chai = require('chai'); + + expect = chai.expect; + + sinon = require('sinon'); + + sinonChai = require('sinon-chai'); + + chai.use(sinonChai); + + describe("ProjectRepository", function() { + var gitlab, projects, repository; + gitlab = null; + projects = null; + repository = null; + before(function() { + gitlab = (require('../'))({ + url: 'test', + token: 'test' + }); + projects = gitlab.projects; + return repository = projects.repository; + }); + beforeEach(function() {}); + describe("listBranches()", function() { + return it("should use GET verb", function() { + var getStub; + getStub = sinon.stub(repository, "get"); + repository.listBranches(1); + getStub.restore(); + return expect(getStub).to.have.been.called; + }); + }); + describe("listCommits()", function() { + return it("should use GET verb", function() { + var getStub; + getStub = sinon.stub(repository, "get"); + repository.listCommits(1); + getStub.restore(); + return expect(getStub).to.have.been.called; + }); + }); + describe("listTags()", function() { + return it("should use GET verb", function() { + var getStub; + getStub = sinon.stub(repository, "get"); + repository.listTags(1); + getStub.restore(); + return expect(getStub).to.have.been.called; + }); + }); + describe("listTree()", function() { + return it("should use GET verb", function() { + var getStub; + getStub = sinon.stub(repository, "get"); + repository.listTree(1); + getStub.restore(); + return expect(getStub).to.have.been.called; + }); + }); + return describe("showFile()", function() { + return it("should use GET verb", function() { + var getStub; + getStub = sinon.stub(repository, "get"); + repository.showFile(1, { + file_path: "test", + ref: "test" + }); + getStub.restore(); + return expect(getStub).to.have.been.called; + }); + }); + }); + +}).call(this); diff --git a/tests/Projects.test.coffee b/tests/Projects.test.coffee new file mode 100644 index 0000000..8e716dc --- /dev/null +++ b/tests/Projects.test.coffee @@ -0,0 +1,89 @@ +chai = require 'chai' +expect = chai.expect +sinon = require 'sinon' +sinonChai = require 'sinon-chai' + +chai.use sinonChai + +describe "Projects", -> + gitlab = null + projects = null + + before -> + gitlab = (require '../') + url: 'test' + token: 'test' + + projects = gitlab.projects + + beforeEach -> + + describe "show()", -> + it "should use GET verb", -> + getStub = sinon.stub projects, "get" + + projects.show 1 + + getStub.restore() + expect(getStub).to.have.been.called + + it "should pass Numeric projectIDs to Utils.parseProjectId", -> + getStub = sinon.stub projects, "get" + + projects.show 1 + + getStub.restore() + expect(getStub).to.have.been.calledWith "projects/1" + + it "should pass Namespaced projectIDs to Utils.parseProjectId", -> + getStub = sinon.stub projects, "get" + + projects.show "abc/def" + + getStub.restore() + expect(getStub).to.have.been.calledWith "projects/abc%2Fdef" + + describe "all()", -> + arrayOf101 = [] + arrayOf100 = [] + arrayOf99 = [] + arrayOf1 = [] + + before -> + for i in [0..102] + if i < 1 + arrayOf1.push {} + if i < 99 + arrayOf99.push {} + if i < 100 + arrayOf100.push {} + if i < 101 + arrayOf101.push {} + + it "should use GET verb", -> + getStub = sinon.stub projects, "get" + + projects.all() + + getStub.restore() + expect(getStub).to.have.been.called + + it "should recurse if more than 100 records are returned", -> + getStub = sinon.stub projects, "get", (a,b,c)-> + if getStub.callCount < 3 + c null, arrayOf100 + else + c null, arrayOf99 + + projects.all() + + expect(getStub).to.have.been.calledThrice + + describe "create()", -> + it "should use POST verb", -> + postStub = sinon.stub projects, "post" + + projects.create {} + + postStub.restore() + expect(postStub).to.have.been.called diff --git a/tests/Projects.test.js b/tests/Projects.test.js new file mode 100644 index 0000000..4c56ccc --- /dev/null +++ b/tests/Projects.test.js @@ -0,0 +1,108 @@ +// Generated by CoffeeScript 1.8.0 +(function() { + var chai, expect, sinon, sinonChai; + + chai = require('chai'); + + expect = chai.expect; + + sinon = require('sinon'); + + sinonChai = require('sinon-chai'); + + chai.use(sinonChai); + + describe("Projects", function() { + var gitlab, projects; + gitlab = null; + projects = null; + before(function() { + gitlab = (require('../'))({ + url: 'test', + token: 'test' + }); + return projects = gitlab.projects; + }); + beforeEach(function() {}); + describe("show()", function() { + it("should use GET verb", function() { + var getStub; + getStub = sinon.stub(projects, "get"); + projects.show(1); + getStub.restore(); + return expect(getStub).to.have.been.called; + }); + it("should pass Numeric projectIDs to Utils.parseProjectId", function() { + var getStub; + getStub = sinon.stub(projects, "get"); + projects.show(1); + getStub.restore(); + return expect(getStub).to.have.been.calledWith("projects/1"); + }); + return it("should pass Namespaced projectIDs to Utils.parseProjectId", function() { + var getStub; + getStub = sinon.stub(projects, "get"); + projects.show("abc/def"); + getStub.restore(); + return expect(getStub).to.have.been.calledWith("projects/abc%2Fdef"); + }); + }); + describe("all()", function() { + var arrayOf1, arrayOf100, arrayOf101, arrayOf99; + arrayOf101 = []; + arrayOf100 = []; + arrayOf99 = []; + arrayOf1 = []; + before(function() { + var i, _i, _results; + _results = []; + for (i = _i = 0; _i <= 102; i = ++_i) { + if (i < 1) { + arrayOf1.push({}); + } + if (i < 99) { + arrayOf99.push({}); + } + if (i < 100) { + arrayOf100.push({}); + } + if (i < 101) { + _results.push(arrayOf101.push({})); + } else { + _results.push(void 0); + } + } + return _results; + }); + it("should use GET verb", function() { + var getStub; + getStub = sinon.stub(projects, "get"); + projects.all(); + getStub.restore(); + return expect(getStub).to.have.been.called; + }); + return it("should recurse if more than 100 records are returned", function() { + var getStub; + getStub = sinon.stub(projects, "get", function(a, b, c) { + if (getStub.callCount < 3) { + return c(null, arrayOf100); + } else { + return c(null, arrayOf99); + } + }); + projects.all(); + return expect(getStub).to.have.been.calledThrice; + }); + }); + return describe("create()", function() { + return it("should use POST verb", function() { + var postStub; + postStub = sinon.stub(projects, "post"); + projects.create({}); + postStub.restore(); + return expect(postStub).to.have.been.called; + }); + }); + }); + +}).call(this); diff --git a/tests/Utils.test.coffee b/tests/Utils.test.coffee new file mode 100644 index 0000000..7e18b84 --- /dev/null +++ b/tests/Utils.test.coffee @@ -0,0 +1,21 @@ +chai = require 'chai' +expect = chai.expect +proxyquire = require 'proxyquire' +Utils = require '../lib/Utils.js' + +describe "Utils", -> + describe "parseProjectId", -> + it "should return a Number if passed a Number", -> + expect(Utils.parseProjectId 0).to.be.a 'number' + + it "should URI encode strings containing '/'", -> + expect(Utils.parseProjectId "/abc").to.equal '%2Fabc' + expect(Utils.parseProjectId "a/bc").to.equal 'a%2Fbc' + expect(Utils.parseProjectId "ab/c").to.equal 'ab%2Fc' + expect(Utils.parseProjectId "abc/").to.equal 'abc%2F' + + it "should return NaN for unparseable strings without '/'", -> + expect(isNaN Utils.parseProjectId "abc").to.be.true + + it "should return a Number for parseable strings without '/'", -> + expect(Utils.parseProjectId "1").to.equal 1 diff --git a/tests/Utils.test.js b/tests/Utils.test.js new file mode 100644 index 0000000..0260d32 --- /dev/null +++ b/tests/Utils.test.js @@ -0,0 +1,33 @@ +// Generated by CoffeeScript 1.8.0 +(function() { + var Utils, chai, expect, proxyquire; + + chai = require('chai'); + + expect = chai.expect; + + proxyquire = require('proxyquire'); + + Utils = require('../lib/Utils.js'); + + describe("Utils", function() { + return describe("parseProjectId", function() { + it("should return a Number if passed a Number", function() { + return expect(Utils.parseProjectId(0)).to.be.a('number'); + }); + it("should URI encode strings containing '/'", function() { + expect(Utils.parseProjectId("/abc")).to.equal('%2Fabc'); + expect(Utils.parseProjectId("a/bc")).to.equal('a%2Fbc'); + expect(Utils.parseProjectId("ab/c")).to.equal('ab%2Fc'); + return expect(Utils.parseProjectId("abc/")).to.equal('abc%2F'); + }); + it("should return NaN for unparseable strings without '/'", function() { + return expect(isNaN(Utils.parseProjectId("abc"))).to.be["true"]; + }); + return it("should return a Number for parseable strings without '/'", function() { + return expect(Utils.parseProjectId("1")).to.equal(1); + }); + }); + }); + +}).call(this); From bcba14f50c224c11dc393dda643813f867545e8f Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Sat, 27 Dec 2014 15:58:17 +0000 Subject: [PATCH 041/135] Strip /api/v3 from provided url. Includes tests. :D Resolves #64 --- lib/ApiBaseHTTP.js | 1 + src/ApiBaseHTTP.coffee | 2 ++ tests/ApiBaseHTTP.test.coffee | 25 +++++++++++++++++++++++ tests/ApiBaseHTTP.test.js | 37 +++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 tests/ApiBaseHTTP.test.coffee create mode 100644 tests/ApiBaseHTTP.test.js diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index 09f4a9d..c2655df 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -47,6 +47,7 @@ if ((_base2 = this.options.slumber).append_slash == null) { _base2.append_slash = false; } + this.options.url = this.options.url.replace(/\/api\/v3/, ''); if (this.options.auth != null) { this.options.slumber.auth = this.options.auth; } diff --git a/src/ApiBaseHTTP.coffee b/src/ApiBaseHTTP.coffee index 9f9a843..ae418a2 100644 --- a/src/ApiBaseHTTP.coffee +++ b/src/ApiBaseHTTP.coffee @@ -18,6 +18,8 @@ class module.exports.ApiBaseHTTP extends ApiBase @options.slumber ?= {} @options.slumber.append_slash ?= false + @options.url = @options.url.replace(/\/api\/v3/, '') + if @options.auth? @options.slumber.auth = @options.auth diff --git a/tests/ApiBaseHTTP.test.coffee b/tests/ApiBaseHTTP.test.coffee new file mode 100644 index 0000000..bd218d7 --- /dev/null +++ b/tests/ApiBaseHTTP.test.coffee @@ -0,0 +1,25 @@ +chai = require 'chai' +expect = chai.expect +sinon = require 'sinon' +proxyquire = require 'proxyquire' +sinonChai = require 'sinon-chai' + +chai.use sinonChai + +describe "ApiBaseHTTP", -> + ApiBaseHTTP = null + apibasehttp = null + + before -> + ApiBaseHTTP = require('../lib/ApiBaseHTTP').ApiBaseHTTP + + beforeEach -> + + describe "handleOptions()", -> + it "should interpret `url` parameter properly", -> + apibasehttp = new ApiBaseHTTP + base_url: "api/v3" + url: "http://gitlab.mydomain.com/api/v3", + token: "test" + + expect(apibasehttp.options.url).to.equal("http://gitlab.mydomain.com") diff --git a/tests/ApiBaseHTTP.test.js b/tests/ApiBaseHTTP.test.js new file mode 100644 index 0000000..2bdaf9c --- /dev/null +++ b/tests/ApiBaseHTTP.test.js @@ -0,0 +1,37 @@ +// Generated by CoffeeScript 1.8.0 +(function() { + var chai, expect, proxyquire, sinon, sinonChai; + + chai = require('chai'); + + expect = chai.expect; + + sinon = require('sinon'); + + proxyquire = require('proxyquire'); + + sinonChai = require('sinon-chai'); + + chai.use(sinonChai); + + describe("ApiBaseHTTP", function() { + var ApiBaseHTTP, apibasehttp; + ApiBaseHTTP = null; + apibasehttp = null; + before(function() { + return ApiBaseHTTP = require('../lib/ApiBaseHTTP').ApiBaseHTTP; + }); + beforeEach(function() {}); + return describe("handleOptions()", function() { + return it("should interpret `url` parameter properly", function() { + apibasehttp = new ApiBaseHTTP({ + base_url: "api/v3", + url: "http://gitlab.mydomain.com/api/v3", + token: "test" + }); + return expect(apibasehttp.options.url).to.equal("http://gitlab.mydomain.com"); + }); + }); + }); + +}).call(this); From 00d998ba1113867d13dc586b08c72e93d35338d8 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Sat, 27 Dec 2014 16:06:10 +0000 Subject: [PATCH 042/135] Additional tests for stripping /api/v3, and a README update. --- README.md | 2 ++ tests/ApiBaseHTTP.test.coffee | 12 ++++++++++-- tests/ApiBaseHTTP.test.js | 10 +++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1855c54..4030b3c 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ npm install gitlab Usage ===== +URL to your GitLab instance should not include `/api/v3` path. + Coffee-Script ------------- ```coffee diff --git a/tests/ApiBaseHTTP.test.coffee b/tests/ApiBaseHTTP.test.coffee index bd218d7..8c9ac76 100644 --- a/tests/ApiBaseHTTP.test.coffee +++ b/tests/ApiBaseHTTP.test.coffee @@ -16,10 +16,18 @@ describe "ApiBaseHTTP", -> beforeEach -> describe "handleOptions()", -> - it "should interpret `url` parameter properly", -> + it "should strip /api/v3 from `url` parameter if provided", -> apibasehttp = new ApiBaseHTTP base_url: "api/v3" - url: "http://gitlab.mydomain.com/api/v3", + url: "http://gitlab.mydomain.com/api/v3" + token: "test" + + expect(apibasehttp.options.url).to.equal("http://gitlab.mydomain.com") + + it "should not strip /api/v3 from `url` parameter if not provided", -> + apibasehttp = new ApiBaseHTTP + base_url: "api/v3" + url: "http://gitlab.mydomain.com" token: "test" expect(apibasehttp.options.url).to.equal("http://gitlab.mydomain.com") diff --git a/tests/ApiBaseHTTP.test.js b/tests/ApiBaseHTTP.test.js index 2bdaf9c..2e965e2 100644 --- a/tests/ApiBaseHTTP.test.js +++ b/tests/ApiBaseHTTP.test.js @@ -23,7 +23,7 @@ }); beforeEach(function() {}); return describe("handleOptions()", function() { - return it("should interpret `url` parameter properly", function() { + it("should strip /api/v3 from `url` parameter if provided", function() { apibasehttp = new ApiBaseHTTP({ base_url: "api/v3", url: "http://gitlab.mydomain.com/api/v3", @@ -31,6 +31,14 @@ }); return expect(apibasehttp.options.url).to.equal("http://gitlab.mydomain.com"); }); + return it("should not strip /api/v3 from `url` parameter if not provided", function() { + apibasehttp = new ApiBaseHTTP({ + base_url: "api/v3", + url: "http://gitlab.mydomain.com", + token: "test" + }); + return expect(apibasehttp.options.url).to.equal("http://gitlab.mydomain.com"); + }); }); }); From c494ad127fea97815825980be733ce7dfa004efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Jim=C3=A9nez?= Date: Wed, 4 Feb 2015 22:13:27 +0100 Subject: [PATCH 043/135] Added ability to list and create labels. --- lib/ApiBase.js | 9 ++-- lib/ApiBaseHTTP.js | 6 +-- lib/ApiV3.js | 6 +-- lib/BaseModel.js | 6 +-- lib/Models/Groups.js | 6 +-- lib/Models/Issues.js | 6 +-- lib/Models/Labels.js | 46 +++++++++++++++++++ lib/Models/ProjectDeployKeys.js | 6 +-- lib/Models/ProjectHooks.js | 6 +-- lib/Models/ProjectIssues.js | 6 +-- lib/Models/ProjectLabels.js | 73 ++++++++++++++++++++++++++++++ lib/Models/ProjectMembers.js | 6 +-- lib/Models/ProjectMergeRequests.js | 6 +-- lib/Models/ProjectMilestones.js | 6 +-- lib/Models/ProjectRepository.js | 6 +-- lib/Models/Projects.js | 7 +-- lib/Models/Users.js | 6 +-- lib/Utils.js | 2 +- lib/index.js | 2 +- src/ApiBase.coffee | 1 + src/Models/Labels.coffee | 14 ++++++ src/Models/ProjectLabels.coffee | 31 +++++++++++++ src/Models/Projects.coffee | 1 + 23 files changed, 216 insertions(+), 48 deletions(-) create mode 100644 lib/Models/Labels.js create mode 100644 lib/Models/ProjectLabels.js create mode 100644 src/Models/Labels.coffee create mode 100644 src/Models/ProjectLabels.coffee diff --git a/lib/ApiBase.js b/lib/ApiBase.js index 65c20ec..ef44a41 100644 --- a/lib/ApiBase.js +++ b/lib/ApiBase.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; @@ -6,8 +6,8 @@ debug = require('debug')('gitlab:ApiBase'); module.exports.ApiBase = (function() { - function ApiBase(options) { - this.options = options; + function ApiBase(_at_options) { + this.options = _at_options; this.init = __bind(this.init, this); this.handleOptions = __bind(this.handleOptions, this); this.handleOptions(); @@ -29,7 +29,8 @@ this.groups = require('./Models/Groups')(this.client); this.projects = require('./Models/Projects')(this.client); this.issues = require('./Models/Issues')(this.client); - return this.users = require('./Models/Users')(this.client); + this.users = require('./Models/Users')(this.client); + return this.labels = require('./Models/Labels')(this.client); }; return ApiBase; diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index c2655df..f8eae1f 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var ApiBase, debug, querystring, slumber, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; debug = require('debug')('gitlab:ApiBaseHTTP'); diff --git a/lib/ApiV3.js b/lib/ApiV3.js index dd0dd8c..7358ca3 100644 --- a/lib/ApiV3.js +++ b/lib/ApiV3.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var ApiBaseHTTP, debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; debug = require('debug')('gitlab:ApiV3'); diff --git a/lib/BaseModel.js b/lib/BaseModel.js index acc7730..7711e95 100644 --- a/lib/BaseModel.js +++ b/lib/BaseModel.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; @@ -6,8 +6,8 @@ debug = require('debug')('gitlab:BaseModel'); module.exports = (function() { - function exports(client) { - this.client = client; + function exports(_at_client) { + this.client = _at_client; this._init = __bind(this._init, this); this.load = __bind(this.load, this); this._init(); diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index 89f40ff..ef86279 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Groups, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Models/Issues.js b/lib/Models/Issues.js index d249dd7..a50ce61 100644 --- a/lib/Models/Issues.js +++ b/lib/Models/Issues.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Issues, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Models/Labels.js b/lib/Models/Labels.js new file mode 100644 index 0000000..e5ddd63 --- /dev/null +++ b/lib/Models/Labels.js @@ -0,0 +1,46 @@ +// Generated by CoffeeScript 1.9.0 +(function() { + var BaseModel, Labels, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; + + BaseModel = require('../BaseModel'); + + Labels = (function(_super) { + __extends(Labels, _super); + + function Labels() { + this.create = __bind(this.create, this); + return Labels.__super__.constructor.apply(this, arguments); + } + + Labels.prototype.create = function(projectId, params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Labels::create()"); + if (projectId.toString().indexOf("/") !== -1) { + projectId = encodeURIComponent(projectId); + } else { + projectId = parseInt(projectId); + } + return this.post("projects/" + projectId + "/labels", params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + + return Labels; + + })(BaseModel); + + module.exports = function(client) { + return new Labels(client); + }; + +}).call(this); diff --git a/lib/Models/ProjectDeployKeys.js b/lib/Models/ProjectDeployKeys.js index 61a9b1f..04eaa2f 100644 --- a/lib/Models/ProjectDeployKeys.js +++ b/lib/Models/ProjectDeployKeys.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectKeys, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Models/ProjectHooks.js b/lib/Models/ProjectHooks.js index 61f2c6c..86eca2c 100644 --- a/lib/Models/ProjectHooks.js +++ b/lib/Models/ProjectHooks.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectHooks, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Models/ProjectIssues.js b/lib/Models/ProjectIssues.js index cb56cd7..925f584 100644 --- a/lib/Models/ProjectIssues.js +++ b/lib/Models/ProjectIssues.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectIssues, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Models/ProjectLabels.js b/lib/Models/ProjectLabels.js new file mode 100644 index 0000000..d433538 --- /dev/null +++ b/lib/Models/ProjectLabels.js @@ -0,0 +1,73 @@ +// Generated by CoffeeScript 1.9.0 +(function() { + var BaseModel, ProjectLabels, Utils, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; + + BaseModel = require('../BaseModel'); + + Utils = require('../Utils'); + + ProjectLabels = (function(_super) { + __extends(ProjectLabels, _super); + + function ProjectLabels() { + this.list = __bind(this.list, this); + return ProjectLabels.__super__.constructor.apply(this, arguments); + } + + ProjectLabels.prototype.list = function(projectId, params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("ProjectLabels::labels()"); + if ('function' === typeof params) { + fn = params; + params = {}; + } + if (params.page == null) { + params.page = 1; + } + if (params.per_page == null) { + params.per_page = 100; + } + return (function() { + var cb, data; + data = []; + cb = (function(_this) { + return function(err, retData) { + if (err) { + if (fn) { + return fn(data); + } + } + if (retData.length === params.per_page) { + _this.debug("Recurse ProjectLabels::list()"); + data = data.concat(retData); + params.page++; + return _this.get("projects/" + (Utils.parseProjectId(projectId)) + "/labels", params, cb); + } else { + data = data.concat(retData); + if (fn) { + return fn(data); + } + } + }; + })(this); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/labels", params, cb); + }).bind(this)(); + }; + + return ProjectLabels; + + })(BaseModel); + + module.exports = function(client) { + return new ProjectLabels(client); + }; + +}).call(this); diff --git a/lib/Models/ProjectMembers.js b/lib/Models/ProjectMembers.js index a31c4d1..1b61739 100644 --- a/lib/Models/ProjectMembers.js +++ b/lib/Models/ProjectMembers.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectMembers, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Models/ProjectMergeRequests.js b/lib/Models/ProjectMergeRequests.js index 622aa67..9a98552 100644 --- a/lib/Models/ProjectMergeRequests.js +++ b/lib/Models/ProjectMergeRequests.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectMergeRequests, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Models/ProjectMilestones.js b/lib/Models/ProjectMilestones.js index 3e4400c..dc7cb65 100644 --- a/lib/Models/ProjectMilestones.js +++ b/lib/Models/ProjectMilestones.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectMilestones, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 0ad86c0..ab08fa6 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectRepository, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index f778c13..5197820 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Projects, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); @@ -29,6 +29,7 @@ this.members = this.load('ProjectMembers'); this.hooks = this.load('ProjectHooks'); this.issues = this.load('ProjectIssues'); + this.labels = this.load('ProjectLabels'); this.repository = this.load('ProjectRepository'); this.milestones = this.load('ProjectMilestones'); this.deploy_keys = this.load('ProjectDeployKeys'); diff --git a/lib/Models/Users.js b/lib/Models/Users.js index ca3a932..ad234a4 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Users, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); diff --git a/lib/Utils.js b/lib/Utils.js index 06dfb64..3a6236d 100644 --- a/lib/Utils.js +++ b/lib/Utils.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var Utils; diff --git a/lib/index.js b/lib/index.js index a16e7a0..eb5678e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { var ApiV3; diff --git a/src/ApiBase.coffee b/src/ApiBase.coffee index 78bc959..0cdee80 100644 --- a/src/ApiBase.coffee +++ b/src/ApiBase.coffee @@ -19,3 +19,4 @@ class module.exports.ApiBase #@repositories = require('./Models/Repositories') @client @users = require('./Models/Users') @client #@mergeRequests = require('./Models/MergeRequests') @client + @labels = require('./Models/Labels') @client diff --git a/src/Models/Labels.coffee b/src/Models/Labels.coffee new file mode 100644 index 0000000..e2c6f89 --- /dev/null +++ b/src/Models/Labels.coffee @@ -0,0 +1,14 @@ +BaseModel = require '../BaseModel' + +class Labels extends BaseModel + + create: (projectId, params = {}, fn = null) => + @debug "Labels::create()" + if projectId.toString().indexOf("/") isnt -1 + projectId = encodeURIComponent(projectId) + else + projectId = parseInt(projectId) + + @post "projects/#{projectId}/labels", params, (data) -> fn data if fn + +module.exports = (client) -> new Labels client diff --git a/src/Models/ProjectLabels.coffee b/src/Models/ProjectLabels.coffee new file mode 100644 index 0000000..31126ff --- /dev/null +++ b/src/Models/ProjectLabels.coffee @@ -0,0 +1,31 @@ +BaseModel = require '../BaseModel' +Utils = require '../Utils' + +class ProjectLabels extends BaseModel + list: (projectId, params = {}, fn = null) => + @debug "ProjectLabels::labels()" + + if 'function' is typeof params + fn = params + params = {} + params.page ?= 1 + params.per_page ?= 100 + + do (-> + data = [] + cb = (err, retData) => + if err + return fn data if fn + if retData.length == params.per_page + @debug "Recurse ProjectLabels::list()" + data = data.concat(retData) + params.page++ + return @get "projects/#{Utils.parseProjectId projectId}/labels", params, cb + else + data = data.concat(retData) + return fn data if fn + + @get "projects/#{Utils.parseProjectId projectId}/labels", params, cb + ).bind(@) + +module.exports = (client) -> new ProjectLabels client diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index b95cbeb..a43a05d 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -6,6 +6,7 @@ class Projects extends BaseModel @members = @load 'ProjectMembers' @hooks = @load 'ProjectHooks' @issues = @load 'ProjectIssues' + @labels = @load 'ProjectLabels' @repository = @load 'ProjectRepository' @milestones = @load 'ProjectMilestones' @deploy_keys = @load 'ProjectDeployKeys' From bab7c3c13a981de7689ae460fb72f32e38ef2681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Jim=C3=A9nez?= Date: Thu, 5 Feb 2015 19:41:22 +0100 Subject: [PATCH 044/135] Refactoring some code --- README.md | 1 + lib/Models/Labels.js | 11 +++----- lib/Models/ProjectLabels.js | 47 +++++++++++++++------------------ src/Models/Labels.coffee | 8 ++---- src/Models/ProjectLabels.coffee | 30 ++++++++++----------- 5 files changed, 43 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 4030b3c..a53ab82 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ Contributors - [nalabjp](https://github.com/nalabjp) - [shaoshuai0102](https://github.com/shaoshuai0102) - [Sakesan Panjamawat](https://github.com/sakp) +- [Jose Jiménez](https://github.com/jjimenezlopez) License ------- diff --git a/lib/Models/Labels.js b/lib/Models/Labels.js index e5ddd63..e7d9165 100644 --- a/lib/Models/Labels.js +++ b/lib/Models/Labels.js @@ -1,12 +1,14 @@ // Generated by CoffeeScript 1.9.0 (function() { - var BaseModel, Labels, + var BaseModel, Labels, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, __hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); + Utils = require('../Utils'); + Labels = (function(_super) { __extends(Labels, _super); @@ -23,12 +25,7 @@ fn = null; } this.debug("Labels::create()"); - if (projectId.toString().indexOf("/") !== -1) { - projectId = encodeURIComponent(projectId); - } else { - projectId = parseInt(projectId); - } - return this.post("projects/" + projectId + "/labels", params, function(data) { + return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/labels", params, function(data) { if (fn) { return fn(data); } diff --git a/lib/Models/ProjectLabels.js b/lib/Models/ProjectLabels.js index d433538..f3fdd3c 100644 --- a/lib/Models/ProjectLabels.js +++ b/lib/Models/ProjectLabels.js @@ -13,11 +13,12 @@ __extends(ProjectLabels, _super); function ProjectLabels() { - this.list = __bind(this.list, this); + this.all = __bind(this.all, this); return ProjectLabels.__super__.constructor.apply(this, arguments); } - ProjectLabels.prototype.list = function(projectId, params, fn) { + ProjectLabels.prototype.all = function(projectId, params, fn) { + var cb, data; if (params == null) { params = {}; } @@ -35,31 +36,27 @@ if (params.per_page == null) { params.per_page = 100; } - return (function() { - var cb, data; - data = []; - cb = (function(_this) { - return function(err, retData) { - if (err) { - if (fn) { - return fn(data); - } + data = []; + cb = (function(_this) { + return function(err, retData) { + if (err) { + if (fn) { + return fn(data); } - if (retData.length === params.per_page) { - _this.debug("Recurse ProjectLabels::list()"); - data = data.concat(retData); - params.page++; - return _this.get("projects/" + (Utils.parseProjectId(projectId)) + "/labels", params, cb); - } else { - data = data.concat(retData); - if (fn) { - return fn(data); - } + } else if (retData.length === params.per_page) { + _this.debug("Recurse ProjectLabels::all()"); + data = data.concat(retData); + params.page++; + return _this.get("projects/" + (Utils.parseProjectId(projectId)) + "/labels", params, cb); + } else { + data = data.concat(retData); + if (fn) { + return fn(data); } - }; - })(this); - return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/labels", params, cb); - }).bind(this)(); + } + }; + })(this); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/labels", params, cb); }; return ProjectLabels; diff --git a/src/Models/Labels.coffee b/src/Models/Labels.coffee index e2c6f89..8f2f5a3 100644 --- a/src/Models/Labels.coffee +++ b/src/Models/Labels.coffee @@ -1,14 +1,10 @@ BaseModel = require '../BaseModel' +Utils = require '../Utils' class Labels extends BaseModel create: (projectId, params = {}, fn = null) => @debug "Labels::create()" - if projectId.toString().indexOf("/") isnt -1 - projectId = encodeURIComponent(projectId) - else - projectId = parseInt(projectId) - - @post "projects/#{projectId}/labels", params, (data) -> fn data if fn + @post "projects/#{Utils.parseProjectId projectId}/labels", params, (data) -> fn data if fn module.exports = (client) -> new Labels client diff --git a/src/Models/ProjectLabels.coffee b/src/Models/ProjectLabels.coffee index 31126ff..d8b1450 100644 --- a/src/Models/ProjectLabels.coffee +++ b/src/Models/ProjectLabels.coffee @@ -2,7 +2,7 @@ BaseModel = require '../BaseModel' Utils = require '../Utils' class ProjectLabels extends BaseModel - list: (projectId, params = {}, fn = null) => + all: (projectId, params = {}, fn = null) => @debug "ProjectLabels::labels()" if 'function' is typeof params @@ -11,21 +11,19 @@ class ProjectLabels extends BaseModel params.page ?= 1 params.per_page ?= 100 - do (-> - data = [] - cb = (err, retData) => - if err - return fn data if fn - if retData.length == params.per_page - @debug "Recurse ProjectLabels::list()" - data = data.concat(retData) - params.page++ - return @get "projects/#{Utils.parseProjectId projectId}/labels", params, cb - else - data = data.concat(retData) - return fn data if fn + data = [] + cb = (err, retData) => + if err + return fn data if fn + else if retData.length == params.per_page + @debug "Recurse ProjectLabels::all()" + data = data.concat(retData) + params.page++ + return @get "projects/#{Utils.parseProjectId projectId}/labels", params, cb + else + data = data.concat(retData) + return fn data if fn - @get "projects/#{Utils.parseProjectId projectId}/labels", params, cb - ).bind(@) + @get "projects/#{Utils.parseProjectId projectId}/labels", params, cb module.exports = (client) -> new ProjectLabels client From 29709078fb2cde7beb6e61250bd08e9854509743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Jim=C3=A9nez?= Date: Sat, 7 Feb 2015 14:01:37 +0100 Subject: [PATCH 045/135] Adding ability to list and create notes --- src/ApiBase.coffee | 1 + src/Models/IssueNotes.coffee | 29 +++++++++++++++++++++++++++++ src/Models/Issues.coffee | 10 ++++++---- src/Models/Notes.coffee | 10 ++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 src/Models/IssueNotes.coffee create mode 100644 src/Models/Notes.coffee diff --git a/src/ApiBase.coffee b/src/ApiBase.coffee index 0cdee80..11e77ed 100644 --- a/src/ApiBase.coffee +++ b/src/ApiBase.coffee @@ -16,6 +16,7 @@ class module.exports.ApiBase @groups = require('./Models/Groups') @client @projects = require('./Models/Projects') @client @issues = require('./Models/Issues') @client + @notes = require('./Models/Notes') @client #@repositories = require('./Models/Repositories') @client @users = require('./Models/Users') @client #@mergeRequests = require('./Models/MergeRequests') @client diff --git a/src/Models/IssueNotes.coffee b/src/Models/IssueNotes.coffee new file mode 100644 index 0000000..39ab244 --- /dev/null +++ b/src/Models/IssueNotes.coffee @@ -0,0 +1,29 @@ +BaseModel = require '../BaseModel' +Utils = require '../Utils' + +class IssueNotes extends BaseModel + all: (projectId, issueId, params = {}, fn = null) => + @debug "IssueNotes::notes()" + + if 'function' is typeof params + fn = params + params = {} + params.page ?= 1 + params.per_page ?= 100 + + data = [] + cb = (err, retData) => + if err + return fn data if fn + else if retData.length == params.per_page + @debug "Recurse IssueNotes::all()" + data = data.concat(retData) + params.page++ + return @get "projects/#{Utils.parseProjectId projectId}/issues/#{Utils.parseProjectId issueId}/notes", params, cb + else + data = data.concat(retData) + return fn data if fn + + @get "projects/#{Utils.parseProjectId projectId}/issues/#{Utils.parseProjectId issueId}/notes", params, cb + +module.exports = (client) -> new IssueNotes client diff --git a/src/Models/Issues.coffee b/src/Models/Issues.coffee index 899e51e..0c64b4b 100644 --- a/src/Models/Issues.coffee +++ b/src/Models/Issues.coffee @@ -1,6 +1,8 @@ BaseModel = require '../BaseModel' class Issues extends BaseModel + init: => + @notes = @load 'IssueNotes' all: (params = {}, fn = null) => if 'function' is typeof params @@ -43,21 +45,21 @@ class Issues extends BaseModel projectId = encodeURIComponent(projectId) else projectId = parseInt(projectId) - + @post "projects/#{projectId}/issues", params, (data) -> fn data if fn - + edit: (projectId, issueId, params = {}, fn = null) => @debug "Issues::edit()" if projectId.toString().indexOf("/") isnt -1 projectId = encodeURIComponent(projectId) else projectId = parseInt(projectId) - + if issueId.toString().indexOf("/") isnt -1 issueId = encodeURIComponent(issueId) else issueId = parseInt(issueId) - + @put "projects/#{projectId}/issues/#{issueId}", params, (data) -> fn data if fn module.exports = (client) -> new Issues client diff --git a/src/Models/Notes.coffee b/src/Models/Notes.coffee new file mode 100644 index 0000000..78a07a8 --- /dev/null +++ b/src/Models/Notes.coffee @@ -0,0 +1,10 @@ +BaseModel = require '../BaseModel' +Utils = require '../Utils' + +class Notes extends BaseModel + + create: (projectId, issueId, params = {}, fn = null) => + @debug "Notes::create()" + @post "projects/#{Utils.parseProjectId projectId}/issues/#{Utils.parseProjectId issueId}/notes", params, (data) -> fn data if fn + +module.exports = (client) -> new Notes client From 4f69f34750f4e438db55decf5ab534ba0cbaf8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Jim=C3=A9nez?= Date: Sun, 8 Feb 2015 20:27:39 +0100 Subject: [PATCH 046/135] Notes moved to ProjectIssues --- src/Models/IssueNotes.coffee | 4 ++-- src/Models/Issues.coffee | 3 --- src/Models/Notes.coffee | 2 +- src/Models/ProjectIssues.coffee | 3 +++ 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Models/IssueNotes.coffee b/src/Models/IssueNotes.coffee index 39ab244..3e1ef8b 100644 --- a/src/Models/IssueNotes.coffee +++ b/src/Models/IssueNotes.coffee @@ -19,11 +19,11 @@ class IssueNotes extends BaseModel @debug "Recurse IssueNotes::all()" data = data.concat(retData) params.page++ - return @get "projects/#{Utils.parseProjectId projectId}/issues/#{Utils.parseProjectId issueId}/notes", params, cb + return @get "projects/#{Utils.parseProjectId projectId}/issues/#{parseInt issueId}/notes", params, cb else data = data.concat(retData) return fn data if fn - @get "projects/#{Utils.parseProjectId projectId}/issues/#{Utils.parseProjectId issueId}/notes", params, cb + @get "projects/#{Utils.parseProjectId projectId}/issues/#{parseInt issueId}/notes", params, cb module.exports = (client) -> new IssueNotes client diff --git a/src/Models/Issues.coffee b/src/Models/Issues.coffee index 0c64b4b..5b88721 100644 --- a/src/Models/Issues.coffee +++ b/src/Models/Issues.coffee @@ -1,9 +1,6 @@ BaseModel = require '../BaseModel' class Issues extends BaseModel - init: => - @notes = @load 'IssueNotes' - all: (params = {}, fn = null) => if 'function' is typeof params fn = params diff --git a/src/Models/Notes.coffee b/src/Models/Notes.coffee index 78a07a8..ae63b40 100644 --- a/src/Models/Notes.coffee +++ b/src/Models/Notes.coffee @@ -5,6 +5,6 @@ class Notes extends BaseModel create: (projectId, issueId, params = {}, fn = null) => @debug "Notes::create()" - @post "projects/#{Utils.parseProjectId projectId}/issues/#{Utils.parseProjectId issueId}/notes", params, (data) -> fn data if fn + @post "projects/#{Utils.parseProjectId projectId}/issues/#{parseInt issueId}/notes", params, (data) -> fn data if fn module.exports = (client) -> new Notes client diff --git a/src/Models/ProjectIssues.coffee b/src/Models/ProjectIssues.coffee index 4a8e28a..778b3e1 100644 --- a/src/Models/ProjectIssues.coffee +++ b/src/Models/ProjectIssues.coffee @@ -2,6 +2,9 @@ BaseModel = require '../BaseModel' Utils = require '../Utils' class ProjectIssues extends BaseModel + init: => + @notes = @load 'IssueNotes' + list: (projectId, params = {}, fn = null) => @debug "ProjectIssues::issues()" From 23c12641b5b9a9d7188127f47f74e4e937b65567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Jim=C3=A9nez?= Date: Sun, 8 Feb 2015 20:29:59 +0100 Subject: [PATCH 047/135] Latest changes build --- lib/ApiBase.js | 1 + lib/Models/IssueNotes.js | 70 +++++++++++++++++++++++++++++++++++++ lib/Models/Notes.js | 43 +++++++++++++++++++++++ lib/Models/ProjectIssues.js | 5 +++ 4 files changed, 119 insertions(+) create mode 100644 lib/Models/IssueNotes.js create mode 100644 lib/Models/Notes.js diff --git a/lib/ApiBase.js b/lib/ApiBase.js index ef44a41..789c697 100644 --- a/lib/ApiBase.js +++ b/lib/ApiBase.js @@ -29,6 +29,7 @@ this.groups = require('./Models/Groups')(this.client); this.projects = require('./Models/Projects')(this.client); this.issues = require('./Models/Issues')(this.client); + this.notes = require('./Models/Notes')(this.client); this.users = require('./Models/Users')(this.client); return this.labels = require('./Models/Labels')(this.client); }; diff --git a/lib/Models/IssueNotes.js b/lib/Models/IssueNotes.js new file mode 100644 index 0000000..b59798a --- /dev/null +++ b/lib/Models/IssueNotes.js @@ -0,0 +1,70 @@ +// Generated by CoffeeScript 1.9.0 +(function() { + var BaseModel, IssueNotes, Utils, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; + + BaseModel = require('../BaseModel'); + + Utils = require('../Utils'); + + IssueNotes = (function(_super) { + __extends(IssueNotes, _super); + + function IssueNotes() { + this.all = __bind(this.all, this); + return IssueNotes.__super__.constructor.apply(this, arguments); + } + + IssueNotes.prototype.all = function(projectId, issueId, params, fn) { + var cb, data; + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("IssueNotes::notes()"); + if ('function' === typeof params) { + fn = params; + params = {}; + } + if (params.page == null) { + params.page = 1; + } + if (params.per_page == null) { + params.per_page = 100; + } + data = []; + cb = (function(_this) { + return function(err, retData) { + if (err) { + if (fn) { + return fn(data); + } + } else if (retData.length === params.per_page) { + _this.debug("Recurse IssueNotes::all()"); + data = data.concat(retData); + params.page++; + return _this.get("projects/" + (Utils.parseProjectId(projectId)) + "/issues/" + (parseInt(issueId)) + "/notes", params, cb); + } else { + data = data.concat(retData); + if (fn) { + return fn(data); + } + } + }; + })(this); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/issues/" + (parseInt(issueId)) + "/notes", params, cb); + }; + + return IssueNotes; + + })(BaseModel); + + module.exports = function(client) { + return new IssueNotes(client); + }; + +}).call(this); diff --git a/lib/Models/Notes.js b/lib/Models/Notes.js new file mode 100644 index 0000000..ff398b9 --- /dev/null +++ b/lib/Models/Notes.js @@ -0,0 +1,43 @@ +// Generated by CoffeeScript 1.9.0 +(function() { + var BaseModel, Notes, Utils, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; + + BaseModel = require('../BaseModel'); + + Utils = require('../Utils'); + + Notes = (function(_super) { + __extends(Notes, _super); + + function Notes() { + this.create = __bind(this.create, this); + return Notes.__super__.constructor.apply(this, arguments); + } + + Notes.prototype.create = function(projectId, issueId, params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Notes::create()"); + return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/issues/" + (parseInt(issueId)) + "/notes", params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + + return Notes; + + })(BaseModel); + + module.exports = function(client) { + return new Notes(client); + }; + +}).call(this); diff --git a/lib/Models/ProjectIssues.js b/lib/Models/ProjectIssues.js index 925f584..6332575 100644 --- a/lib/Models/ProjectIssues.js +++ b/lib/Models/ProjectIssues.js @@ -14,9 +14,14 @@ function ProjectIssues() { this.list = __bind(this.list, this); + this.init = __bind(this.init, this); return ProjectIssues.__super__.constructor.apply(this, arguments); } + ProjectIssues.prototype.init = function() { + return this.notes = this.load('IssueNotes'); + }; + ProjectIssues.prototype.list = function(projectId, params, fn) { if (params == null) { params = {}; From 601a43c15e6632868a481c14c92b5afbec76ee29 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 9 Feb 2015 11:20:31 +0100 Subject: [PATCH 048/135] Removed coffee header --- Cakefile | 12 ++++++------ examples/bad-token.js | 1 - examples/example.credentials.js | 1 - examples/list-projects.js | 1 - examples/list-users.js | 1 - examples/reset-hooks.js | 7 +++---- examples/show-file.js | 1 - examples/show-project.js | 1 - examples/show-user.js | 1 - lib/ApiBase.js | 1 - lib/ApiBaseHTTP.js | 1 - lib/ApiV3.js | 1 - lib/BaseModel.js | 1 - lib/Models/Groups.js | 1 - lib/Models/IssueNotes.js | 1 - lib/Models/Issues.js | 1 - lib/Models/Labels.js | 1 - lib/Models/Notes.js | 1 - lib/Models/ProjectDeployKeys.js | 1 - lib/Models/ProjectHooks.js | 1 - lib/Models/ProjectIssues.js | 1 - lib/Models/ProjectLabels.js | 1 - lib/Models/ProjectMembers.js | 1 - lib/Models/ProjectMergeRequests.js | 1 - lib/Models/ProjectMilestones.js | 1 - lib/Models/ProjectRepository.js | 1 - lib/Models/Projects.js | 1 - lib/Models/Users.js | 1 - lib/Utils.js | 1 - lib/index.js | 1 - tests/ApiBaseHTTP.test.js | 1 - tests/ProjectMembers.test.js | 1 - tests/ProjectRepository.test.js | 1 - tests/Projects.test.js | 1 - tests/Utils.test.js | 1 - tests/mock.js | 5 ++--- tests/test.js | 1 - tests/validators.js | 1 - 38 files changed, 11 insertions(+), 48 deletions(-) diff --git a/Cakefile b/Cakefile index e9a74e5..5b175e2 100644 --- a/Cakefile +++ b/Cakefile @@ -11,14 +11,14 @@ system = (command, args) -> spawn command, args, stdio: "inherit" build = (fn = null) -> - call 'coffee', ['-c', '-o', 'lib', 'src'] - call 'coffee', ['-c', '-o', 'examples', 'examples'] - call 'coffee', ['-c', '-o', 'tests', 'tests'] + call 'coffee', ['-c', '--no-header', '-o', 'lib', 'src'] + call 'coffee', ['-c', '--no-header', '-o', 'examples', 'examples'] + call 'coffee', ['-c', '--no-header', '-o', 'tests', 'tests'] watch = (fn = null) -> - system 'coffee', ['-w', '-c', '-o', 'lib', 'src'] - system 'coffee', ['-w', '-c', '-o', 'examples', 'examples'] - system 'coffee', ['-w', '-c', '-o', 'tests', 'tests'] + system 'coffee', ['-w', '--no-header', '-c', '-o', 'lib', 'src'] + system 'coffee', ['-w', '--no-header', '-c', '-o', 'examples', 'examples'] + system 'coffee', ['-w', '--no-header', '-c', '-o', 'tests', 'tests'] task 'watch', 'continually build the JavaScript code', -> watch -> diff --git a/examples/bad-token.js b/examples/bad-token.js index 1105c9c..398bfef 100644 --- a/examples/bad-token.js +++ b/examples/bad-token.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; diff --git a/examples/example.credentials.js b/examples/example.credentials.js index f3c5c56..2561918 100755 --- a/examples/example.credentials.js +++ b/examples/example.credentials.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { module.exports = { url: 'http://demo.gitlab.com', diff --git a/examples/list-projects.js b/examples/list-projects.js index 934a7ae..afee024 100755 --- a/examples/list-projects.js +++ b/examples/list-projects.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; diff --git a/examples/list-users.js b/examples/list-users.js index 79e84ea..458899a 100644 --- a/examples/list-users.js +++ b/examples/list-users.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; diff --git a/examples/reset-hooks.js b/examples/reset-hooks.js index 47eb0dc..3ec48ac 100644 --- a/examples/reset-hooks.js +++ b/examples/reset-hooks.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab; @@ -25,7 +24,7 @@ var hook, url, _j, _len1; url = "" + credentials.service_hook_base + project.path_with_namespace; if (hooks.length > 1) { - return console.log("" + url + " too much hooks"); + return console.log(url + " too much hooks"); } else if (hooks.length === 1) { for (_j = 0, _len1 = hooks.length; _j < _len1; _j++) { hook = hooks[_j]; @@ -35,10 +34,10 @@ }); } } - return console.log("" + url + " is already OK"); + return console.log(url + " is already OK"); } else { return gitlab.projects.hooks.add(project.id, url, function() { - return console.log("" + url + " has been added"); + return console.log(url + " has been added"); }); } }); diff --git a/examples/show-file.js b/examples/show-file.js index ea4e8b1..00c17ff 100644 --- a/examples/show-file.js +++ b/examples/show-file.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab, projectId; diff --git a/examples/show-project.js b/examples/show-project.js index e06b388..c1bea0a 100755 --- a/examples/show-project.js +++ b/examples/show-project.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab, projectId; diff --git a/examples/show-user.js b/examples/show-user.js index 12306e4..29a8298 100755 --- a/examples/show-user.js +++ b/examples/show-user.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, credentials, gitlab, userId; diff --git a/lib/ApiBase.js b/lib/ApiBase.js index 789c697..0f4a07f 100644 --- a/lib/ApiBase.js +++ b/lib/ApiBase.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index f8eae1f..9dd4b99 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var ApiBase, debug, querystring, slumber, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/ApiV3.js b/lib/ApiV3.js index 7358ca3..5fc586a 100644 --- a/lib/ApiV3.js +++ b/lib/ApiV3.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var ApiBaseHTTP, debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/BaseModel.js b/lib/BaseModel.js index 7711e95..86cac3c 100644 --- a/lib/BaseModel.js +++ b/lib/BaseModel.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var debug, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index ef86279..27ac0f5 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Groups, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/IssueNotes.js b/lib/Models/IssueNotes.js index b59798a..4749d45 100644 --- a/lib/Models/IssueNotes.js +++ b/lib/Models/IssueNotes.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, IssueNotes, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/Issues.js b/lib/Models/Issues.js index a50ce61..5a64b32 100644 --- a/lib/Models/Issues.js +++ b/lib/Models/Issues.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Issues, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/Labels.js b/lib/Models/Labels.js index e7d9165..2796966 100644 --- a/lib/Models/Labels.js +++ b/lib/Models/Labels.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Labels, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/Notes.js b/lib/Models/Notes.js index ff398b9..c720b6a 100644 --- a/lib/Models/Notes.js +++ b/lib/Models/Notes.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Notes, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectDeployKeys.js b/lib/Models/ProjectDeployKeys.js index 04eaa2f..3b55632 100644 --- a/lib/Models/ProjectDeployKeys.js +++ b/lib/Models/ProjectDeployKeys.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectKeys, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectHooks.js b/lib/Models/ProjectHooks.js index 86eca2c..4860f08 100644 --- a/lib/Models/ProjectHooks.js +++ b/lib/Models/ProjectHooks.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectHooks, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectIssues.js b/lib/Models/ProjectIssues.js index 6332575..a0f46ed 100644 --- a/lib/Models/ProjectIssues.js +++ b/lib/Models/ProjectIssues.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectIssues, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectLabels.js b/lib/Models/ProjectLabels.js index f3fdd3c..075c2ff 100644 --- a/lib/Models/ProjectLabels.js +++ b/lib/Models/ProjectLabels.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectLabels, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectMembers.js b/lib/Models/ProjectMembers.js index 1b61739..346f1cb 100644 --- a/lib/Models/ProjectMembers.js +++ b/lib/Models/ProjectMembers.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectMembers, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectMergeRequests.js b/lib/Models/ProjectMergeRequests.js index 9a98552..e6ceea3 100644 --- a/lib/Models/ProjectMergeRequests.js +++ b/lib/Models/ProjectMergeRequests.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectMergeRequests, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectMilestones.js b/lib/Models/ProjectMilestones.js index dc7cb65..8f2af7e 100644 --- a/lib/Models/ProjectMilestones.js +++ b/lib/Models/ProjectMilestones.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectMilestones, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index ab08fa6..4a0ec10 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, ProjectRepository, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index 5197820..aac71c2 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Projects, Utils, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Models/Users.js b/lib/Models/Users.js index ad234a4..1aa5f75 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var BaseModel, Users, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, diff --git a/lib/Utils.js b/lib/Utils.js index 3a6236d..50951fd 100644 --- a/lib/Utils.js +++ b/lib/Utils.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var Utils; diff --git a/lib/index.js b/lib/index.js index eb5678e..0a4b62a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.9.0 (function() { var ApiV3; diff --git a/tests/ApiBaseHTTP.test.js b/tests/ApiBaseHTTP.test.js index 2e965e2..324bd2c 100644 --- a/tests/ApiBaseHTTP.test.js +++ b/tests/ApiBaseHTTP.test.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var chai, expect, proxyquire, sinon, sinonChai; diff --git a/tests/ProjectMembers.test.js b/tests/ProjectMembers.test.js index cf43d3a..5adabba 100644 --- a/tests/ProjectMembers.test.js +++ b/tests/ProjectMembers.test.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var chai, expect, sinon, sinonChai; diff --git a/tests/ProjectRepository.test.js b/tests/ProjectRepository.test.js index 0b6a4c5..8d1db80 100644 --- a/tests/ProjectRepository.test.js +++ b/tests/ProjectRepository.test.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var chai, expect, sinon, sinonChai; diff --git a/tests/Projects.test.js b/tests/Projects.test.js index 4c56ccc..40bc89a 100644 --- a/tests/Projects.test.js +++ b/tests/Projects.test.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var chai, expect, sinon, sinonChai; diff --git a/tests/Utils.test.js b/tests/Utils.test.js index 0260d32..7aea4d4 100644 --- a/tests/Utils.test.js +++ b/tests/Utils.test.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Utils, chai, expect, proxyquire; diff --git a/tests/mock.js b/tests/mock.js index 0e7aabb..3320c9c 100644 --- a/tests/mock.js +++ b/tests/mock.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Mock, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; @@ -64,8 +63,8 @@ })(this)); }; - Mock.prototype.update_path = function(path) { - this.path = path; + Mock.prototype.update_path = function(_at_path) { + this.path = _at_path; return this; }; diff --git a/tests/test.js b/tests/test.js index e4e1178..e682d50 100644 --- a/tests/test.js +++ b/tests/test.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var Gitlab, assert, credentials, gitlab, mock, projectId, userId, validate_project; diff --git a/tests/validators.js b/tests/validators.js index d00b135..9def427 100644 --- a/tests/validators.js +++ b/tests/validators.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.8.0 (function() { var assert; From d338c9ae0156a6d309619b93b6c67ba80e74531b Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 9 Feb 2015 11:20:47 +0100 Subject: [PATCH 049/135] v1.3.0 --- README.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a53ab82..617dd4c 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,16 @@ MIT Changelog ========= +1.3.0 (2015-02-09) +------------------ + +- Now handling notes +- Now handling lables +- Added Groups.addMember() and Groups.access_levels +- Checking for permissions +- Added tests +- Code cleanup and various small improvements + 1.2.0 (2014-12-24) ------------------ diff --git a/package.json b/package.json index 917b1d0..c268c21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.2.0", + "version": "1.3.0", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From d7fd75de0436d51c92be7579a0212141b6c956e3 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 9 Feb 2015 11:23:12 +0100 Subject: [PATCH 050/135] Post release version bump --- README.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 617dd4c..a257d2e 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,11 @@ MIT Changelog ========= +1.4.0 (unreleased) +------------------ + +- No entry + 1.3.0 (2015-02-09) ------------------ diff --git a/package.json b/package.json index c268c21..0871b94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.3.0", + "version": "1.4.0", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 7efec65f113aaae13f95728de1fc514aae731728 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 9 Feb 2015 12:51:17 +0100 Subject: [PATCH 051/135] Added code-climate badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a257d2e..610ef77 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ node-gitlab [![Total views](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/counters/views.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) [![Views in the last 24 hours](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/counters/views-24h.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/node-gitlab/node-gitlab/trend.png)](https://bitdeli.com/free "Bitdeli Badge") +[![Code Climate](https://codeclimate.com/github/node-gitlab/node-gitlab/badges/gpa.svg)](https://codeclimate.com/github/node-gitlab/node-gitlab) [![NPM Badge](https://nodei.co/npm/gitlab.png?downloads=true&stars=true)](https://npmjs.org/package/gitlab) -- From 4ebbde804f6bd1b1cbda6605465c05361f567554 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 9 Feb 2015 12:55:41 +0100 Subject: [PATCH 052/135] Added links to tags in CHANGELOG + POC entry --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 610ef77..517b15b 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ Changelog - No entry -1.3.0 (2015-02-09) +[1.3.0](https://github.com/node-gitlab/node-gitlab/tree/v1.3.0) (2015-02-09) ------------------ - Now handling notes @@ -131,7 +131,7 @@ Changelog - Added tests - Code cleanup and various small improvements -1.2.0 (2014-12-24) +[1.2.0](https://github.com/node-gitlab/node-gitlab/tree/v1.2.0) (2014-12-24) ------------------ - Switched to new organization, some urls changed @@ -140,7 +140,7 @@ Changelog - Changed AddHook parameters - Happy Christmas -1.1.0 (2014-11-04) +[1.1.0](https://github.com/node-gitlab/node-gitlab/tree/v1.1.0) (2014-11-04) ------------------ - Added project branch support @@ -148,8 +148,13 @@ Changelog - Improved global error handling - Rebuilt javascript using latest Coffee-Script -1.0.0 (2014-08-19) +[1.0.0](https://github.com/node-gitlab/node-gitlab/tree/v1.0.0) (2014-08-19) ------------------ - Not fully stable, need more tests - Now we have a CHANGELOG + +[POC](https://github.com/node-gitlab/node-gitlab/tree/e7a5eedea4c27aed8bd567a3c455ec311b915d60) (2012-12-11) +---------------- + +- POC From 83e77c08ba11e8a4d3f8a8d87a2b03ad9c727026 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 11 Mar 2015 10:30:59 +0100 Subject: [PATCH 053/135] Let the default error handling autonomous Should fix #75 --- src/ApiBaseHTTP.coffee | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ApiBaseHTTP.coffee b/src/ApiBaseHTTP.coffee index ae418a2..42ddaae 100644 --- a/src/ApiBaseHTTP.coffee +++ b/src/ApiBaseHTTP.coffee @@ -37,10 +37,6 @@ class module.exports.ApiBaseHTTP extends ApiBase fn_wrapper: (fn) => return (err, response, ret) => - if err - debug 'an error has occured', err - if 400 <= err.statusCode <= 499 - throw "Authorisation error. #{err.statusCode}. Check your key." arity = fn.length switch arity when 1 then fn ret From 9ce9016221838360d040c58a740b377f03135d50 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Wed, 11 Mar 2015 09:55:28 +0000 Subject: [PATCH 054/135] Update to Coffeescript 1.9.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0871b94..404f533 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "slumber": ">=0.5.0" }, "devDependencies": { - "coffee-script": "*", + "coffee-script": ">=1.9.1", "mocha": "", "proxyquire": "~1.0.1", "chai": "~1.9.2", From cca5b66c5e31f77ff8df02ec7463af5958d9c239 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Wed, 11 Mar 2015 09:55:52 +0000 Subject: [PATCH 055/135] Rebuild with Coffeescript 1.9.1 --- examples/list-projects.js | 12 ++++---- examples/list-users.js | 12 ++++---- examples/reset-hooks.js | 18 ++++++------ lib/ApiBase.js | 16 +++++------ lib/ApiBaseHTTP.js | 46 +++++++++++++++--------------- lib/ApiV3.js | 12 ++++---- lib/BaseModel.js | 10 +++---- lib/Models/Groups.js | 30 +++++++++---------- lib/Models/IssueNotes.js | 12 ++++---- lib/Models/Issues.js | 18 ++++++------ lib/Models/Labels.js | 12 ++++---- lib/Models/Notes.js | 12 ++++---- lib/Models/ProjectDeployKeys.js | 16 +++++------ lib/Models/ProjectHooks.js | 20 ++++++------- lib/Models/ProjectIssues.js | 14 ++++----- lib/Models/ProjectLabels.js | 12 ++++---- lib/Models/ProjectMembers.js | 20 ++++++------- lib/Models/ProjectMergeRequests.js | 20 ++++++------- lib/Models/ProjectMilestones.js | 18 ++++++------ lib/Models/ProjectRepository.js | 38 ++++++++++++------------ lib/Models/Projects.js | 28 +++++++++--------- lib/Models/Users.js | 20 ++++++------- tests/Projects.test.js | 12 ++++---- tests/mock.js | 26 ++++++++--------- tests/test.js | 6 ++-- 25 files changed, 230 insertions(+), 230 deletions(-) diff --git a/examples/list-projects.js b/examples/list-projects.js index afee024..c06d86a 100755 --- a/examples/list-projects.js +++ b/examples/list-projects.js @@ -13,13 +13,13 @@ }); gitlab.projects.all(function(projects) { - var project, _i, _len, _results; - _results = []; - for (_i = 0, _len = projects.length; _i < _len; _i++) { - project = projects[_i]; - _results.push(console.log("#" + project.id + ": " + project.name + ", path: " + project.path + ", default_branch: " + project.default_branch + ", private: " + project["private"] + ", owner: " + project.owner.name + " (" + project.owner.email + "), date: " + project.created_at)); + var i, len, project, results; + results = []; + for (i = 0, len = projects.length; i < len; i++) { + project = projects[i]; + results.push(console.log("#" + project.id + ": " + project.name + ", path: " + project.path + ", default_branch: " + project.default_branch + ", private: " + project["private"] + ", owner: " + project.owner.name + " (" + project.owner.email + "), date: " + project.created_at)); } - return _results; + return results; }); }).call(this); diff --git a/examples/list-users.js b/examples/list-users.js index 458899a..272bad1 100644 --- a/examples/list-users.js +++ b/examples/list-users.js @@ -13,13 +13,13 @@ }); gitlab.users.all(function(users) { - var user, _i, _len, _results; - _results = []; - for (_i = 0, _len = users.length; _i < _len; _i++) { - user = users[_i]; - _results.push(console.log("#" + user.id + ": " + user.email + ", " + user.name + ", " + user.created_at)); + var i, len, results, user; + results = []; + for (i = 0, len = users.length; i < len; i++) { + user = users[i]; + results.push(console.log("#" + user.id + ": " + user.email + ", " + user.name + ", " + user.created_at)); } - return _results; + return results; }); }).call(this); diff --git a/examples/reset-hooks.js b/examples/reset-hooks.js index 3ec48ac..87f4221 100644 --- a/examples/reset-hooks.js +++ b/examples/reset-hooks.js @@ -13,21 +13,21 @@ }); gitlab.projects.all(function(projects) { - var _i, _len, _project, _results; - _results = []; - for (_i = 0, _len = projects.length; _i < _len; _i++) { - _project = projects[_i]; - _results.push((function() { + var _project, i, len, results; + results = []; + for (i = 0, len = projects.length; i < len; i++) { + _project = projects[i]; + results.push((function() { var project; project = _project; return gitlab.projects.hooks.list(project.id, function(hooks) { - var hook, url, _j, _len1; + var hook, j, len1, url; url = "" + credentials.service_hook_base + project.path_with_namespace; if (hooks.length > 1) { return console.log(url + " too much hooks"); } else if (hooks.length === 1) { - for (_j = 0, _len1 = hooks.length; _j < _len1; _j++) { - hook = hooks[_j]; + for (j = 0, len1 = hooks.length; j < len1; j++) { + hook = hooks[j]; if (hook.url !== url) { gitlab.projects.hooks.remove(project.id, hook.id, function(ret) { return console.log(ret); @@ -43,7 +43,7 @@ }); })()); } - return _results; + return results; }); }).call(this); diff --git a/lib/ApiBase.js b/lib/ApiBase.js index 0f4a07f..2b14332 100644 --- a/lib/ApiBase.js +++ b/lib/ApiBase.js @@ -1,23 +1,23 @@ (function() { var debug, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; debug = require('debug')('gitlab:ApiBase'); module.exports.ApiBase = (function() { - function ApiBase(_at_options) { - this.options = _at_options; - this.init = __bind(this.init, this); - this.handleOptions = __bind(this.handleOptions, this); + function ApiBase(options) { + this.options = options; + this.init = bind(this.init, this); + this.handleOptions = bind(this.handleOptions, this); this.handleOptions(); this.init(); debug("constructor()"); } ApiBase.prototype.handleOptions = function() { - var _base; - if ((_base = this.options).verbose == null) { - _base.verbose = false; + var base; + if ((base = this.options).verbose == null) { + base.verbose = false; } return debug("handleOptions()"); }; diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index 9dd4b99..934cd3c 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -1,8 +1,8 @@ (function() { var ApiBase, debug, querystring, slumber, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; debug = require('debug')('gitlab:ApiBaseHTTP'); @@ -12,27 +12,27 @@ slumber = require('slumber'); - module.exports.ApiBaseHTTP = (function(_super) { - __extends(ApiBaseHTTP, _super); + module.exports.ApiBaseHTTP = (function(superClass) { + extend(ApiBaseHTTP, superClass); function ApiBaseHTTP() { - this.patch = __bind(this.patch, this); - this.put = __bind(this.put, this); - this.post = __bind(this.post, this); - this["delete"] = __bind(this["delete"], this); - this.get = __bind(this.get, this); - this.fn_wrapper = __bind(this.fn_wrapper, this); - this.prepare_opts = __bind(this.prepare_opts, this); - this.init = __bind(this.init, this); - this.handleOptions = __bind(this.handleOptions, this); + this.patch = bind(this.patch, this); + this.put = bind(this.put, this); + this.post = bind(this.post, this); + this["delete"] = bind(this["delete"], this); + this.get = bind(this.get, this); + this.fn_wrapper = bind(this.fn_wrapper, this); + this.prepare_opts = bind(this.prepare_opts, this); + this.init = bind(this.init, this); + this.handleOptions = bind(this.handleOptions, this); return ApiBaseHTTP.__super__.constructor.apply(this, arguments); } ApiBaseHTTP.prototype.handleOptions = function() { - var _base, _base1, _base2; + var base, base1, base2; ApiBaseHTTP.__super__.handleOptions.apply(this, arguments); - if ((_base = this.options).base_url == null) { - _base.base_url = ''; + if ((base = this.options).base_url == null) { + base.base_url = ''; } if (!this.options.url) { throw "`url` is mandatory"; @@ -40,11 +40,11 @@ if (!this.options.token) { throw "`private_token` is mandatory"; } - if ((_base1 = this.options).slumber == null) { - _base1.slumber = {}; + if ((base1 = this.options).slumber == null) { + base1.slumber = {}; } - if ((_base2 = this.options.slumber).append_slash == null) { - _base2.append_slash = false; + if ((base2 = this.options.slumber).append_slash == null) { + base2.append_slash = false; } this.options.url = this.options.url.replace(/\/api\/v3/, ''); if (this.options.auth != null) { @@ -71,10 +71,10 @@ ApiBaseHTTP.prototype.fn_wrapper = function(fn) { return (function(_this) { return function(err, response, ret) { - var arity, _ref; + var arity, ref; if (err) { debug('an error has occured', err); - if ((400 <= (_ref = err.statusCode) && _ref <= 499)) { + if ((400 <= (ref = err.statusCode) && ref <= 499)) { throw "Authorisation error. " + err.statusCode + ". Check your key."; } } diff --git a/lib/ApiV3.js b/lib/ApiV3.js index 5fc586a..6b5c3fb 100644 --- a/lib/ApiV3.js +++ b/lib/ApiV3.js @@ -1,18 +1,18 @@ (function() { var ApiBaseHTTP, debug, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; debug = require('debug')('gitlab:ApiV3'); ApiBaseHTTP = require('./ApiBaseHTTP').ApiBaseHTTP; - module.exports.ApiV3 = (function(_super) { - __extends(ApiV3, _super); + module.exports.ApiV3 = (function(superClass) { + extend(ApiV3, superClass); function ApiV3() { - this.handleOptions = __bind(this.handleOptions, this); + this.handleOptions = bind(this.handleOptions, this); return ApiV3.__super__.constructor.apply(this, arguments); } diff --git a/lib/BaseModel.js b/lib/BaseModel.js index 86cac3c..80e44c4 100644 --- a/lib/BaseModel.js +++ b/lib/BaseModel.js @@ -1,14 +1,14 @@ (function() { var debug, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; debug = require('debug')('gitlab:BaseModel'); module.exports = (function() { - function exports(_at_client) { - this.client = _at_client; - this._init = __bind(this._init, this); - this.load = __bind(this.load, this); + function exports(client) { + this.client = client; + this._init = bind(this._init, this); + this.load = bind(this.load, this); this._init(); } diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index 27ac0f5..9d97d23 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -1,21 +1,21 @@ (function() { var BaseModel, Groups, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); - Groups = (function(_super) { - __extends(Groups, _super); + Groups = (function(superClass) { + extend(Groups, superClass); function Groups() { - this.addMember = __bind(this.addMember, this); - this.listMembers = __bind(this.listMembers, this); - this.listProjects = __bind(this.listProjects, this); - this.show = __bind(this.show, this); - this.all = __bind(this.all, this); - this.init = __bind(this.init, this); + this.addMember = bind(this.addMember, this); + this.listMembers = bind(this.listMembers, this); + this.listProjects = bind(this.listProjects, this); + this.show = bind(this.show, this); + this.all = bind(this.all, this); + this.init = bind(this.init, this); return Groups.__super__.constructor.apply(this, arguments); } @@ -127,10 +127,10 @@ this.debug("addMember(" + groupId + ", " + userId + ", " + accessLevel + ")"); checkAccessLevel = (function(_this) { return function() { - var access_level, k, _ref; - _ref = _this.access_levels; - for (k in _ref) { - access_level = _ref[k]; + var access_level, k, ref; + ref = _this.access_levels; + for (k in ref) { + access_level = ref[k]; if (accessLevel === access_level) { return true; } diff --git a/lib/Models/IssueNotes.js b/lib/Models/IssueNotes.js index 4749d45..54bd415 100644 --- a/lib/Models/IssueNotes.js +++ b/lib/Models/IssueNotes.js @@ -1,18 +1,18 @@ (function() { var BaseModel, IssueNotes, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - IssueNotes = (function(_super) { - __extends(IssueNotes, _super); + IssueNotes = (function(superClass) { + extend(IssueNotes, superClass); function IssueNotes() { - this.all = __bind(this.all, this); + this.all = bind(this.all, this); return IssueNotes.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/Issues.js b/lib/Models/Issues.js index 5a64b32..093f018 100644 --- a/lib/Models/Issues.js +++ b/lib/Models/Issues.js @@ -1,19 +1,19 @@ (function() { var BaseModel, Issues, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); - Issues = (function(_super) { - __extends(Issues, _super); + Issues = (function(superClass) { + extend(Issues, superClass); function Issues() { - this.edit = __bind(this.edit, this); - this.create = __bind(this.create, this); - this.show = __bind(this.show, this); - this.all = __bind(this.all, this); + this.edit = bind(this.edit, this); + this.create = bind(this.create, this); + this.show = bind(this.show, this); + this.all = bind(this.all, this); return Issues.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/Labels.js b/lib/Models/Labels.js index 2796966..339700d 100644 --- a/lib/Models/Labels.js +++ b/lib/Models/Labels.js @@ -1,18 +1,18 @@ (function() { var BaseModel, Labels, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - Labels = (function(_super) { - __extends(Labels, _super); + Labels = (function(superClass) { + extend(Labels, superClass); function Labels() { - this.create = __bind(this.create, this); + this.create = bind(this.create, this); return Labels.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/Notes.js b/lib/Models/Notes.js index c720b6a..c0f1e89 100644 --- a/lib/Models/Notes.js +++ b/lib/Models/Notes.js @@ -1,18 +1,18 @@ (function() { var BaseModel, Notes, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - Notes = (function(_super) { - __extends(Notes, _super); + Notes = (function(superClass) { + extend(Notes, superClass); function Notes() { - this.create = __bind(this.create, this); + this.create = bind(this.create, this); return Notes.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/ProjectDeployKeys.js b/lib/Models/ProjectDeployKeys.js index 3b55632..929a99d 100644 --- a/lib/Models/ProjectDeployKeys.js +++ b/lib/Models/ProjectDeployKeys.js @@ -1,20 +1,20 @@ (function() { var BaseModel, ProjectKeys, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - ProjectKeys = (function(_super) { - __extends(ProjectKeys, _super); + ProjectKeys = (function(superClass) { + extend(ProjectKeys, superClass); function ProjectKeys() { - this.addKey = __bind(this.addKey, this); - this.getKey = __bind(this.getKey, this); - this.listKeys = __bind(this.listKeys, this); + this.addKey = bind(this.addKey, this); + this.getKey = bind(this.getKey, this); + this.listKeys = bind(this.listKeys, this); return ProjectKeys.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/ProjectHooks.js b/lib/Models/ProjectHooks.js index 4860f08..20e1aff 100644 --- a/lib/Models/ProjectHooks.js +++ b/lib/Models/ProjectHooks.js @@ -1,22 +1,22 @@ (function() { var BaseModel, ProjectHooks, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - ProjectHooks = (function(_super) { - __extends(ProjectHooks, _super); + ProjectHooks = (function(superClass) { + extend(ProjectHooks, superClass); function ProjectHooks() { - this.remove = __bind(this.remove, this); - this.update = __bind(this.update, this); - this.add = __bind(this.add, this); - this.show = __bind(this.show, this); - this.list = __bind(this.list, this); + this.remove = bind(this.remove, this); + this.update = bind(this.update, this); + this.add = bind(this.add, this); + this.show = bind(this.show, this); + this.list = bind(this.list, this); return ProjectHooks.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/ProjectIssues.js b/lib/Models/ProjectIssues.js index a0f46ed..2844f80 100644 --- a/lib/Models/ProjectIssues.js +++ b/lib/Models/ProjectIssues.js @@ -1,19 +1,19 @@ (function() { var BaseModel, ProjectIssues, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - ProjectIssues = (function(_super) { - __extends(ProjectIssues, _super); + ProjectIssues = (function(superClass) { + extend(ProjectIssues, superClass); function ProjectIssues() { - this.list = __bind(this.list, this); - this.init = __bind(this.init, this); + this.list = bind(this.list, this); + this.init = bind(this.init, this); return ProjectIssues.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/ProjectLabels.js b/lib/Models/ProjectLabels.js index 075c2ff..c9da1ea 100644 --- a/lib/Models/ProjectLabels.js +++ b/lib/Models/ProjectLabels.js @@ -1,18 +1,18 @@ (function() { var BaseModel, ProjectLabels, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - ProjectLabels = (function(_super) { - __extends(ProjectLabels, _super); + ProjectLabels = (function(superClass) { + extend(ProjectLabels, superClass); function ProjectLabels() { - this.all = __bind(this.all, this); + this.all = bind(this.all, this); return ProjectLabels.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/ProjectMembers.js b/lib/Models/ProjectMembers.js index 346f1cb..72b4b1d 100644 --- a/lib/Models/ProjectMembers.js +++ b/lib/Models/ProjectMembers.js @@ -1,22 +1,22 @@ (function() { var BaseModel, ProjectMembers, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - ProjectMembers = (function(_super) { - __extends(ProjectMembers, _super); + ProjectMembers = (function(superClass) { + extend(ProjectMembers, superClass); function ProjectMembers() { - this.remove = __bind(this.remove, this); - this.update = __bind(this.update, this); - this.add = __bind(this.add, this); - this.show = __bind(this.show, this); - this.list = __bind(this.list, this); + this.remove = bind(this.remove, this); + this.update = bind(this.update, this); + this.add = bind(this.add, this); + this.show = bind(this.show, this); + this.list = bind(this.list, this); return ProjectMembers.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/ProjectMergeRequests.js b/lib/Models/ProjectMergeRequests.js index e6ceea3..edfab59 100644 --- a/lib/Models/ProjectMergeRequests.js +++ b/lib/Models/ProjectMergeRequests.js @@ -1,22 +1,22 @@ (function() { var BaseModel, ProjectMergeRequests, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - ProjectMergeRequests = (function(_super) { - __extends(ProjectMergeRequests, _super); + ProjectMergeRequests = (function(superClass) { + extend(ProjectMergeRequests, superClass); function ProjectMergeRequests() { - this.comment = __bind(this.comment, this); - this.update = __bind(this.update, this); - this.add = __bind(this.add, this); - this.show = __bind(this.show, this); - this.list = __bind(this.list, this); + this.comment = bind(this.comment, this); + this.update = bind(this.update, this); + this.add = bind(this.add, this); + this.show = bind(this.show, this); + this.list = bind(this.list, this); return ProjectMergeRequests.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/ProjectMilestones.js b/lib/Models/ProjectMilestones.js index 8f2af7e..b01231c 100644 --- a/lib/Models/ProjectMilestones.js +++ b/lib/Models/ProjectMilestones.js @@ -1,21 +1,21 @@ (function() { var BaseModel, ProjectMilestones, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - ProjectMilestones = (function(_super) { - __extends(ProjectMilestones, _super); + ProjectMilestones = (function(superClass) { + extend(ProjectMilestones, superClass); function ProjectMilestones() { - this.update = __bind(this.update, this); - this.add = __bind(this.add, this); - this.show = __bind(this.show, this); - this.list = __bind(this.list, this); + this.update = bind(this.update, this); + this.add = bind(this.add, this); + this.show = bind(this.show, this); + this.list = bind(this.list, this); return ProjectMilestones.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 4a0ec10..ee9ba6f 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -1,31 +1,31 @@ (function() { var BaseModel, ProjectRepository, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - ProjectRepository = (function(_super) { - __extends(ProjectRepository, _super); + ProjectRepository = (function(superClass) { + extend(ProjectRepository, superClass); function ProjectRepository() { - this.updateFile = __bind(this.updateFile, this); - this.createFile = __bind(this.createFile, this); - this.showFile = __bind(this.showFile, this); - this.listTree = __bind(this.listTree, this); - this.diffCommit = __bind(this.diffCommit, this); - this.showCommit = __bind(this.showCommit, this); - this.listCommits = __bind(this.listCommits, this); - this.listTags = __bind(this.listTags, this); - this.deleteBranch = __bind(this.deleteBranch, this); - this.createBranch = __bind(this.createBranch, this); - this.unprotectBranch = __bind(this.unprotectBranch, this); - this.protectBranch = __bind(this.protectBranch, this); - this.showBranch = __bind(this.showBranch, this); - this.listBranches = __bind(this.listBranches, this); + this.updateFile = bind(this.updateFile, this); + this.createFile = bind(this.createFile, this); + this.showFile = bind(this.showFile, this); + this.listTree = bind(this.listTree, this); + this.diffCommit = bind(this.diffCommit, this); + this.showCommit = bind(this.showCommit, this); + this.listCommits = bind(this.listCommits, this); + this.listTags = bind(this.listTags, this); + this.deleteBranch = bind(this.deleteBranch, this); + this.createBranch = bind(this.createBranch, this); + this.unprotectBranch = bind(this.unprotectBranch, this); + this.protectBranch = bind(this.protectBranch, this); + this.showBranch = bind(this.showBranch, this); + this.listBranches = bind(this.listBranches, this); return ProjectRepository.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index aac71c2..d2ca21b 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -1,26 +1,26 @@ (function() { var BaseModel, Projects, Utils, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); Utils = require('../Utils'); - Projects = (function(_super) { - __extends(Projects, _super); + Projects = (function(superClass) { + extend(Projects, superClass); function Projects() { - this.listTags = __bind(this.listTags, this); - this.listCommits = __bind(this.listCommits, this); - this.listMembers = __bind(this.listMembers, this); - this.editMember = __bind(this.editMember, this); - this.addMember = __bind(this.addMember, this); - this.create = __bind(this.create, this); - this.show = __bind(this.show, this); - this.all = __bind(this.all, this); - this.init = __bind(this.init, this); + this.listTags = bind(this.listTags, this); + this.listCommits = bind(this.listCommits, this); + this.listMembers = bind(this.listMembers, this); + this.editMember = bind(this.editMember, this); + this.addMember = bind(this.addMember, this); + this.create = bind(this.create, this); + this.show = bind(this.show, this); + this.all = bind(this.all, this); + this.init = bind(this.init, this); return Projects.__super__.constructor.apply(this, arguments); } diff --git a/lib/Models/Users.js b/lib/Models/Users.js index 1aa5f75..51ca6de 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -1,20 +1,20 @@ (function() { var BaseModel, Users, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; BaseModel = require('../BaseModel'); - Users = (function(_super) { - __extends(Users, _super); + Users = (function(superClass) { + extend(Users, superClass); function Users() { - this.session = __bind(this.session, this); - this.create = __bind(this.create, this); - this.show = __bind(this.show, this); - this.current = __bind(this.current, this); - this.all = __bind(this.all, this); + this.session = bind(this.session, this); + this.create = bind(this.create, this); + this.show = bind(this.show, this); + this.current = bind(this.current, this); + this.all = bind(this.all, this); return Users.__super__.constructor.apply(this, arguments); } diff --git a/tests/Projects.test.js b/tests/Projects.test.js index 40bc89a..8116a5b 100644 --- a/tests/Projects.test.js +++ b/tests/Projects.test.js @@ -53,9 +53,9 @@ arrayOf99 = []; arrayOf1 = []; before(function() { - var i, _i, _results; - _results = []; - for (i = _i = 0; _i <= 102; i = ++_i) { + var i, j, results; + results = []; + for (i = j = 0; j <= 102; i = ++j) { if (i < 1) { arrayOf1.push({}); } @@ -66,12 +66,12 @@ arrayOf100.push({}); } if (i < 101) { - _results.push(arrayOf101.push({})); + results.push(arrayOf101.push({})); } else { - _results.push(void 0); + results.push(void 0); } } - return _results; + return results; }); it("should use GET verb", function() { var getStub; diff --git a/tests/mock.js b/tests/mock.js index 3320c9c..f32e234 100644 --- a/tests/mock.js +++ b/tests/mock.js @@ -1,12 +1,12 @@ (function() { var Mock, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; Mock = (function() { function Mock() { - this.beforeEach = __bind(this.beforeEach, this); - this.update_path = __bind(this.update_path, this); - this.setup = __bind(this.setup, this); + this.beforeEach = bind(this.beforeEach, this); + this.update_path = bind(this.update_path, this); + this.setup = bind(this.setup, this); var project; this.path = ''; this.projects = []; @@ -63,8 +63,8 @@ })(this)); }; - Mock.prototype.update_path = function(_at_path) { - this.path = _at_path; + Mock.prototype.update_path = function(path1) { + this.path = path1; return this; }; @@ -97,14 +97,14 @@ }; Mock.prototype.beforeEach = function() { - var method, _i, _len, _ref, _results; - _ref = ['get', 'delete', 'post', 'put', 'patch']; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - method = _ref[_i]; - _results.push(this[method] = this.defaults[method]); + var i, len, method, ref, results; + ref = ['get', 'delete', 'post', 'put', 'patch']; + results = []; + for (i = 0, len = ref.length; i < len; i++) { + method = ref[i]; + results.push(this[method] = this.defaults[method]); } - return _results; + return results; }; return Mock; diff --git a/tests/test.js b/tests/test.js index e682d50..71368c4 100644 --- a/tests/test.js +++ b/tests/test.js @@ -69,10 +69,10 @@ }); return it('should retrieve array of projects without error', function(done) { return gitlab.projects.all(function(projects) { - var project, _i, _len; + var i, len, project; assert(projects.length > 0); - for (_i = 0, _len = projects.length; _i < _len; _i++) { - project = projects[_i]; + for (i = 0, len = projects.length; i < len; i++) { + project = projects[i]; validate_project(project); } return done(); From 2e08eecbc8f899aed44ef4a1565f783ec5b35d7c Mon Sep 17 00:00:00 2001 From: huhgawz Date: Thu, 5 Mar 2015 21:41:33 -0600 Subject: [PATCH 056/135] Add .editorconfig file --- .editorconfig | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..aff8802 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,24 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[.*ignore] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[**.{coffee,js,json}] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = false +trim_trailing_whitespace = true + +[*.md] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = false \ No newline at end of file From 44b2ba2d665d7bd4c42664cfa2d175bfb9b8ff04 Mon Sep 17 00:00:00 2001 From: huhgawz Date: Thu, 5 Mar 2015 21:42:47 -0600 Subject: [PATCH 057/135] Add create and addProject methods --- src/Models/Groups.coffee | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Models/Groups.coffee b/src/Models/Groups.coffee index 6da1eba..0734231 100644 --- a/src/Models/Groups.coffee +++ b/src/Models/Groups.coffee @@ -14,7 +14,7 @@ class Groups extends BaseModel fn = params params = {} @debug "Groups::all()" - + params.page ?= 1 params.per_page ?= 100 @@ -40,7 +40,7 @@ class Groups extends BaseModel listProjects: (groupId, fn = null) => @debug "Groups::listProjects()" @get "groups/#{parseInt groupId}", (data) => fn data.projects if fn - + listMembers: (groupId, fn = null) => @debug "Groups::listMembers()" @get "groups/#{parseInt groupId}/members", (data) => fn data if fn @@ -62,5 +62,12 @@ class Groups extends BaseModel @post "groups/#{parseInt groupId}/members", params, (data) -> fn data if fn + create: (params = {}, fn = null) => + @debug "Groups::create()" + @post "groups", params, (data) -> fn data if fn + + addProject: (groupId, projectId, fn = null) => + @debug "Groups::addProject(#{groupId}, #{projectId})" + @post "groups/#{parseInt groupId}/projects/#{parseInt projectId}", null, (data) -> fn data if fn module.exports = (client) -> new Groups client From 949648f883f8e30e2c5388d6e1cdf0e0c9cfdae2 Mon Sep 17 00:00:00 2001 From: huhgawz Date: Thu, 5 Mar 2015 21:43:13 -0600 Subject: [PATCH 058/135] Add search method --- src/Models/Users.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Models/Users.coffee b/src/Models/Users.coffee index 2e61b74..74d6230 100644 --- a/src/Models/Users.coffee +++ b/src/Models/Users.coffee @@ -44,4 +44,10 @@ class Users extends BaseModel password: password @post "session", params, (data) -> fn data if fn + search: (emailOrUsername, fn = null) => + @debug "Users::search(#{emailOrUsername})" + params = + search: emailOrUsername + @get "users", params, (data) -> fn data if fn + module.exports = (client) -> new Users client From a263ae88785b89b956f38ea0baf28f6b4818cb25 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Wed, 11 Mar 2015 10:17:03 +0000 Subject: [PATCH 059/135] Add groups.search API --- src/Models/Groups.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Models/Groups.coffee b/src/Models/Groups.coffee index 0734231..1b71be6 100644 --- a/src/Models/Groups.coffee +++ b/src/Models/Groups.coffee @@ -70,4 +70,10 @@ class Groups extends BaseModel @debug "Groups::addProject(#{groupId}, #{projectId})" @post "groups/#{parseInt groupId}/projects/#{parseInt projectId}", null, (data) -> fn data if fn + search: (nameOrPath, fn = null) => + @debug "Groups::search(#{nameOrPath})" + params = + search: nameOrPath + @get "groups", params, (data) -> fn data if fn + module.exports = (client) -> new Groups client From d3946a30f1c24955a8bfce8db02e65403d275b98 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Wed, 11 Mar 2015 10:18:00 +0000 Subject: [PATCH 060/135] Coffeescript rebuild. --- lib/Models/Groups.js | 46 ++++++++++++++++++++++++++++++++++++++++++++ lib/Models/Users.js | 17 ++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index 9d97d23..10df0ec 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -10,6 +10,9 @@ extend(Groups, superClass); function Groups() { + this.search = bind(this.search, this); + this.addProject = bind(this.addProject, this); + this.create = bind(this.create, this); this.addMember = bind(this.addMember, this); this.listMembers = bind(this.listMembers, this); this.listProjects = bind(this.listProjects, this); @@ -152,6 +155,49 @@ }); }; + Groups.prototype.create = function(params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Groups::create()"); + return this.post("groups", params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + + Groups.prototype.addProject = function(groupId, projectId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Groups::addProject(" + groupId + ", " + projectId + ")"); + return this.post("groups/" + (parseInt(groupId)) + "/projects/" + (parseInt(projectId)), null, function(data) { + if (fn) { + return fn(data); + } + }); + }; + + Groups.prototype.search = function(nameOrPath, fn) { + var params; + if (fn == null) { + fn = null; + } + this.debug("Groups::search(" + nameOrPath + ")"); + params = { + search: nameOrPath + }; + return this.get("groups", params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + return Groups; })(BaseModel); diff --git a/lib/Models/Users.js b/lib/Models/Users.js index 51ca6de..7b03cff 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -10,6 +10,7 @@ extend(Users, superClass); function Users() { + this.search = bind(this.search, this); this.session = bind(this.session, this); this.create = bind(this.create, this); this.show = bind(this.show, this); @@ -124,6 +125,22 @@ }); }; + Users.prototype.search = function(emailOrUsername, fn) { + var params; + if (fn == null) { + fn = null; + } + this.debug("Users::search(" + emailOrUsername + ")"); + params = { + search: emailOrUsername + }; + return this.get("users", params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + return Users; })(BaseModel); From fa9c491a9ec3eaafd232f4fb6636f804715fef43 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Wed, 11 Mar 2015 10:19:48 +0000 Subject: [PATCH 061/135] Added huhgawz to Contributors --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 517b15b..4689618 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ Contributors - [shaoshuai0102](https://github.com/shaoshuai0102) - [Sakesan Panjamawat](https://github.com/sakp) - [Jose Jiménez](https://github.com/jjimenezlopez) +- [huhgawz](https://github.com/huhgawz) License ------- From 249e91eb37662a9ad628ee0962ca849f9efdbb2d Mon Sep 17 00:00:00 2001 From: Connor Weng Date: Thu, 19 Mar 2015 16:02:00 +0800 Subject: [PATCH 062/135] fix diffCommit --- lib/Models/ProjectRepository.js | 2 +- src/Models/ProjectRepository.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index ee9ba6f..8384838 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -163,7 +163,7 @@ fn = null; } this.debug("Projects::diffCommit()"); - return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/repository/branches/" + sha, (function(_this) { + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/repository/commits/" + sha + "/diff", (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index 48c1e8c..b955dc0 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -44,7 +44,7 @@ class ProjectRepository extends BaseModel diffCommit: (projectId, sha, fn = null) => @debug "Projects::diffCommit()" - @get "projects/#{Utils.parseProjectId projectId}/repository/branches/#{sha}", (data) => fn data if fn + @get "projects/#{Utils.parseProjectId projectId}/repository/commits/#{sha}/diff", (data) => fn data if fn # === Tree listTree: (projectId, params = {}, fn = null) => From a1ba7b8ef65eb8789a6cc3d8a134a5b25f4df90e Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 19 Mar 2015 13:14:10 +0100 Subject: [PATCH 063/135] Create LICENSE.md --- LICENSE.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..f578612 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,24 @@ +The MIT License +=============== + +Copyright (c) + **2012-2015 Manfred Touron** ([@moul](https://twitter.com/moul)), + **2013-2015 Dave Irvin** ([@dave_irvin](https://twitter.com/dave_irvine)) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. From 3b37f664dae3d91bacb9d3f1c3051cb0dcf0b5ea Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Thu, 19 Mar 2015 13:20:58 +0000 Subject: [PATCH 064/135] Update LICENSE.md --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index f578612..f401f49 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -3,7 +3,7 @@ The MIT License Copyright (c) **2012-2015 Manfred Touron** ([@moul](https://twitter.com/moul)), - **2013-2015 Dave Irvin** ([@dave_irvin](https://twitter.com/dave_irvine)) + **2013-2015 Dave Irvine** ([@dave_irvine](https://twitter.com/dave_irvine)) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 5fc33ea068d10b5babe00c59dcc5939f0a0ee0a2 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Thu, 19 Mar 2015 13:21:56 +0000 Subject: [PATCH 065/135] Added Connor Weng to Contributors list. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4689618..aa27878 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ Contributors - [Sakesan Panjamawat](https://github.com/sakp) - [Jose Jiménez](https://github.com/jjimenezlopez) - [huhgawz](https://github.com/huhgawz) +- [Connor Weng](https://github.com/ConnorWeng) License ------- From 12223c6b4b6df49d8cfe4d2960a837602a8da5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20L=C3=A5ng?= Date: Thu, 9 Apr 2015 07:32:40 +0300 Subject: [PATCH 066/135] Use cake and mocha under node_modules --- Cakefile | 14 ++++++++------ package.json | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cakefile b/Cakefile index 5b175e2..f985fcf 100644 --- a/Cakefile +++ b/Cakefile @@ -1,5 +1,7 @@ {spawn, exec} = require 'child_process' +coffee = './node_modules/.bin/coffee' + call = (command, args = [], fn = null) -> exec "#{command} #{args.join(' ')}", (err, stdout, stderr) -> if err? @@ -11,14 +13,14 @@ system = (command, args) -> spawn command, args, stdio: "inherit" build = (fn = null) -> - call 'coffee', ['-c', '--no-header', '-o', 'lib', 'src'] - call 'coffee', ['-c', '--no-header', '-o', 'examples', 'examples'] - call 'coffee', ['-c', '--no-header', '-o', 'tests', 'tests'] + call coffee, ['-c', '--no-header', '-o', 'lib', 'src'] + call coffee, ['-c', '--no-header', '-o', 'examples', 'examples'] + call coffee, ['-c', '--no-header', '-o', 'tests', 'tests'] watch = (fn = null) -> - system 'coffee', ['-w', '--no-header', '-c', '-o', 'lib', 'src'] - system 'coffee', ['-w', '--no-header', '-c', '-o', 'examples', 'examples'] - system 'coffee', ['-w', '--no-header', '-c', '-o', 'tests', 'tests'] + system coffee, ['-w', '--no-header', '-c', '-o', 'lib', 'src'] + system coffee, ['-w', '--no-header', '-c', '-o', 'examples', 'examples'] + system coffee, ['-w', '--no-header', '-c', '-o', 'tests', 'tests'] task 'watch', 'continually build the JavaScript code', -> watch -> diff --git a/package.json b/package.json index 404f533..3cc04f9 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "test": "test" }, "scripts": { - "test": "./node_modules/mocha/bin/mocha tests", - "build": "./node_modules/coffee-script/bin/cake build" + "test": "./node_modules/.bin/mocha tests", + "build": "./node_modules/.bin/cake build" }, "repository": { "type": "git", From 29caf2246db22ff73eb26074615e809a2bbb966d Mon Sep 17 00:00:00 2001 From: luispmiranda Date: Thu, 11 Jun 2015 09:18:33 +0100 Subject: [PATCH 067/135] Fix broken link for HTTP api --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa27878..8d1850e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ node-gitlab -- [GitLab](https://github.com/gitlabhq/gitlabhq) API Nodejs library. -It wraps the HTTP api library described [here](https://github.com/node-gitlab/gitlabhq/tree/master/doc/api). +It wraps the HTTP api library described [here](https://github.com/gitlabhq/gitlabhq/tree/master/doc/api). Maintained by [Manfred Touron](https://github.com/moul) and [Dave Irvine](https://github.com/dave-irvine) From c93bb54c40ac6143f7894c371d08477919ca77e1 Mon Sep 17 00:00:00 2001 From: Steve Norman Date: Fri, 26 Jun 2015 14:21:59 +0000 Subject: [PATCH 068/135] Use headers for PRIVATE-TOKEN --- lib/ApiBaseHTTP.js | 4 +++- package.json | 4 ++-- src/ApiBaseHTTP.coffee | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index 934cd3c..807d670 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -64,7 +64,9 @@ if (opts.__query == null) { opts.__query = {}; } - opts.__query.private_token = this.options.token; + opts.headers = { + 'PRIVATE-TOKEN': this.options.token + }; return opts; }; diff --git a/package.json b/package.json index 3cc04f9..05b7095 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.4.0", + "version": "1.4.1", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { @@ -17,7 +17,7 @@ }, "dependencies": { "debug": "*", - "slumber": ">=0.5.0" + "slumber": ">=0.7.0" }, "devDependencies": { "coffee-script": ">=1.9.1", diff --git a/src/ApiBaseHTTP.coffee b/src/ApiBaseHTTP.coffee index 42ddaae..9948f81 100644 --- a/src/ApiBaseHTTP.coffee +++ b/src/ApiBaseHTTP.coffee @@ -32,7 +32,7 @@ class module.exports.ApiBaseHTTP extends ApiBase prepare_opts: (opts) => opts.__query ?= {} - opts.__query.private_token = @options.token + opts.headers = { 'PRIVATE-TOKEN': @options.token } return opts fn_wrapper: (fn) => From 6f9ce99219612f23c9371f3a0a53a342cc0daa36 Mon Sep 17 00:00:00 2001 From: Steve Norman Date: Fri, 24 Apr 2015 11:52:49 +0000 Subject: [PATCH 069/135] Added functionality to remove projects --- lib/Models/Projects.js | 15 +++++++++++++++ src/Models/Projects.coffee | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index d2ca21b..a1e9b1c 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -12,6 +12,7 @@ extend(Projects, superClass); function Projects() { + this.remove = bind(this.remove, this); this.listTags = bind(this.listTags, this); this.listCommits = bind(this.listCommits, this); this.listMembers = bind(this.listMembers, this); @@ -185,6 +186,20 @@ })(this)); }; + Projects.prototype.remove = function(projectId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::remove()"); + return this["delete"]("projects/" + (Utils.parseProjectId(projectId)), (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + return Projects; })(BaseModel); diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index a43a05d..4e50c5c 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -64,4 +64,8 @@ class Projects extends BaseModel @debug "Projects::listTags()" @get "projects/#{params.id}/repository/tags", (data) => fn data if fn + remove: (projectId, fn = null) => + @debug "Projects::remove()" + @delete "projects/#{Utils.parseProjectId projectId}", (data) => fn data if fn + module.exports = (client) -> new Projects client From b129bd53ccca07ccd2d407c7055783e13f83e470 Mon Sep 17 00:00:00 2001 From: Felix Fichte Date: Thu, 6 Aug 2015 10:40:08 +0200 Subject: [PATCH 070/135] add possibility to pass params to list milestones --- src/Models/ProjectMilestones.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Models/ProjectMilestones.coffee b/src/Models/ProjectMilestones.coffee index 6b0360c..4a2ca9b 100644 --- a/src/Models/ProjectMilestones.coffee +++ b/src/Models/ProjectMilestones.coffee @@ -2,9 +2,12 @@ BaseModel = require '../BaseModel' Utils = require '../Utils' class ProjectMilestones extends BaseModel - list: (projectId, fn = null) => + list: (projectId, query, fn = null) => @debug "Projects::milestones()" - @get "projects/#{Utils.parseProjectId projectId}/milestones", (data) => fn data if fn + if 'function' is typeof query + fn = query + query = {} + @get "projects/#{Utils.parseProjectId projectId}/milestones", query, (data) => fn data if fn show: (projectId, milestoneId, fn = null) => @debug "Projects::milestone()" From 43ef138f51e7f7e447dc77205269e3f540277a6d Mon Sep 17 00:00:00 2001 From: Felix Fichte Date: Thu, 6 Aug 2015 10:46:16 +0200 Subject: [PATCH 071/135] showcase new option Gitlab API accepts parameters per_page and page for pagination also on get for milestones --- examples/show-project.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/show-project.coffee b/examples/show-project.coffee index a68540b..4e077ab 100755 --- a/examples/show-project.coffee +++ b/examples/show-project.coffee @@ -23,3 +23,8 @@ gitlab.projects.members.list projectId, (members) -> console.log "" console.log "=== Members ===" console.log members + +gitlab.projects.milestones.list projectId, {per_page: 100}, (milestones) -> + console.log "" + console.log "=== Milestones ===" + console.log milestones From 2047e00c7085e08ef2fb27d1d87ddbb0614ff169 Mon Sep 17 00:00:00 2001 From: Felix Fichte Date: Thu, 6 Aug 2015 11:35:36 +0200 Subject: [PATCH 072/135] Update ProjectMilestones.coffee --- src/Models/ProjectMilestones.coffee | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Models/ProjectMilestones.coffee b/src/Models/ProjectMilestones.coffee index 4a2ca9b..c55908d 100644 --- a/src/Models/ProjectMilestones.coffee +++ b/src/Models/ProjectMilestones.coffee @@ -2,12 +2,29 @@ BaseModel = require '../BaseModel' Utils = require '../Utils' class ProjectMilestones extends BaseModel - list: (projectId, query, fn = null) => - @debug "Projects::milestones()" - if 'function' is typeof query - fn = query - query = {} - @get "projects/#{Utils.parseProjectId projectId}/milestones", query, (data) => fn data if fn + list = (projectId, fn = null) -> + console.log 'DEPRECATED: milestone.list. Use milestone.all instead' + @all arguments... + all: (projectId, fn = null) => + @debug "Projects::Milestones::all()" + params = {} + params.page ?= 1 + params.per_page ?= 100 + + data = [] + cb = (err, retData) => + if err + return fn(retData || data) if fn + else if retData.length == params.per_page + @debug "Recurse Projects::Milestones::all()" + data = data.concat(retData) + params.page++ + return @get "projects/#{Utils.parseProjectId projectId}/milestones", params, cb + else + data = data.concat(retData) + return fn data if fn + + @get "projects/#{Utils.parseProjectId projectId}/milestones", params, cb show: (projectId, milestoneId, fn = null) => @debug "Projects::milestone()" From 7aaaa3b0e14d27d23bea725617f802302f5fe18e Mon Sep 17 00:00:00 2001 From: Felix Fichte Date: Thu, 6 Aug 2015 11:39:39 +0200 Subject: [PATCH 073/135] Update ProjectMilestones.coffee --- src/Models/ProjectMilestones.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/ProjectMilestones.coffee b/src/Models/ProjectMilestones.coffee index c55908d..bd68cec 100644 --- a/src/Models/ProjectMilestones.coffee +++ b/src/Models/ProjectMilestones.coffee @@ -2,7 +2,7 @@ BaseModel = require '../BaseModel' Utils = require '../Utils' class ProjectMilestones extends BaseModel - list = (projectId, fn = null) -> + list = (projectId, fn = null) -> console.log 'DEPRECATED: milestone.list. Use milestone.all instead' @all arguments... all: (projectId, fn = null) => From a464a365dc334c0300f51ac231d29a9ff9c23c06 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Thu, 6 Aug 2015 10:50:16 +0100 Subject: [PATCH 074/135] Containers *are* cool Travis. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 184785d..f71287f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ node_js: - "0.11" - "0.10" - "0.8" +sudo: false notifications: webhooks: urls: From d1584f2463b4ab2ca482497c091b12cfb6753370 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Thu, 6 Aug 2015 10:56:36 +0100 Subject: [PATCH 075/135] Drop 0.8 from Travis, add 0.12. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f71287f..cc4b897 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: node_js node_js: + - "0.12" - "0.11" - "0.10" - - "0.8" sudo: false notifications: webhooks: From ca6ca265a7056372168d534ea31b402ac68643f1 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Thu, 6 Aug 2015 11:06:56 +0100 Subject: [PATCH 076/135] Added Felix Fichte to Contributors list. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8d1850e..6c538b9 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ Contributors - [Jose Jiménez](https://github.com/jjimenezlopez) - [huhgawz](https://github.com/huhgawz) - [Connor Weng](https://github.com/ConnorWeng) +- [Felix Fichte](https://github.com/spruce) License ------- From cc3907e3de8af29e339badd0e5a3388abdf205bf Mon Sep 17 00:00:00 2001 From: Steve Norman Date: Wed, 29 Jul 2015 16:40:59 +0000 Subject: [PATCH 077/135] Fixed loading all users and groups by getting all pages. --- lib/Models/Groups.js | 8 +------- lib/Models/Users.js | 8 +------- src/Models/Groups.coffee | 2 +- src/Models/Users.coffee | 2 +- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index 10df0ec..1d233d4 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -71,13 +71,7 @@ } }; })(this); - return this.get("groups", params, (function(_this) { - return function(data) { - if (fn) { - return fn(data); - } - }; - })(this)); + return this.get("groups", params, cb); }; Groups.prototype.show = function(groupId, fn) { diff --git a/lib/Models/Users.js b/lib/Models/Users.js index 7b03cff..7fa75b1 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -58,13 +58,7 @@ } }; })(this); - return this.get("users", params, (function(_this) { - return function(data) { - if (fn) { - return fn(data); - } - }; - })(this)); + return this.get("users", params, cb); }; Users.prototype.current = function(fn) { diff --git a/src/Models/Groups.coffee b/src/Models/Groups.coffee index 1b71be6..7f20729 100644 --- a/src/Models/Groups.coffee +++ b/src/Models/Groups.coffee @@ -31,7 +31,7 @@ class Groups extends BaseModel data = data.concat(retData) return fn data if fn - @get "groups", params, (data) => fn data if fn + @get "groups", params, cb show: (groupId, fn = null) => @debug "Groups::show()" diff --git a/src/Models/Users.coffee b/src/Models/Users.coffee index 74d6230..06743d2 100644 --- a/src/Models/Users.coffee +++ b/src/Models/Users.coffee @@ -23,7 +23,7 @@ class Users extends BaseModel data = data.concat(retData) return fn data if fn - @get "users", params, (data) => fn data if fn + @get "users", params, cb current: (fn = null) => @debug "Users::current()" From ce7ce3ffc3584bb0aae9a9c815af10513c21e66a Mon Sep 17 00:00:00 2001 From: Steve Norman Date: Wed, 29 Jul 2015 16:40:59 +0000 Subject: [PATCH 078/135] Added ability to get users keys --- lib/Models/UserKeys.js | 38 ++++++++++++++++++++++++++++++++++++++ lib/Models/Users.js | 5 +++++ src/Models/UserKeys.coffee | 7 +++++++ src/Models/Users.coffee | 3 +++ 4 files changed, 53 insertions(+) create mode 100644 lib/Models/UserKeys.js create mode 100644 src/Models/UserKeys.coffee diff --git a/lib/Models/UserKeys.js b/lib/Models/UserKeys.js new file mode 100644 index 0000000..a5abc35 --- /dev/null +++ b/lib/Models/UserKeys.js @@ -0,0 +1,38 @@ +(function() { + var BaseModel, UserKeys, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + BaseModel = require('../BaseModel'); + + UserKeys = (function(superClass) { + extend(UserKeys, superClass); + + function UserKeys() { + this.all = bind(this.all, this); + return UserKeys.__super__.constructor.apply(this, arguments); + } + + UserKeys.prototype.all = function(userId, fn) { + if (fn == null) { + fn = null; + } + return this.get("users/" + (parseInt(userId)) + "/keys", (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + return UserKeys; + + })(BaseModel); + + module.exports = function(client) { + return new UserKeys(client); + }; + +}).call(this); diff --git a/lib/Models/Users.js b/lib/Models/Users.js index 7b03cff..960a02b 100644 --- a/lib/Models/Users.js +++ b/lib/Models/Users.js @@ -16,9 +16,14 @@ this.show = bind(this.show, this); this.current = bind(this.current, this); this.all = bind(this.all, this); + this.init = bind(this.init, this); return Users.__super__.constructor.apply(this, arguments); } + Users.prototype.init = function() { + return this.keys = this.load('UserKeys'); + }; + Users.prototype.all = function(params, fn) { var cb, data; if (params == null) { diff --git a/src/Models/UserKeys.coffee b/src/Models/UserKeys.coffee new file mode 100644 index 0000000..75a9705 --- /dev/null +++ b/src/Models/UserKeys.coffee @@ -0,0 +1,7 @@ +BaseModel = require '../BaseModel' + +class UserKeys extends BaseModel + all: (userId, fn = null) => + @get "users/#{parseInt userId}/keys", (data) => fn data if fn + +module.exports = (client) -> new UserKeys client diff --git a/src/Models/Users.coffee b/src/Models/Users.coffee index 74d6230..596d4a4 100644 --- a/src/Models/Users.coffee +++ b/src/Models/Users.coffee @@ -1,6 +1,9 @@ BaseModel = require '../BaseModel' class Users extends BaseModel + init: => + @keys = @load 'UserKeys' + all: (params = {}, fn = null) => if 'function' is typeof params fn = params From 080ba8c25da5fb12ab05dee1a27838ac7a620bd1 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Mon, 10 Aug 2015 13:53:41 +0100 Subject: [PATCH 079/135] Added Steve Norman to Contributors list. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6c538b9..e1d9e50 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ Contributors - [huhgawz](https://github.com/huhgawz) - [Connor Weng](https://github.com/ConnorWeng) - [Felix Fichte](https://github.com/spruce) +- [Steve Norman](https://github.com/stevenorman) License ------- From afcac006fee9034a07be9d98929725dc9e57a50d Mon Sep 17 00:00:00 2001 From: Steve Norman Date: Fri, 24 Apr 2015 11:52:49 +0000 Subject: [PATCH 080/135] Added project search functionality --- lib/Models/Projects.js | 22 ++++++++++++++++++++++ src/Models/Projects.coffee | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index a1e9b1c..7102c3b 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -12,6 +12,7 @@ extend(Projects, superClass); function Projects() { + this.search = bind(this.search, this); this.remove = bind(this.remove, this); this.listTags = bind(this.listTags, this); this.listCommits = bind(this.listCommits, this); @@ -200,6 +201,27 @@ })(this)); }; + Projects.prototype.search = function(projectName, params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + if ('function' === typeof params) { + fn = params; + params = {}; + } + this.debug("Projects::search()"); + return this.get("projects/search/" + projectName, params, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + return Projects; })(BaseModel); diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 4e50c5c..515f4e2 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -68,4 +68,12 @@ class Projects extends BaseModel @debug "Projects::remove()" @delete "projects/#{Utils.parseProjectId projectId}", (data) => fn data if fn + search: (projectName, params={}, fn=null) => + if 'function' is typeof params + fn = params + params={} + + @debug "Projects::search()" + @get "projects/search/#{projectName}", params, (data) => fn data if fn + module.exports = (client) -> new Projects client From 792661dad505faa70432a14c6fb320ea037b1cc6 Mon Sep 17 00:00:00 2001 From: Steve Norman Date: Mon, 10 Aug 2015 14:58:15 +0100 Subject: [PATCH 081/135] Reverted version number change --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 05b7095..623cdac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.4.1", + "version": "1.4.0", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 0ecf6ca5fc97070b8306f2d5862441aa580b07e5 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Tue, 11 Aug 2015 08:28:22 +0100 Subject: [PATCH 082/135] Removed sourcegraph badges --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index e1d9e50..6938594 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,6 @@ node-gitlab [![Build Status (Travis)](https://travis-ci.org/node-gitlab/node-gitlab.png?branch=master)](https://travis-ci.org/node-gitlab/node-gitlab) [![Dependency Status](https://david-dm.org/node-gitlab/node-gitlab.png?theme=shields.io)](https://david-dm.org/node-gitlab/node-gitlab) -[![authors](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/badges/authors.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) -[![library users](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/badges/library-users.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) -[![Total views](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/counters/views.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) -[![Views in the last 24 hours](https://sourcegraph.com/api/repos/github.com/node-gitlab/node-gitlab/counters/views-24h.png)](https://sourcegraph.com/github.com/node-gitlab/node-gitlab) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/node-gitlab/node-gitlab/trend.png)](https://bitdeli.com/free "Bitdeli Badge") [![Code Climate](https://codeclimate.com/github/node-gitlab/node-gitlab/badges/gpa.svg)](https://codeclimate.com/github/node-gitlab/node-gitlab) From 6ff5fa6a7024f2e28a0ddbe1b59c9d338faf2f83 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 11 Aug 2015 13:55:49 +0200 Subject: [PATCH 083/135] v1.4.0 --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6938594..a563ffe 100644 --- a/README.md +++ b/README.md @@ -116,10 +116,25 @@ MIT Changelog ========= -1.4.0 (unreleased) +[1.4.0](https://github.com/node-gitlab/node-gitlab/tree/v1.4.0) (2015-08-11) ------------------ -- No entry +- Now using headers for PRIVATE-TOKEN +- Add `Groups.create`, `Groups.addProject` and `Groups.search` methods +- Add `Projects.remove` and `Projects.search` methods +- Add `UserKeys` resource +- Add `Users.search` method +- Rename `ProjectMielstones.get` to `ProjectMilestones.all` +- Handling pagination on multiple new `.all()` methods +- Various stability and performance fixes + +Thanks to [@huhgawz](https://github.com/huhgawz), +[@ConnorWeng](https://github.com/ConnorWeng), [@langma](https://github.com/langma), +[@spruce](https://github.com/spruce), [@stevenorman](https://github.com/stevenorman) +and [@nogs](https://github.com/nogs) + + +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.3.0...develop) [1.3.0](https://github.com/node-gitlab/node-gitlab/tree/v1.3.0) (2015-02-09) ------------------ From 4933c80d05f481269ab6f5dd1666ccf3aeb994eb Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 11 Aug 2015 13:59:15 +0200 Subject: [PATCH 084/135] Post-release version bump --- README.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a563ffe..459383b 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,11 @@ MIT Changelog ========= +1.5.0-dev (unrelease) +--------------------- + +- No entry + [1.4.0](https://github.com/node-gitlab/node-gitlab/tree/v1.4.0) (2015-08-11) ------------------ diff --git a/package.json b/package.json index 623cdac..ceb8649 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.4.0", + "version": "1.5.0-dev", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 574a2c3de114732c8826587f603071097043785d Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 20 Aug 2015 03:45:21 +0200 Subject: [PATCH 085/135] Coffee rebuild --- examples/show-project.js | 8 ++++++ lib/ApiBaseHTTP.js | 8 +----- lib/Models/ProjectMilestones.js | 48 +++++++++++++++++++++++++++------ 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/examples/show-project.js b/examples/show-project.js index c1bea0a..df2f87a 100755 --- a/examples/show-project.js +++ b/examples/show-project.js @@ -26,4 +26,12 @@ return console.log(members); }); + gitlab.projects.milestones.list(projectId, { + per_page: 100 + }, function(milestones) { + console.log(""); + console.log("=== Milestones ==="); + return console.log(milestones); + }); + }).call(this); diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index 807d670..6c65459 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -73,13 +73,7 @@ ApiBaseHTTP.prototype.fn_wrapper = function(fn) { return (function(_this) { return function(err, response, ret) { - var arity, ref; - if (err) { - debug('an error has occured', err); - if ((400 <= (ref = err.statusCode) && ref <= 499)) { - throw "Authorisation error. " + err.statusCode + ". Check your key."; - } - } + var arity; arity = fn.length; switch (arity) { case 1: diff --git a/lib/Models/ProjectMilestones.js b/lib/Models/ProjectMilestones.js index b01231c..8ae0082 100644 --- a/lib/Models/ProjectMilestones.js +++ b/lib/Models/ProjectMilestones.js @@ -9,28 +9,60 @@ Utils = require('../Utils'); ProjectMilestones = (function(superClass) { + var list; + extend(ProjectMilestones, superClass); function ProjectMilestones() { this.update = bind(this.update, this); this.add = bind(this.add, this); this.show = bind(this.show, this); - this.list = bind(this.list, this); + this.all = bind(this.all, this); return ProjectMilestones.__super__.constructor.apply(this, arguments); } - ProjectMilestones.prototype.list = function(projectId, fn) { + list = function(projectId, fn) { if (fn == null) { fn = null; } - this.debug("Projects::milestones()"); - return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/milestones", (function(_this) { - return function(data) { - if (fn) { - return fn(data); + console.log('DEPRECATED: milestone.list. Use milestone.all instead'); + return this.all.apply(this, arguments); + }; + + ProjectMilestones.prototype.all = function(projectId, fn) { + var cb, data, params; + if (fn == null) { + fn = null; + } + this.debug("Projects::Milestones::all()"); + params = {}; + if (params.page == null) { + params.page = 1; + } + if (params.per_page == null) { + params.per_page = 100; + } + data = []; + cb = (function(_this) { + return function(err, retData) { + if (err) { + if (fn) { + return fn(retData || data); + } + } else if (retData.length === params.per_page) { + _this.debug("Recurse Projects::Milestones::all()"); + data = data.concat(retData); + params.page++; + return _this.get("projects/" + (Utils.parseProjectId(projectId)) + "/milestones", params, cb); + } else { + data = data.concat(retData); + if (fn) { + return fn(data); + } } }; - })(this)); + })(this); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/milestones", params, cb); }; ProjectMilestones.prototype.show = function(projectId, milestoneId, fn) { From b7b1a6d95b2b72a6edd1ae0b18efeab7f77548b5 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 20 Aug 2015 03:46:29 +0200 Subject: [PATCH 086/135] v1.4.1 --- README.md | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 459383b..8554a03 100644 --- a/README.md +++ b/README.md @@ -116,10 +116,10 @@ MIT Changelog ========= -1.5.0-dev (unrelease) ---------------------- +1.4.1 (2015-08-11) +------------------ -- No entry +- Coffee rebuild [1.4.0](https://github.com/node-gitlab/node-gitlab/tree/v1.4.0) (2015-08-11) ------------------ diff --git a/package.json b/package.json index ceb8649..05b7095 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.5.0-dev", + "version": "1.4.1", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 0a9c6aeb7c1a473269bae23aa8f7f6191bf0ff14 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 20 Aug 2015 03:48:53 +0200 Subject: [PATCH 087/135] Post-release version bump --- README.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8554a03..b27f6db 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,11 @@ MIT Changelog ========= +1.5.0-dev (unreleased) +---------------------- + +- No entry + 1.4.1 (2015-08-11) ------------------ diff --git a/package.json b/package.json index 05b7095..ceb8649 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.4.1", + "version": "1.5.0-dev", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From e59b2225a42cf20a8202bf9e2f5666cb7b3aa3ba Mon Sep 17 00:00:00 2001 From: pete Date: Sun, 1 Nov 2015 11:44:55 +0000 Subject: [PATCH 088/135] added Project.edit method --- src/Models/Projects.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 515f4e2..8e9314b 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -44,6 +44,10 @@ class Projects extends BaseModel @debug "Projects::create()" @post "projects", params, (data) -> fn data if fn + edit: (projectId, params={}, fn=null) => + @debug "Projects::edit()" + @put "projects/#{Utils.parseProjectId projectId}", params, (data) -> fn data if fn + addMember: (params={}, fn=null) => @debug "Projects::addMember()" @post "projects/#{params.id}/members", params, (data) -> fn data if fn From 8637af9d81c5cadc534b90ec9943bc1aad2cfcbb Mon Sep 17 00:00:00 2001 From: pete Date: Sun, 1 Nov 2015 11:50:01 +0000 Subject: [PATCH 089/135] Rebuilt --- lib/Models/Projects.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index 7102c3b..ef0274f 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -19,6 +19,7 @@ this.listMembers = bind(this.listMembers, this); this.editMember = bind(this.editMember, this); this.addMember = bind(this.addMember, this); + this.edit = bind(this.edit, this); this.create = bind(this.create, this); this.show = bind(this.show, this); this.all = bind(this.all, this); @@ -108,6 +109,21 @@ }); }; + Projects.prototype.edit = function(projectId, params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Projects::edit()"); + return this.put("projects/" + (Utils.parseProjectId(projectId)), params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + Projects.prototype.addMember = function(params, fn) { if (params == null) { params = {}; From 1764fb176a6ef08dc441e772e2aeed5abf424053 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Mon, 2 Nov 2015 08:22:56 +0000 Subject: [PATCH 090/135] Hound CI will now ignore JavaScript as this is built by CoffeeScript compiler --- .hound.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .hound.yml diff --git a/.hound.yml b/.hound.yml new file mode 100644 index 0000000..0564610 --- /dev/null +++ b/.hound.yml @@ -0,0 +1,2 @@ +javascript: + enabled: false From 9e10fd8a85a2fef915524b68f7907b008b92452d Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Mon, 2 Nov 2015 08:24:13 +0000 Subject: [PATCH 091/135] Added Pete Ward to Contributors list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b27f6db..a75d472 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ Contributors - [Connor Weng](https://github.com/ConnorWeng) - [Felix Fichte](https://github.com/spruce) - [Steve Norman](https://github.com/stevenorman) +- [Pete Ward](https://github.com/peteward44) License ------- From b989dd69529d419cd663a8c226486f80b8823a08 Mon Sep 17 00:00:00 2001 From: Pieter Soudan Date: Mon, 2 Nov 2015 23:07:23 +0100 Subject: [PATCH 092/135] add projects.create_for_user; admin function to create new project on behalf of user (#74) --- lib/Models/Projects.js | 16 ++++++++++++++++ src/Models/Projects.coffee | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index ef0274f..dc23466 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -20,6 +20,7 @@ this.editMember = bind(this.editMember, this); this.addMember = bind(this.addMember, this); this.edit = bind(this.edit, this); + this.create_for_user = bind(this.create_for_user, this); this.create = bind(this.create, this); this.show = bind(this.show, this); this.all = bind(this.all, this); @@ -109,6 +110,21 @@ }); }; + Projects.prototype.create_for_user = function(params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Projects::create_for_user()"); + return this.post("projects/user/" + params.user_id, params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + Projects.prototype.edit = function(projectId, params, fn) { if (params == null) { params = {}; diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 8e9314b..017e7cf 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -44,6 +44,10 @@ class Projects extends BaseModel @debug "Projects::create()" @post "projects", params, (data) -> fn data if fn + create_for_user: (params={}, fn=null) => + @debug "Projects::create_for_user()" + @post "projects/user/#{params.user_id}", params, (data) -> fn data if fn + edit: (projectId, params={}, fn=null) => @debug "Projects::edit()" @put "projects/#{Utils.parseProjectId projectId}", params, (data) -> fn data if fn From ce7afb610b40a56edebd219f8c9531b05d949d7f Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Tue, 3 Nov 2015 11:04:30 +0000 Subject: [PATCH 093/135] Added Pieter Soudan to Contributors list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a75d472..e7bed52 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ Contributors - [Felix Fichte](https://github.com/spruce) - [Steve Norman](https://github.com/stevenorman) - [Pete Ward](https://github.com/peteward44) +- [Pieter Soudan](https://github.com/Sewdn) License ------- From 6a6c7af8139f191760d3526f727cdd8c6b634786 Mon Sep 17 00:00:00 2001 From: Ryan Southern Date: Tue, 10 Nov 2015 09:34:23 -0500 Subject: [PATCH 094/135] add ssh key to user --- lib/Models/UserKeys.js | 17 +++++++++++++++++ src/Models/UserKeys.coffee | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/lib/Models/UserKeys.js b/lib/Models/UserKeys.js index a5abc35..5cdb336 100644 --- a/lib/Models/UserKeys.js +++ b/lib/Models/UserKeys.js @@ -10,6 +10,7 @@ extend(UserKeys, superClass); function UserKeys() { + this.addKey = bind(this.addKey, this); this.all = bind(this.all, this); return UserKeys.__super__.constructor.apply(this, arguments); } @@ -27,6 +28,22 @@ })(this)); }; + UserKeys.prototype.addKey = function(userId, title, key, fn) { + var params; + if (fn == null) { + fn = null; + } + params = { + title: title, + key: key + }; + return this.post("users/" + userId + "/keys", params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + return UserKeys; })(BaseModel); diff --git a/src/Models/UserKeys.coffee b/src/Models/UserKeys.coffee index 75a9705..2601614 100644 --- a/src/Models/UserKeys.coffee +++ b/src/Models/UserKeys.coffee @@ -4,4 +4,11 @@ class UserKeys extends BaseModel all: (userId, fn = null) => @get "users/#{parseInt userId}/keys", (data) => fn data if fn + addKey: (userId, title, key, fn = null) => + params = + title: title + key: key + + @post "users/#{userId}/keys", params, (data) -> fn data if fn + module.exports = (client) -> new UserKeys client From 08281b507dcbc910b7ce9c93b39cf071930c2292 Mon Sep 17 00:00:00 2001 From: Ryan Southern Date: Tue, 10 Nov 2015 09:41:35 -0500 Subject: [PATCH 095/135] fixing tab --- src/Models/UserKeys.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/UserKeys.coffee b/src/Models/UserKeys.coffee index 2601614..394de00 100644 --- a/src/Models/UserKeys.coffee +++ b/src/Models/UserKeys.coffee @@ -5,7 +5,7 @@ class UserKeys extends BaseModel @get "users/#{parseInt userId}/keys", (data) => fn data if fn addKey: (userId, title, key, fn = null) => - params = + params = title: title key: key From f1cbf59415122348613b5f2f346b981f80e78968 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Tue, 10 Nov 2015 14:49:15 +0000 Subject: [PATCH 096/135] Added Ryan Southern to Contributors list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e7bed52..7cc36f0 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ Contributors - [Steve Norman](https://github.com/stevenorman) - [Pete Ward](https://github.com/peteward44) - [Pieter Soudan](https://github.com/Sewdn) +- [Ryan Southern](https://github.com/ryansouthern) License ------- From 8af2619b8634ab8c884fe2d3b7e092d1435ca891 Mon Sep 17 00:00:00 2001 From: ZhongyiTong Date: Thu, 26 Nov 2015 18:56:30 +0800 Subject: [PATCH 097/135] 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 098/135] 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 From a3a769b7cdb8eb4a4df81338370d4a21e7b82a92 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 26 Nov 2015 12:18:32 +0100 Subject: [PATCH 099/135] v1.5.0 --- README.md | 21 ++++++++++++++++++--- package.json | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7cc36f0..c9c123d 100644 --- a/README.md +++ b/README.md @@ -119,10 +119,19 @@ MIT Changelog ========= -1.5.0-dev (unreleased) +[1.5.0](https://github.com/node-gitlab/node-gitlab/tree/v1.5.0) (2015-11-26) ---------------------- -- No entry +- Add `Project.edit` +- Add `Projects.create_for_user` +- Add ssh key to user +- Add Projects forks + +Thanks to [@peteward44](https://github.com/peteward44), +[@Sewdn](https://github.com/Sewdn), [@ryansouthern](https://github.com/ryansouthern) +and [@geeeeeeeeek](https://github.com/geeeeeeeeek) + +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.4.1...v1.5.0) 1.4.1 (2015-08-11) ------------------ @@ -147,7 +156,7 @@ Thanks to [@huhgawz](https://github.com/huhgawz), and [@nogs](https://github.com/nogs) -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.3.0...develop) +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.3.0...v1.4.0) [1.3.0](https://github.com/node-gitlab/node-gitlab/tree/v1.3.0) (2015-02-09) ------------------ @@ -159,6 +168,8 @@ and [@nogs](https://github.com/nogs) - Added tests - Code cleanup and various small improvements +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.2.0...v1.3.0) + [1.2.0](https://github.com/node-gitlab/node-gitlab/tree/v1.2.0) (2014-12-24) ------------------ @@ -168,6 +179,8 @@ and [@nogs](https://github.com/nogs) - Changed AddHook parameters - Happy Christmas +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.1.0...v1.2.0) + [1.1.0](https://github.com/node-gitlab/node-gitlab/tree/v1.1.0) (2014-11-04) ------------------ @@ -176,6 +189,8 @@ and [@nogs](https://github.com/nogs) - Improved global error handling - Rebuilt javascript using latest Coffee-Script +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.0.0...v1.1.0) + [1.0.0](https://github.com/node-gitlab/node-gitlab/tree/v1.0.0) (2014-08-19) ------------------ diff --git a/package.json b/package.json index ceb8649..f3c2af2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.5.0-dev", + "version": "1.5.0", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 2399a33670a1c977b773a03e9b5951dbcb46f410 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 26 Nov 2015 14:14:08 +0100 Subject: [PATCH 100/135] Post-release version bump --- README.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c9c123d..c8e8702 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,11 @@ MIT Changelog ========= +master (unreleased) +------------------- + +- No entry + [1.5.0](https://github.com/node-gitlab/node-gitlab/tree/v1.5.0) (2015-11-26) ---------------------- diff --git a/package.json b/package.json index f3c2af2..5037cb6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.5.0", + "version": "1.5.0+", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 8bd402e0bb498505cd0c3c2f52a76f93f804a7be Mon Sep 17 00:00:00 2001 From: ZhongyiTong Date: Sat, 28 Nov 2015 15:31:44 +0800 Subject: [PATCH 101/135] Fix undefined assigneeId in merge request. See issue #111. --- lib/Models/ProjectMergeRequests.js | 4 +++- src/Models/ProjectMergeRequests.coffee | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Models/ProjectMergeRequests.js b/lib/Models/ProjectMergeRequests.js index edfab59..6bedc55 100644 --- a/lib/Models/ProjectMergeRequests.js +++ b/lib/Models/ProjectMergeRequests.js @@ -71,9 +71,11 @@ id: Utils.parseProjectId(projectId), source_branch: sourceBranch, target_branch: targetBranch, - assignee_id: parseInt(assigneeId), title: title }; + if (assigneeId !== void 0) { + params.assigneeId = parseInt(assigneeId); + } return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/merge_requests", params, (function(_this) { return function(data) { if (fn) { diff --git a/src/Models/ProjectMergeRequests.coffee b/src/Models/ProjectMergeRequests.coffee index 067fbc8..3229f05 100644 --- a/src/Models/ProjectMergeRequests.coffee +++ b/src/Models/ProjectMergeRequests.coffee @@ -23,8 +23,8 @@ class ProjectMergeRequests extends BaseModel id: Utils.parseProjectId projectId source_branch: sourceBranch target_branch: targetBranch - assignee_id: parseInt assigneeId title: title + params.assigneeId = parseInt assigneeId unless assigneeId is undefined @post "projects/#{Utils.parseProjectId projectId}/merge_requests", params, (data) => fn data if fn update: (projectId, mergerequestId, params, fn = null) => From 9c2618132002234d3bc165e1e9597fd2e5d98d06 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Sat, 28 Nov 2015 12:37:58 +0000 Subject: [PATCH 102/135] Update package.json Bump unreleased version to 1.5.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5037cb6..e21bab2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.5.0+", + "version": "1.5.1", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 2eb1f20c4eba041c03461574e395dd755128f1c0 Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Sat, 28 Nov 2015 12:41:32 +0000 Subject: [PATCH 103/135] Added Zhongyi Tong to Contributors list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c8e8702..d7a194a 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ Contributors - [Pete Ward](https://github.com/peteward44) - [Pieter Soudan](https://github.com/Sewdn) - [Ryan Southern](https://github.com/ryansouthern) +- [Zhongyi Tong](https://github.com/geeeeeeeeek) License ------- From 07f6a3e48b78ede4f0c3e45e08714c7ef4dbe674 Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 16 Dec 2015 17:32:25 -0500 Subject: [PATCH 104/135] Added support for the gitlab services api --- examples/create-service.coffee | 27 ++++++++++++ examples/create-service.js | 31 ++++++++++++++ examples/delete-service.coffee | 23 ++++++++++ examples/delete-service.js | 25 +++++++++++ examples/show-service.coffee | 21 +++++++++ examples/show-service.js | 25 +++++++++++ lib/Models/ProjectServices.js | 71 +++++++++++++++++++++++++++++++ lib/Models/Projects.js | 3 +- src/Models/ProjectServices.coffee | 18 ++++++++ src/Models/Projects.coffee | 1 + 10 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 examples/create-service.coffee create mode 100644 examples/create-service.js create mode 100644 examples/delete-service.coffee create mode 100644 examples/delete-service.js create mode 100644 examples/show-service.coffee create mode 100644 examples/show-service.js create mode 100644 lib/Models/ProjectServices.js create mode 100644 src/Models/ProjectServices.coffee diff --git a/examples/create-service.coffee b/examples/create-service.coffee new file mode 100644 index 0000000..c141a44 --- /dev/null +++ b/examples/create-service.coffee @@ -0,0 +1,27 @@ +#!/usr/bin/env coffee + +# clear terminal +process.stdout.write '\u001B[2J\u001B[0;0f' + + +Gitlab = require('..') + +credentials = require './credentials' + +gitlab = new Gitlab + url: credentials.url + token: credentials.token + +projectId = parseInt process.argv[2] +serviceName = process.argv[3] +serviceParams = + webhook: process.argv[4] + username: process.argv[5] + channel: process.argv[6] + + + +gitlab.projects.services.update projectId, serviceName, serviceParams, (service) -> + console.log + console.log "=== Service ===" + console.log service diff --git a/examples/create-service.js b/examples/create-service.js new file mode 100644 index 0000000..6ae516e --- /dev/null +++ b/examples/create-service.js @@ -0,0 +1,31 @@ +(function() { + var Gitlab, credentials, gitlab, projectId, serviceName, serviceParams; + + process.stdout.write('\u001B[2J\u001B[0;0f'); + + Gitlab = require('..'); + + credentials = require('./credentials'); + + gitlab = new Gitlab({ + url: credentials.url, + token: credentials.token + }); + + projectId = parseInt(process.argv[2]); + + serviceName = process.argv[3]; + + serviceParams = { + webhook: process.argv[4], + username: process.argv[5], + channel: process.argv[6] + }; + + gitlab.projects.services.update(projectId, serviceName, serviceParams, function(service) { + console.log; + console.log("=== Service ==="); + return console.log(service); + }); + +}).call(this); diff --git a/examples/delete-service.coffee b/examples/delete-service.coffee new file mode 100644 index 0000000..25abe3d --- /dev/null +++ b/examples/delete-service.coffee @@ -0,0 +1,23 @@ +#!/usr/bin/env coffee + +# clear terminal +process.stdout.write '\u001B[2J\u001B[0;0f' + + +Gitlab = require('..') + +credentials = require './credentials' + +gitlab = new Gitlab + url: credentials.url + token: credentials.token + +projectId = parseInt process.argv[2] +serviceName = process.argv[3] + + + +gitlab.projects.services.remove projectId, serviceName, (service) -> + console.log + console.log "=== Service ===" + console.log service diff --git a/examples/delete-service.js b/examples/delete-service.js new file mode 100644 index 0000000..57364e7 --- /dev/null +++ b/examples/delete-service.js @@ -0,0 +1,25 @@ +(function() { + var Gitlab, credentials, gitlab, projectId, serviceName; + + process.stdout.write('\u001B[2J\u001B[0;0f'); + + Gitlab = require('..'); + + credentials = require('./credentials'); + + gitlab = new Gitlab({ + url: credentials.url, + token: credentials.token + }); + + projectId = parseInt(process.argv[2]); + + serviceName = process.argv[3]; + + gitlab.projects.services.remove(projectId, serviceName, function(service) { + console.log; + console.log("=== Service ==="); + return console.log(service); + }); + +}).call(this); diff --git a/examples/show-service.coffee b/examples/show-service.coffee new file mode 100644 index 0000000..ebbe7d2 --- /dev/null +++ b/examples/show-service.coffee @@ -0,0 +1,21 @@ +#!/usr/bin/env coffee + +# clear terminal +process.stdout.write '\u001B[2J\u001B[0;0f' + + +Gitlab = require('..') + +credentials = require './credentials' + +gitlab = new Gitlab + url: credentials.url + token: credentials.token + +projectId = parseInt process.argv[2] +serviceName = process.argv[3] + +gitlab.projects.services.show projectId, serviceName, (service) -> + console.log + console.log "=== Service ===" + console.log service diff --git a/examples/show-service.js b/examples/show-service.js new file mode 100644 index 0000000..c73c096 --- /dev/null +++ b/examples/show-service.js @@ -0,0 +1,25 @@ +(function() { + var Gitlab, credentials, gitlab, projectId, serviceName; + + process.stdout.write('\u001B[2J\u001B[0;0f'); + + Gitlab = require('..'); + + credentials = require('./credentials'); + + gitlab = new Gitlab({ + url: credentials.url, + token: credentials.token + }); + + projectId = parseInt(process.argv[2]); + + serviceName = process.argv[3]; + + gitlab.projects.services.show(projectId, serviceName, function(service) { + console.log; + console.log("=== Service ==="); + return console.log(service); + }); + +}).call(this); diff --git a/lib/Models/ProjectServices.js b/lib/Models/ProjectServices.js new file mode 100644 index 0000000..846733c --- /dev/null +++ b/lib/Models/ProjectServices.js @@ -0,0 +1,71 @@ +(function() { + var BaseModel, ProjectServices, Utils, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + BaseModel = require('../BaseModel'); + + Utils = require('../Utils'); + + ProjectServices = (function(superClass) { + extend(ProjectServices, superClass); + + function ProjectServices() { + this.remove = bind(this.remove, this); + this.update = bind(this.update, this); + this.show = bind(this.show, this); + return ProjectServices.__super__.constructor.apply(this, arguments); + } + + ProjectServices.prototype.show = function(projectId, serviceName, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::showService()"); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/services/" + serviceName, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + ProjectServices.prototype.update = function(projectId, serviceName, params, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::updateService()"); + return this.put("projects/" + (Utils.parseProjectId(projectId)) + "/services/" + serviceName, params, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + ProjectServices.prototype.remove = function(projectId, serviceName, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects:removeService()"); + return this["delete"]("projects/" + (Utils.parseProjectId(projectId)) + "/services/" + serviceName, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + return ProjectServices; + + })(BaseModel); + + module.exports = function(client) { + return new ProjectServices(client); + }; + +}).call(this); diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index bf00e1e..5223043 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -37,7 +37,8 @@ this.repository = this.load('ProjectRepository'); this.milestones = this.load('ProjectMilestones'); this.deploy_keys = this.load('ProjectDeployKeys'); - return this.merge_requests = this.load('ProjectMergeRequests'); + this.merge_requests = this.load('ProjectMergeRequests'); + return this.services = this.load('ProjectServices'); }; Projects.prototype.all = function(params, fn) { diff --git a/src/Models/ProjectServices.coffee b/src/Models/ProjectServices.coffee new file mode 100644 index 0000000..551af7a --- /dev/null +++ b/src/Models/ProjectServices.coffee @@ -0,0 +1,18 @@ +BaseModel = require '../BaseModel' +Utils = require '../Utils' + +class ProjectServices extends BaseModel + + show: (projectId, serviceName, fn = null) => + @debug "Projects::showService()" + @get "projects/#{Utils.parseProjectId projectId}/services/#{serviceName}", (data) => fn data if fn + + update: (projectId, serviceName, params, fn = null) => + @debug "Projects::updateService()" + @put "projects/#{Utils.parseProjectId projectId}/services/#{serviceName}", params, (data) => fn data if fn + + remove: (projectId, serviceName, fn = null) => + @debug "Projects:removeService()" + @delete "projects/#{Utils.parseProjectId projectId}/services/#{serviceName}", (data) => fn data if fn + +module.exports = (client) -> new ProjectServices client diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 573c8f1..5c2dde1 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -11,6 +11,7 @@ class Projects extends BaseModel @milestones = @load 'ProjectMilestones' @deploy_keys = @load 'ProjectDeployKeys' @merge_requests = @load 'ProjectMergeRequests' + @services = @load 'ProjectServices' all: (params={}, fn=null) => if 'function' is typeof params From f79ff9e5563f092aaf429af943d70daf813444dc Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Thu, 17 Dec 2015 08:12:19 +0000 Subject: [PATCH 105/135] Added mrawdon to Contributors list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d7a194a..52f6d48 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ Contributors - [Pieter Soudan](https://github.com/Sewdn) - [Ryan Southern](https://github.com/ryansouthern) - [Zhongyi Tong](https://github.com/geeeeeeeeek) +- [mrawdon](https://github.com/mrawdon) License ------- From 91d7237ef6d7a204c040bd5154c7492a6dc360c1 Mon Sep 17 00:00:00 2001 From: Cyril Feraudet Date: Thu, 31 Dec 2015 10:18:40 +0100 Subject: [PATCH 106/135] Add possibility to showFile by sha id --- lib/Models/ProjectRepository.js | 8 ++++++++ src/Models/ProjectRepository.coffee | 2 ++ 2 files changed, 10 insertions(+) diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 8384838..a516924 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -215,6 +215,14 @@ } }; })(this)); + } else if (params.file_path && params.file_id) { + return this.get(("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/raw_blobs/") + params.file_id, params, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); } }; diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index b955dc0..423d9cc 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -65,6 +65,8 @@ class ProjectRepository extends BaseModel @debug "Projects::showFile()", params if params.file_path and params.ref @get "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn + else if params.file_path and params.file_id + @get "projects/#{Utils.parseProjectId params.projectId}/repository/raw_blobs/" + params.file_id, params, (data) => fn data if fn createFile: (params = {}, fn = null) => @debug "Projects::createFile()", params From 2e547cb94ba8dfa3d6c648f9526083fd2e65ccc4 Mon Sep 17 00:00:00 2001 From: "Marcus M. Darden" Date: Sun, 31 Jan 2016 23:28:12 -0500 Subject: [PATCH 107/135] Add oauth_token option to authenticate connection The GitLab spec allows authentication with the private_token or oauth bearer token. This modification accepts the oauth_token parameter for connection, and puts the token into the headers if it is supplied. Docs: https://gitlab.eecs.umich.edu/help/api/README.md#authentication-with-oauth2-token --- lib/ApiBaseHTTP.js | 16 +++++++++++----- src/ApiBaseHTTP.coffee | 9 ++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/ApiBaseHTTP.js b/lib/ApiBaseHTTP.js index 6c65459..b9c30e8 100644 --- a/lib/ApiBaseHTTP.js +++ b/lib/ApiBaseHTTP.js @@ -37,8 +37,8 @@ if (!this.options.url) { throw "`url` is mandatory"; } - if (!this.options.token) { - throw "`private_token` is mandatory"; + if (!(this.options.token || this.options.oauth_token)) { + throw "`private_token` or `oauth_token` is mandatory"; } if ((base1 = this.options).slumber == null) { base1.slumber = {}; @@ -64,9 +64,15 @@ if (opts.__query == null) { opts.__query = {}; } - opts.headers = { - 'PRIVATE-TOKEN': this.options.token - }; + if (this.options.token) { + opts.headers = { + 'PRIVATE-TOKEN': this.options.token + }; + } else { + opts.headers = { + 'Authorization': 'Bearer ' + this.options.oauth_token + }; + } return opts; }; diff --git a/src/ApiBaseHTTP.coffee b/src/ApiBaseHTTP.coffee index 9948f81..ace87a7 100644 --- a/src/ApiBaseHTTP.coffee +++ b/src/ApiBaseHTTP.coffee @@ -12,8 +12,8 @@ class module.exports.ApiBaseHTTP extends ApiBase unless @options.url throw "`url` is mandatory" - unless @options.token - throw "`private_token` is mandatory" + unless @options.token or @options.oauth_token + throw "`private_token` or `oauth_token` is mandatory" @options.slumber ?= {} @options.slumber.append_slash ?= false @@ -32,7 +32,10 @@ class module.exports.ApiBaseHTTP extends ApiBase prepare_opts: (opts) => opts.__query ?= {} - opts.headers = { 'PRIVATE-TOKEN': @options.token } + if @options.token + opts.headers = { 'PRIVATE-TOKEN': @options.token } + else + opts.headers = { 'Authorization': 'Bearer ' + @options.oauth_token } return opts fn_wrapper: (fn) => From da948b827f63b789ac815c6fbbab6ef23831ec0e Mon Sep 17 00:00:00 2001 From: Dave Irvine Date: Tue, 2 Feb 2016 08:33:58 +0000 Subject: [PATCH 108/135] Added Marcus Darden to Contributors list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 52f6d48..dbf6ab5 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ Contributors - [Ryan Southern](https://github.com/ryansouthern) - [Zhongyi Tong](https://github.com/geeeeeeeeek) - [mrawdon](https://github.com/mrawdon) +- [Marcus M. Darden](https://github.com/marcus-darden) License ------- From 47828c3461a90bbeb638eefb9da38cf6a3695e70 Mon Sep 17 00:00:00 2001 From: Philipp Hess Date: Fri, 29 Apr 2016 11:26:48 +0200 Subject: [PATCH 109/135] Add function to query all projects as admin feat: add function to query all projects as admin Add function to query all projects as admin --- lib/Models/Projects.js | 43 ++++++++++++++++++++++++++++++++++++++ src/Models/Projects.coffee | 24 +++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index 5223043..5107284 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -25,6 +25,7 @@ this.create = bind(this.create, this); this.show = bind(this.show, this); this.all = bind(this.all, this); + this.allAdmin = bind(this.allAdmin, this); this.init = bind(this.init, this); return Projects.__super__.constructor.apply(this, arguments); } @@ -83,6 +84,48 @@ return this.get("projects", params, cb); }; + Projects.prototype.allAdmin = function(params, fn) { + var cb, data; + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + if ('function' === typeof params) { + fn = params; + params = {}; + } + this.debug("Projects::allAdmin()"); + if (params.page == null) { + params.page = 1; + } + if (params.per_page == null) { + params.per_page = 100; + } + data = []; + cb = (function(_this) { + return function(err, retData) { + if (err) { + if (fn) { + return fn(retData || data); + } + } else if (retData.length === params.per_page) { + _this.debug("Recurse Projects::allAdmin()"); + data = data.concat(retData); + params.page++; + return _this.get("projects/all", params, cb); + } else { + data = data.concat(retData); + if (fn) { + return fn(data); + } + } + }; + })(this); + return this.get("projects/all", params, cb); + }; + Projects.prototype.show = function(projectId, fn) { if (fn == null) { fn = null; diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 5c2dde1..649c2a5 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -37,6 +37,30 @@ class Projects extends BaseModel @get "projects", params, cb + allAdmin: (params={}, fn=null) => + if 'function' is typeof params + fn = params + params={} + @debug "Projects::allAdmin()" + + params.page ?= 1 + params.per_page ?= 100 + + data = [] + cb = (err, retData) => + if err + return fn(retData || data) if fn + else if retData.length == params.per_page + @debug "Recurse Projects::allAdmin()" + data = data.concat(retData) + params.page++ + return @get "projects/all", params, cb + else + data = data.concat(retData) + return fn data if fn + + @get "projects/all", params, cb + show: (projectId, fn=null) => @debug "Projects::show()" @get "projects/#{Utils.parseProjectId projectId}", (data) => fn data if fn From 98c21f79bc3eaad08e53207fcc34ba2219b99b99 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 10 May 2016 18:06:24 +0200 Subject: [PATCH 110/135] v1.6.0 --- README.md | 10 +++++++--- package.json | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dbf6ab5..d8bb527 100644 --- a/README.md +++ b/README.md @@ -122,10 +122,14 @@ MIT Changelog ========= -master (unreleased) -------------------- +[1.6.0](https://github.com/node-gitlab/node-gitlab/tree/v1.6.0) (2016-05-10) +---------------------- -- No entry +- Add function to query all projects as admin +- Add oauth_token option to authenticate connection +- Add possibility to showFile by sha id +- Add support for the GitLab services API +- Fix undefined assigneeId in merge request (#111) [1.5.0](https://github.com/node-gitlab/node-gitlab/tree/v1.5.0) (2015-11-26) ---------------------- diff --git a/package.json b/package.json index e21bab2..3b3c43c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.5.1", + "version": "1.6.0", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 3b5a7ffd82fd2ca3946ca4093118e49c0df83168 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 10 May 2016 18:12:14 +0200 Subject: [PATCH 111/135] Post-release version bump --- README.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d8bb527..1e4070c 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,11 @@ MIT Changelog ========= +master (unreleased) +------------------- + +- No entry + [1.6.0](https://github.com/node-gitlab/node-gitlab/tree/v1.6.0) (2016-05-10) ---------------------- diff --git a/package.json b/package.json index 3b3c43c..6309dec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.6.0", + "version": "1.6.0+dev", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 15af2c4f1bd17eae97fa5e81a051d9ced8477cc3 Mon Sep 17 00:00:00 2001 From: Hutson Betts Date: Fri, 13 May 2016 21:58:35 -0500 Subject: [PATCH 112/135] Add support for adding a tag to a project. --- lib/Models/ProjectRepository.js | 18 ++++++++++++++++++ lib/Models/Projects.js | 2 +- src/Models/ProjectRepository.coffee | 4 ++++ tests/ProjectRepository.test.coffee | 17 ++++++++++++++++- tests/ProjectRepository.test.js | 16 ++++++++++++++++ tests/test.coffee | 11 +++++++++++ tests/test.js | 15 +++++++++++++++ 7 files changed, 81 insertions(+), 2 deletions(-) diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index a516924..86542da 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -20,6 +20,7 @@ this.showCommit = bind(this.showCommit, this); this.listCommits = bind(this.listCommits, this); this.listTags = bind(this.listTags, this); + this.addTag = bind(this.addTag, this); this.deleteBranch = bind(this.deleteBranch, this); this.createBranch = bind(this.createBranch, this); this.unprotectBranch = bind(this.unprotectBranch, this); @@ -116,6 +117,23 @@ })(this)); }; + ProjectRepository.prototype.addTag = function(params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Projects::addTag()"); + return this.post("projects/" + (Utils.parseProjectId(params.id)) + "/repository/tags", params, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + ProjectRepository.prototype.listTags = function(projectId, fn) { if (fn == null) { fn = null; diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index 5107284..a91bdf0 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -24,8 +24,8 @@ this.create_for_user = bind(this.create_for_user, this); this.create = bind(this.create, this); this.show = bind(this.show, this); - this.all = bind(this.all, this); this.allAdmin = bind(this.allAdmin, this); + this.all = bind(this.all, this); this.init = bind(this.init, this); return Projects.__super__.constructor.apply(this, arguments); } diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index 423d9cc..26fba26 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -29,6 +29,10 @@ class ProjectRepository extends BaseModel @delete "projects/#{Utils.parseProjectId projectId}/repository/branches/#{encodeURI branchId}", (data) => fn data if fn # === Tags + addTag: (params = {}, fn = null) => + @debug "Projects::addTag()" + @post "projects/#{Utils.parseProjectId params.id}/repository/tags", params, (data) => fn data if fn + listTags: (projectId, fn = null) => @debug "Projects::listTags()" @get "projects/#{Utils.parseProjectId projectId}/repository/tags", (data) => fn data if fn diff --git a/tests/ProjectRepository.test.coffee b/tests/ProjectRepository.test.coffee index 49dfd9f..a1ab87d 100644 --- a/tests/ProjectRepository.test.coffee +++ b/tests/ProjectRepository.test.coffee @@ -38,6 +38,21 @@ describe "ProjectRepository", -> getStub.restore() expect(getStub).to.have.been.called + describe "addTag()", -> + it "should use POST verb", -> + postStub = sinon.stub repository, "post" + + opts = + id: 1, + tag_name: "v1.0.0", + ref: "2695effb5807a22ff3d138d593fd856244e155e7", + message: "Annotated message", + release_description: "Release description" + repository.addTag opts + + postStub.restore() + expect(postStub).to.have.been.called + describe "listTags()", -> it "should use GET verb", -> getStub = sinon.stub repository, "get" @@ -66,4 +81,4 @@ describe "ProjectRepository", -> } getStub.restore() - expect(getStub).to.have.been.called \ No newline at end of file + expect(getStub).to.have.been.called diff --git a/tests/ProjectRepository.test.js b/tests/ProjectRepository.test.js index 8d1db80..692deb7 100644 --- a/tests/ProjectRepository.test.js +++ b/tests/ProjectRepository.test.js @@ -43,6 +43,22 @@ return expect(getStub).to.have.been.called; }); }); + describe("addTag()", function() { + return it("should use POST verb", function() { + var opts, postStub; + postStub = sinon.stub(repository, "post"); + opts = { + id: 1, + tag_name: "v1.0.0", + ref: "2695effb5807a22ff3d138d593fd856244e155e7", + message: "Annotated message", + release_description: "Release description" + }; + repository.addTag(opts); + postStub.restore(); + return expect(postStub).to.have.been.called; + }); + }); describe("listTags()", function() { return it("should use GET verb", function() { var getStub; diff --git a/tests/test.coffee b/tests/test.coffee index f2b90ae..473b3e7 100644 --- a/tests/test.coffee +++ b/tests/test.coffee @@ -89,6 +89,17 @@ describe 'Project', -> gitlab.projects.repository.listCommits projectId, (result) -> done() + describe '#addTag()', -> + it 'should add a tag to a given project', (done) -> + opts = + id: projectId, + tag_name: "v1.0.0", + ref: "2695effb5807a22ff3d138d593fd856244e155e7", + message: "Annotated message", + release_description: "Release description" + gitlab.projects.repository.addTag opts, (result) -> + done() + describe '#listTags()', -> it 'should retrieve tags of a given project', (done) -> gitlab.projects.repository.listTags projectId, (result) -> diff --git a/tests/test.js b/tests/test.js index 71368c4..699c1c4 100644 --- a/tests/test.js +++ b/tests/test.js @@ -122,6 +122,21 @@ }); }); }); + describe('#addTag()', function() { + return it('should add a tag to a given project', function(done) { + var opts; + opts = { + id: projectId, + tag_name: "v1.0.0", + ref: "2695effb5807a22ff3d138d593fd856244e155e7", + message: "Annotated message", + release_description: "Release description" + }; + return gitlab.projects.repository.addTag(opts, function(result) { + return done(); + }); + }); + }); describe('#listTags()', function() { return it('should retrieve tags of a given project', function(done) { return gitlab.projects.repository.listTags(projectId, function(result) { From 93bc64f8d9f543882ac29ea1da2e98e2b8d0694d Mon Sep 17 00:00:00 2001 From: ls6s Date: Fri, 27 May 2016 10:29:31 +0800 Subject: [PATCH 113/135] add gitlab.projects.repository.compare --- src/Models/ProjectRepository.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index 26fba26..b936b7f 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -80,6 +80,10 @@ class ProjectRepository extends BaseModel @debug "Projects::updateFile()", params @put "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn + compare: (params = {}, fn = null) => + @debug "Projects::compare()", params + @get "projects/#{Utils.parseProjectId params.projectId}/repository/compare", params, (data) => fn data if fn + ## TODO: # - Raw file content # - Raw blob content From 7f24f4e1f133ad1e0f15002890803b2e0b275f1b Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Fri, 27 May 2016 11:46:21 +0200 Subject: [PATCH 114/135] Rebuild js --- lib/Models/ProjectRepository.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 86542da..0c03ba8 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -12,6 +12,7 @@ extend(ProjectRepository, superClass); function ProjectRepository() { + this.compare = bind(this.compare, this); this.updateFile = bind(this.updateFile, this); this.createFile = bind(this.createFile, this); this.showFile = bind(this.showFile, this); @@ -278,6 +279,23 @@ })(this)); }; + ProjectRepository.prototype.compare = function(params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Projects::compare()", params); + return this.get("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/compare", params, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + return ProjectRepository; })(BaseModel); From 377858e88028a4cf6e1a89498c76da4151e81954 Mon Sep 17 00:00:00 2001 From: vvvsrx Date: Fri, 3 Jun 2016 17:08:34 +0800 Subject: [PATCH 115/135] Add support for portion builds api --- lib/Models/ProjectBuilds.js | 74 +++++++++++++++++++++++++++++++++ lib/Models/Projects.js | 18 +++++++- src/Models/ProjectBuilds.coffee | 19 +++++++++ src/Models/Projects.coffee | 5 +++ 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 lib/Models/ProjectBuilds.js create mode 100644 src/Models/ProjectBuilds.coffee diff --git a/lib/Models/ProjectBuilds.js b/lib/Models/ProjectBuilds.js new file mode 100644 index 0000000..21b0cd1 --- /dev/null +++ b/lib/Models/ProjectBuilds.js @@ -0,0 +1,74 @@ +(function() { + var BaseModel, ProjectBuilds, Utils, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + BaseModel = require('../BaseModel'); + + Utils = require('../Utils'); + + ProjectBuilds = (function(superClass) { + extend(ProjectBuilds, superClass); + + function ProjectBuilds() { + this.triggerBuild = bind(this.triggerBuild, this); + this.showBuild = bind(this.showBuild, this); + this.listBuilds = bind(this.listBuilds, this); + return ProjectBuilds.__super__.constructor.apply(this, arguments); + } + + ProjectBuilds.prototype.listBuilds = function(projectId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::listBuilds()"); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/builds", (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + ProjectBuilds.prototype.showBuild = function(projectId, buildId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::build()"); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/builds/" + buildId, null, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + ProjectBuilds.prototype.triggerBuild = function(params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Projects::triggerBuild()"); + return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/trigger/builds", params, null, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + return ProjectBuilds; + + })(BaseModel); + + module.exports = function(client) { + return new ProjectBuilds(client); + }; + +}).call(this); diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index a91bdf0..2799dc8 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -12,6 +12,7 @@ extend(Projects, superClass); function Projects() { + this.listTriggers = bind(this.listTriggers, this); this.search = bind(this.search, this); this.fork = bind(this.fork, this); this.remove = bind(this.remove, this); @@ -39,7 +40,8 @@ this.milestones = this.load('ProjectMilestones'); this.deploy_keys = this.load('ProjectDeployKeys'); this.merge_requests = this.load('ProjectMergeRequests'); - return this.services = this.load('ProjectServices'); + this.services = this.load('ProjectServices'); + return this.builds = this.load('ProjectBuilds'); }; Projects.prototype.all = function(params, fn) { @@ -314,6 +316,20 @@ })(this)); }; + Projects.prototype.listTriggers = function(projectId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::listTriggers()"); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/triggers", (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + return Projects; })(BaseModel); diff --git a/src/Models/ProjectBuilds.coffee b/src/Models/ProjectBuilds.coffee new file mode 100644 index 0000000..e482f54 --- /dev/null +++ b/src/Models/ProjectBuilds.coffee @@ -0,0 +1,19 @@ +BaseModel = require '../BaseModel' +Utils = require '../Utils' + +class ProjectBuilds extends BaseModel + + # === Builds + listBuilds: (projectId, fn = null) => + @debug "Projects::listBuilds()" + @get "projects/#{Utils.parseProjectId projectId}/builds", (data) => fn data if fn + + showBuild: (projectId, buildId, fn = null) => + @debug "Projects::build()" + @get "projects/#{Utils.parseProjectId projectId}/builds/#{buildId}", null, (data) => fn data if fn + + triggerBuild: (params={}, fn = null) => + @debug "Projects::triggerBuild()" + @post "projects/#{Utils.parseProjectId params.projectId}/trigger/builds", params, null, (data) => fn data if fn + +module.exports = (client) -> new ProjectBuilds client diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 649c2a5..8bcd26f 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -12,6 +12,7 @@ class Projects extends BaseModel @deploy_keys = @load 'ProjectDeployKeys' @merge_requests = @load 'ProjectMergeRequests' @services = @load 'ProjectServices' + @builds = @load 'ProjectBuilds' all: (params={}, fn=null) => if 'function' is typeof params @@ -113,4 +114,8 @@ class Projects extends BaseModel @debug "Projects::search()" @get "projects/search/#{projectName}", params, (data) => fn data if fn + listTriggers: (projectId, fn = null) => + @debug "Projects::listTriggers()" + @get "projects/#{Utils.parseProjectId projectId}/triggers", (data) => fn data if fn + module.exports = (client) -> new Projects client From d90f562dedbd851184374498c519fdd4faaa1c6e Mon Sep 17 00:00:00 2001 From: Josh Shaw Date: Fri, 8 Jul 2016 13:14:09 +1200 Subject: [PATCH 116/135] set slumber version to non breaking --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6309dec..7483a5e 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "debug": "*", - "slumber": ">=0.7.0" + "slumber": "0.9.0" }, "devDependencies": { "coffee-script": ">=1.9.1", From fe1b4b1e7288384babd275870a0b87b5be826061 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 11 Jul 2016 23:21:52 +0200 Subject: [PATCH 117/135] v1.7.0 --- README.md | 14 +++++++++++--- package.json | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1e4070c..2045fa4 100644 --- a/README.md +++ b/README.md @@ -122,10 +122,16 @@ MIT Changelog ========= -master (unreleased) -------------------- +[1.7.0](https://github.com/node-gitlab/node-gitlab/tree/v1.7.0) (2016-07-11) +---------------------- + +- Add support for adding a tag to a project +- Add gitlab.projects.repository.compare() +- Add support for portion builds API +- Set slumber version to non-breaking + +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.6.0...v1.7.0) -- No entry [1.6.0](https://github.com/node-gitlab/node-gitlab/tree/v1.6.0) (2016-05-10) ---------------------- @@ -136,6 +142,8 @@ master (unreleased) - Add support for the GitLab services API - Fix undefined assigneeId in merge request (#111) +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.5.0...v1.6.0) + [1.5.0](https://github.com/node-gitlab/node-gitlab/tree/v1.5.0) (2015-11-26) ---------------------- diff --git a/package.json b/package.json index 7483a5e..1dac0ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.6.0+dev", + "version": "1.7.0", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From b2fa781d26e1e312efdee734d0beb5c7d3c27a77 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 11 Jul 2016 23:23:11 +0200 Subject: [PATCH 118/135] Post-release version bump --- README.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2045fa4..99ea896 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,11 @@ MIT Changelog ========= +master (unreleased) +------------------- + +- No entry + [1.7.0](https://github.com/node-gitlab/node-gitlab/tree/v1.7.0) (2016-07-11) ---------------------- diff --git a/package.json b/package.json index 1dac0ca..bf1e6dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.7.0", + "version": "1.7.0+dev", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 2a16328607f2deeb1fb4f3b1ddeb103bfbca1a4e Mon Sep 17 00:00:00 2001 From: Liu Weifeng Date: Sat, 30 Jul 2016 17:14:39 +0800 Subject: [PATCH 119/135] add `addTag` API --- lib/Models/ProjectRepository.js | 15 +++++++++++++++ src/Models/ProjectRepository.coffee | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index 0c03ba8..dec8714 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -21,6 +21,7 @@ this.showCommit = bind(this.showCommit, this); this.listCommits = bind(this.listCommits, this); this.listTags = bind(this.listTags, this); + this.showTag = bind(this.showTag, this); this.addTag = bind(this.addTag, this); this.deleteBranch = bind(this.deleteBranch, this); this.createBranch = bind(this.createBranch, this); @@ -135,6 +136,20 @@ })(this)); }; + ProjectRepository.prototype.showTag = function(projectId, tagName, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::showTag()"); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/repository/tags/" + (encodeURI(tagName)), (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + ProjectRepository.prototype.listTags = function(projectId, fn) { if (fn == null) { fn = null; diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index b936b7f..1643dbe 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -33,6 +33,10 @@ class ProjectRepository extends BaseModel @debug "Projects::addTag()" @post "projects/#{Utils.parseProjectId params.id}/repository/tags", params, (data) => fn data if fn + showTag: (projectId, tagName, fn = null) => + @debug "Projects::showTag()" + @get "projects/#{Utils.parseProjectId projectId}/repository/tags/#{encodeURI tagName}", (data) => fn data if fn + listTags: (projectId, fn = null) => @debug "Projects::listTags()" @get "projects/#{Utils.parseProjectId projectId}/repository/tags", (data) => fn data if fn From caefbaea07adbbaec1b5a110e1455182c6c340b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=9D=92=E5=AE=87?= Date: Mon, 1 Aug 2016 10:05:16 +0800 Subject: [PATCH 120/135] bugfix:create MR failed,parameter assigneeId should be assignee_id. see http://docs.gitlab.com/ce/api/merge_requests.html#create-mr --- lib/Models/ProjectMergeRequests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Models/ProjectMergeRequests.js b/lib/Models/ProjectMergeRequests.js index 6bedc55..37f1b70 100644 --- a/lib/Models/ProjectMergeRequests.js +++ b/lib/Models/ProjectMergeRequests.js @@ -74,7 +74,7 @@ title: title }; if (assigneeId !== void 0) { - params.assigneeId = parseInt(assigneeId); + params.assignee_id = parseInt(assigneeId); } return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/merge_requests", params, (function(_this) { return function(data) { From 313f1d37beda9f7f061f71f88ac30749c7efc604 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 4 Aug 2016 10:47:51 +0200 Subject: [PATCH 121/135] v1.7.1 --- README.md | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 99ea896..c1b8229 100644 --- a/README.md +++ b/README.md @@ -122,10 +122,12 @@ MIT Changelog ========= -master (unreleased) +[1.7.1](https://github.com/node-gitlab/node-gitlab/tree/v1.7.1) (2016-08-04) ------------------- -- No entry +- Bug: fix create MR ([@zhangqingyv](https://github.com/zhangqingyv)) + +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.7.0...v1.7.1) [1.7.0](https://github.com/node-gitlab/node-gitlab/tree/v1.7.0) (2016-07-11) ---------------------- diff --git a/package.json b/package.json index bf1e6dd..e4aa66e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.7.0+dev", + "version": "1.7.1", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From d1a0d9b922459e4cf27ed9378a1fe339738d7518 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 4 Aug 2016 10:50:50 +0200 Subject: [PATCH 122/135] Post-release version bump --- README.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c1b8229..777be64 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,13 @@ MIT Changelog ========= +master (unreleased) +------------------- + +* No entry. + +[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.7.1...master) + [1.7.1](https://github.com/node-gitlab/node-gitlab/tree/v1.7.1) (2016-08-04) ------------------- diff --git a/package.json b/package.json index e4aa66e..14fda5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.7.1", + "version": "1.7.1+dev", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From cf5f804adcc03628b7e7ada47452bac94a30559f Mon Sep 17 00:00:00 2001 From: Judson Neer Date: Tue, 6 Sep 2016 00:02:13 -0700 Subject: [PATCH 123/135] Pass an optional params object to the list builds API. (#147) This allows providing a scope value to limit the number of returned builds. See API documentation at http://docs.gitlab.com/ee/api/builds.html. --- lib/Models/ProjectBuilds.js | 17 +++++++++++++++-- src/Models/ProjectBuilds.coffee | 11 +++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/Models/ProjectBuilds.js b/lib/Models/ProjectBuilds.js index 21b0cd1..855861d 100644 --- a/lib/Models/ProjectBuilds.js +++ b/lib/Models/ProjectBuilds.js @@ -18,12 +18,25 @@ return ProjectBuilds.__super__.constructor.apply(this, arguments); } - ProjectBuilds.prototype.listBuilds = function(projectId, fn) { + ProjectBuilds.prototype.listBuilds = function(projectId, params, fn) { + if (params == null) { + params = {}; + } if (fn == null) { fn = null; } + if ('function' === typeof params) { + fn = params; + params = {}; + } + if (params.page == null) { + params.page = 1; + } + if (params.per_page == null) { + params.per_page = 100; + } this.debug("Projects::listBuilds()"); - return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/builds", (function(_this) { + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/builds", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/ProjectBuilds.coffee b/src/Models/ProjectBuilds.coffee index e482f54..75f5fe4 100644 --- a/src/Models/ProjectBuilds.coffee +++ b/src/Models/ProjectBuilds.coffee @@ -4,9 +4,16 @@ Utils = require '../Utils' class ProjectBuilds extends BaseModel # === Builds - listBuilds: (projectId, fn = null) => + listBuilds: (projectId, params={}, fn = null) => + if 'function' is typeof params + fn = params + params={} + + params.page ?= 1 + params.per_page ?= 100 + @debug "Projects::listBuilds()" - @get "projects/#{Utils.parseProjectId projectId}/builds", (data) => fn data if fn + @get "projects/#{Utils.parseProjectId projectId}/builds", params, (data) => fn data if fn showBuild: (projectId, buildId, fn = null) => @debug "Projects::build()" From 4c8e17a45123db3647e38f5f463b9e1b059f2b43 Mon Sep 17 00:00:00 2001 From: mrawdon Date: Tue, 6 Sep 2016 03:03:14 -0400 Subject: [PATCH 124/135] Added subscriptions api for issues (#146) --- lib/Models/Issues.js | 51 +++++++++++++++++++++++++++++++++++++++- src/Models/Issues.coffee | 31 +++++++++++++++++++++++- 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/lib/Models/Issues.js b/lib/Models/Issues.js index 093f018..f1d65b6 100644 --- a/lib/Models/Issues.js +++ b/lib/Models/Issues.js @@ -10,6 +10,8 @@ extend(Issues, superClass); function Issues() { + this.unsubscribe = bind(this.unsubscribe, this); + this.subscribe = bind(this.subscribe, this); this.edit = bind(this.edit, this); this.create = bind(this.create, this); this.show = bind(this.show, this); @@ -119,7 +121,54 @@ } else { issueId = parseInt(issueId); } - return this.put("projects/" + projectId + "/issues/" + issueId, params, function(data) { + return this.put("projects/" + projectId + "/issues/" + issueId, function(data) { + if (fn) { + return fn(data); + } + }); + }; + + Issues.prototype.subscribe = function(projectId, issueId, params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Issues::subscribe()"); + if (projectId.toString().indexOf("/") !== -1) { + projectId = encodeURIComponent(projectId); + } else { + projectId = parseInt(projectId); + } + if (issueId.toString().indexOf("/") !== -1) { + issueId = encodeURIComponent(issueId); + } else { + issueId = parseInt(issueId); + } + return this.post("projects/" + projectId + "/issues/" + issueId + "/subscription", function(data) { + if (fn) { + return fn(data); + } + }); + }; + + Issues.prototype.unsubscribe = function(projectId, issueId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Issues::subscribe()"); + if (projectId.toString().indexOf("/") !== -1) { + projectId = encodeURIComponent(projectId); + } else { + projectId = parseInt(projectId); + } + if (issueId.toString().indexOf("/") !== -1) { + issueId = encodeURIComponent(issueId); + } else { + issueId = parseInt(issueId); + } + return this["delete"]("projects/" + projectId + "/issues/" + issueId + "/subscription", function(data) { if (fn) { return fn(data); } diff --git a/src/Models/Issues.coffee b/src/Models/Issues.coffee index 5b88721..47a4413 100644 --- a/src/Models/Issues.coffee +++ b/src/Models/Issues.coffee @@ -57,6 +57,35 @@ class Issues extends BaseModel else issueId = parseInt(issueId) - @put "projects/#{projectId}/issues/#{issueId}", params, (data) -> fn data if fn + @put "projects/#{projectId}/issues/#{issueId}", (data) -> fn data if fn + + subscribe: (projectId, issueId, params = {}, fn = null) => + @debug "Issues::subscribe()" + if projectId.toString().indexOf("/") isnt -1 + projectId = encodeURIComponent(projectId) + else + projectId = parseInt(projectId) + + if issueId.toString().indexOf("/") isnt -1 + issueId = encodeURIComponent(issueId) + else + issueId = parseInt(issueId) + + @post "projects/#{projectId}/issues/#{issueId}/subscription", (data) -> fn data if fn + + unsubscribe: (projectId, issueId, fn = null) => + @debug "Issues::unsubscribe()" + if projectId.toString().indexOf("/") isnt -1 + projectId = encodeURIComponent(projectId) + else + projectId = parseInt(projectId) + + if issueId.toString().indexOf("/") isnt -1 + issueId = encodeURIComponent(issueId) + else + issueId = parseInt(issueId) + + @delete "projects/#{projectId}/issues/#{issueId}/subscription", (data) -> fn data if fn + module.exports = (client) -> new Issues client From a9aa23bcb48fb639520f1a45892f2cd1b29ec27f Mon Sep 17 00:00:00 2001 From: Louix Date: Tue, 6 Sep 2016 15:04:46 +0800 Subject: [PATCH 125/135] Add Trigger API and fix Build API bug (#132) * Add all trigger api * fix build api bug --- lib/Models/ProjectBuilds.js | 12 ++++----- lib/Models/Projects.js | 46 +++++++++++++++++++++++++++++++++ src/Models/ProjectBuilds.coffee | 2 +- src/Models/Projects.coffee | 12 +++++++++ 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/lib/Models/ProjectBuilds.js b/lib/Models/ProjectBuilds.js index 855861d..6c97b6f 100644 --- a/lib/Models/ProjectBuilds.js +++ b/lib/Models/ProjectBuilds.js @@ -67,13 +67,11 @@ fn = null; } this.debug("Projects::triggerBuild()"); - return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/trigger/builds", params, null, (function(_this) { - return function(data) { - if (fn) { - return fn(data); - } - }; - })(this)); + return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/trigger/builds", params, function(data) { + if (fn) { + return fn(data); + } + }); }; return ProjectBuilds; diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index 2799dc8..75db455 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -12,6 +12,9 @@ extend(Projects, superClass); function Projects() { + this.removeTrigger = bind(this.removeTrigger, this); + this.createTrigger = bind(this.createTrigger, this); + this.showTrigger = bind(this.showTrigger, this); this.listTriggers = bind(this.listTriggers, this); this.search = bind(this.search, this); this.fork = bind(this.fork, this); @@ -330,6 +333,49 @@ })(this)); }; + Projects.prototype.showTrigger = function(projectId, token, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::showTrigger()"); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/triggers/" + token, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + Projects.prototype.createTrigger = function(params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Projects::createTrigger()"); + return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/triggers", params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + + Projects.prototype.removeTrigger = function(projectId, token, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::removeTrigger()"); + return this["delete"]("projects/" + (Utils.parseProjectId(projectId)) + "/triggers/" + token, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + return Projects; })(BaseModel); diff --git a/src/Models/ProjectBuilds.coffee b/src/Models/ProjectBuilds.coffee index 75f5fe4..a4699b1 100644 --- a/src/Models/ProjectBuilds.coffee +++ b/src/Models/ProjectBuilds.coffee @@ -21,6 +21,6 @@ class ProjectBuilds extends BaseModel triggerBuild: (params={}, fn = null) => @debug "Projects::triggerBuild()" - @post "projects/#{Utils.parseProjectId params.projectId}/trigger/builds", params, null, (data) => fn data if fn + @post "projects/#{Utils.parseProjectId params.projectId}/trigger/builds", params, (data) -> fn data if fn module.exports = (client) -> new ProjectBuilds client diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 8bcd26f..1a29b0f 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -118,4 +118,16 @@ class Projects extends BaseModel @debug "Projects::listTriggers()" @get "projects/#{Utils.parseProjectId projectId}/triggers", (data) => fn data if fn + showTrigger: (projectId, token, fn = null) => + @debug "Projects::showTrigger()" + @get "projects/#{Utils.parseProjectId projectId}/triggers/#{token}", (data) => fn data if fn + + createTrigger: (params={}, fn=null) => + @debug "Projects::createTrigger()" + @post "projects/#{Utils.parseProjectId params.projectId}/triggers", params, (data) -> fn data if fn + + removeTrigger: (projectId, token, fn = null) => + @debug "Projects::removeTrigger()" + @delete "projects/#{Utils.parseProjectId projectId}/triggers/#{token}", (data) => fn data if fn + module.exports = (client) -> new Projects client From 4ff4b9d2a9686f1c8cb160f4432bdc569d615de7 Mon Sep 17 00:00:00 2001 From: "Marcus M. Darden" Date: Tue, 6 Sep 2016 03:05:40 -0400 Subject: [PATCH 126/135] Extend groups (#124) * Add oauth_token option to authenticate connection The GitLab spec allows authentication with the private_token or oauth bearer token. This modification accepts the oauth_token parameter for connection, and puts the token into the headers if it is supplied. Docs: https://gitlab.eecs.umich.edu/help/api/README.md#authentication-with-oauth2-token * Add remainder of Groups API methods Newly added methods that were in the GitLab spec but previously not implemented: * deleteGroup(groupId) [DELETE] * editMember(groupId, userId, accessLevel) [POST] * removeMember(groupId, userId) [DELETE] --- lib/Models/Groups.js | 59 ++++++++++++++++++++++++++++++++++++++++ src/Models/Groups.coffee | 24 ++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/lib/Models/Groups.js b/lib/Models/Groups.js index 1d233d4..9678ad3 100644 --- a/lib/Models/Groups.js +++ b/lib/Models/Groups.js @@ -11,8 +11,11 @@ function Groups() { this.search = bind(this.search, this); + this.deleteGroup = bind(this.deleteGroup, this); this.addProject = bind(this.addProject, this); this.create = bind(this.create, this); + this.removeMember = bind(this.removeMember, this); + this.editMember = bind(this.editMember, this); this.addMember = bind(this.addMember, this); this.listMembers = bind(this.listMembers, this); this.listProjects = bind(this.listProjects, this); @@ -149,6 +152,50 @@ }); }; + Groups.prototype.editMember = function(groupId, userId, accessLevel, fn) { + var checkAccessLevel, params; + if (fn == null) { + fn = null; + } + this.debug("Groups::editMember(" + groupId + ", " + userId + ", " + accessLevel + ")"); + checkAccessLevel = (function(_this) { + return function() { + var access_level, k, ref; + ref = _this.access_levels; + for (k in ref) { + access_level = ref[k]; + if (accessLevel === access_level) { + return true; + } + } + return false; + }; + })(this); + if (!checkAccessLevel()) { + throw "`accessLevel` must be one of " + (JSON.stringify(this.access_levels)); + } + params = { + access_level: accessLevel + }; + return this.put("groups/" + (parseInt(groupId)) + "/members/" + (parseInt(userId)), params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + + Groups.prototype.removeMember = function(groupId, userId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Groups::removeMember(" + groupId + ", " + userId + ")"); + return this["delete"]("groups/" + (parseInt(groupId)) + "/members/" + (parseInt(userId)), function(data) { + if (fn) { + return fn(data); + } + }); + }; + Groups.prototype.create = function(params, fn) { if (params == null) { params = {}; @@ -176,6 +223,18 @@ }); }; + Groups.prototype.deleteGroup = function(groupId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Groups::delete(" + groupId + ")"); + return this["delete"]("groups/" + (parseInt(groupId)), function(data) { + if (fn) { + return fn(data); + } + }); + }; + Groups.prototype.search = function(nameOrPath, fn) { var params; if (fn == null) { diff --git a/src/Models/Groups.coffee b/src/Models/Groups.coffee index 7f20729..2f2f1d4 100644 --- a/src/Models/Groups.coffee +++ b/src/Models/Groups.coffee @@ -62,6 +62,26 @@ class Groups extends BaseModel @post "groups/#{parseInt groupId}/members", params, (data) -> fn data if fn + editMember: (groupId, userId, accessLevel, fn = null) => + @debug "Groups::editMember(#{groupId}, #{userId}, #{accessLevel})" + + checkAccessLevel = => + for k, access_level of @access_levels + return true if accessLevel == access_level + false + + unless do checkAccessLevel + throw "`accessLevel` must be one of #{JSON.stringify @access_levels}" + + params = + access_level: accessLevel + + @put "groups/#{parseInt groupId}/members/#{parseInt userId}", params, (data) -> fn data if fn + + removeMember: (groupId, userId, fn = null) => + @debug "Groups::removeMember(#{groupId}, #{userId})" + @delete "groups/#{parseInt groupId}/members/#{parseInt userId}", (data) -> fn data if fn + create: (params = {}, fn = null) => @debug "Groups::create()" @post "groups", params, (data) -> fn data if fn @@ -70,6 +90,10 @@ class Groups extends BaseModel @debug "Groups::addProject(#{groupId}, #{projectId})" @post "groups/#{parseInt groupId}/projects/#{parseInt projectId}", null, (data) -> fn data if fn + deleteGroup: (groupId, fn = null) => + @debug "Groups::delete(#{groupId})" + @delete "groups/#{parseInt groupId}", (data) -> fn data if fn + search: (nameOrPath, fn = null) => @debug "Groups::search(#{nameOrPath})" params = From 92a4bc32124308ee63376d03c7397e115506f34f Mon Sep 17 00:00:00 2001 From: Wander Lairson Costa Date: Wed, 21 Sep 2016 11:32:07 -0300 Subject: [PATCH 127/135] Add new APIs (#148) * Add Pipeline listing API. API reference: http://docs.gitlab.com/ee/api/pipelines.html gitlab.projects.pipelines.all(projectId, (pipelines) -> console.log(pipelines) ) * Add Runners API. --- lib/Models/Pipelines.js | 41 +++++++++ lib/Models/ProjectMergeRequests.js | 2 +- lib/Models/Projects.js | 4 +- lib/Models/Runners.js | 134 +++++++++++++++++++++++++++++ src/Models/Pipelines.coffee | 9 ++ src/Models/Projects.coffee | 2 + src/Models/Runners.coffee | 39 +++++++++ 7 files changed, 229 insertions(+), 2 deletions(-) create mode 100644 lib/Models/Pipelines.js create mode 100644 lib/Models/Runners.js create mode 100644 src/Models/Pipelines.coffee create mode 100644 src/Models/Runners.coffee diff --git a/lib/Models/Pipelines.js b/lib/Models/Pipelines.js new file mode 100644 index 0000000..c4cc687 --- /dev/null +++ b/lib/Models/Pipelines.js @@ -0,0 +1,41 @@ +(function() { + var BaseModel, Pipelines, Utils, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + BaseModel = require('../BaseModel'); + + Utils = require('../Utils'); + + Pipelines = (function(superClass) { + extend(Pipelines, superClass); + + function Pipelines() { + this.all = bind(this.all, this); + return Pipelines.__super__.constructor.apply(this, arguments); + } + + Pipelines.prototype.all = function(projectId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Pipelines::all()"); + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/pipelines", (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + return Pipelines; + + })(BaseModel); + + module.exports = function(client) { + return new Pipelines(client); + }; + +}).call(this); diff --git a/lib/Models/ProjectMergeRequests.js b/lib/Models/ProjectMergeRequests.js index 37f1b70..6bedc55 100644 --- a/lib/Models/ProjectMergeRequests.js +++ b/lib/Models/ProjectMergeRequests.js @@ -74,7 +74,7 @@ title: title }; if (assigneeId !== void 0) { - params.assignee_id = parseInt(assigneeId); + params.assigneeId = parseInt(assigneeId); } return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/merge_requests", params, (function(_this) { return function(data) { diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index 75db455..8fdfcc5 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -44,7 +44,9 @@ this.deploy_keys = this.load('ProjectDeployKeys'); this.merge_requests = this.load('ProjectMergeRequests'); this.services = this.load('ProjectServices'); - return this.builds = this.load('ProjectBuilds'); + this.builds = this.load('ProjectBuilds'); + this.pipelines = this.load('Pipelines'); + return this.runners = this.load('Runners'); }; Projects.prototype.all = function(params, fn) { diff --git a/lib/Models/Runners.js b/lib/Models/Runners.js new file mode 100644 index 0000000..b37ab4d --- /dev/null +++ b/lib/Models/Runners.js @@ -0,0 +1,134 @@ +(function() { + var BaseModel, Runners, Utils, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + BaseModel = require('../BaseModel'); + + Utils = require('../Utils'); + + Runners = (function(superClass) { + extend(Runners, superClass); + + function Runners() { + this.disable = bind(this.disable, this); + this.enable = bind(this.enable, this); + this.remove = bind(this.remove, this); + this.update = bind(this.update, this); + this.show = bind(this.show, this); + this.all = bind(this.all, this); + return Runners.__super__.constructor.apply(this, arguments); + } + + Runners.prototype.all = function(projectId, params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + if ('function' === typeof params) { + fn = params; + params = {}; + } + this.debug("Projects::Runners::all()"); + if (projectId != null) { + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/runners", params, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + } else { + return this.get("runners", params, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + } + }; + + Runners.prototype.show = function(runnerId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::Runners::show()"); + return this.get("runners/" + (parseInt(runnerId)), (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + Runners.prototype.update = function(runnerId, attributes, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::Runners::update"); + return this.put("runners/" + (parseInt(runnerId)), attributes, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + Runners.prototype.remove = function(runnerId, projectId, enable, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::Runners::runners()"); + return this["delete"]("runners/" + (parseInt(runnerId)), (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + + Runners.prototype.enable = function(projectId, runnerId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::Runners::enable()"); + ({ + attributes: { + runner_id: parseInt(runnerId) + } + }); + return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/runners", attributes, function(data) { + if (fn) { + return fn(data); + } + }); + }; + + Runners.prototype.disable = function(projectId, runnerId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::Runners::disable()"); + return this["delete"]("projects/" + (Utils.parseProjectId(projectId)) + "/runners/" + (parseInt(runnerId)), function(data) { + if (fn) { + return fn(data); + } + }); + }; + + return Runners; + + })(BaseModel); + + module.exports = function(client) { + return new Runners(client); + }; + +}).call(this); diff --git a/src/Models/Pipelines.coffee b/src/Models/Pipelines.coffee new file mode 100644 index 0000000..3c4bbde --- /dev/null +++ b/src/Models/Pipelines.coffee @@ -0,0 +1,9 @@ +BaseModel = require '../BaseModel' +Utils = require '../Utils' + +class Pipelines extends BaseModel + all: (projectId, fn = null) => + @debug "Pipelines::all()" + @get "projects/#{Utils.parseProjectId projectId}/pipelines", (data) => fn data if fn + +module.exports = (client) -> new Pipelines client diff --git a/src/Models/Projects.coffee b/src/Models/Projects.coffee index 1a29b0f..3c1bbac 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -13,6 +13,8 @@ class Projects extends BaseModel @merge_requests = @load 'ProjectMergeRequests' @services = @load 'ProjectServices' @builds = @load 'ProjectBuilds' + @pipelines = @load 'Pipelines' + @runners = @load 'Runners' all: (params={}, fn=null) => if 'function' is typeof params diff --git a/src/Models/Runners.coffee b/src/Models/Runners.coffee new file mode 100644 index 0000000..4bee932 --- /dev/null +++ b/src/Models/Runners.coffee @@ -0,0 +1,39 @@ +BaseModel = require '../BaseModel' +Utils = require '../Utils' + +class Runners extends BaseModel + all: (projectId, params={}, fn = null) => + if 'function' is typeof params + fn = params + params={} + + @debug "Projects::Runners::all()" + + if projectId? + @get "projects/#{Utils.parseProjectId projectId}/runners", params, (data) => fn data if fn + else + @get "runners", params, (data) => fn data if fn + + show: (runnerId, fn = null) => + @debug "Projects::Runners::show()" + @get "runners/#{parseInt runnerId}", (data) => fn data if fn + + update: (runnerId, attributes, fn = null) => + @debug "Projects::Runners::update" + @put "runners/#{parseInt runnerId}", attributes, (data) => fn data if fn + + remove: (runnerId, projectId, enable, fn = null) => + @debug "Projects::Runners::runners()" + @delete "runners/#{parseInt runnerId}", (data) => fn data if fn + + enable: (projectId, runnerId, fn = null) => + @debug "Projects::Runners::enable()" + attributes: + runner_id: parseInt runnerId + @post "projects/#{Utils.parseProjectId projectId}/runners", attributes, (data) -> fn data if fn + + disable: (projectId, runnerId, fn = null) => + @debug "Projects::Runners::disable()" + @delete "projects/#{Utils.parseProjectId projectId}/runners/#{parseInt runnerId}", (data) -> fn data if fn + +module.exports = (client) -> new Runners client From 4aa5fd84d67d3f0d119878c27bd84c39ea7ccf84 Mon Sep 17 00:00:00 2001 From: Luca Ravizzotti Date: Fri, 7 Oct 2016 09:06:15 +0200 Subject: [PATCH 128/135] Issues, edit method doesn't work and remove method missing (#150) * Fix issue edit don't pass data * Add delete issue method * Change delete issue method to remove * Build issues module with new delete method and fix edit method --- lib/Models/Issues.js | 27 +++++++++++++++++++++++++-- src/Models/Issues.coffee | 16 +++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/lib/Models/Issues.js b/lib/Models/Issues.js index f1d65b6..aa48f0e 100644 --- a/lib/Models/Issues.js +++ b/lib/Models/Issues.js @@ -12,6 +12,7 @@ function Issues() { this.unsubscribe = bind(this.unsubscribe, this); this.subscribe = bind(this.subscribe, this); + this.remove = bind(this.remove, this); this.edit = bind(this.edit, this); this.create = bind(this.create, this); this.show = bind(this.show, this); @@ -121,7 +122,29 @@ } else { issueId = parseInt(issueId); } - return this.put("projects/" + projectId + "/issues/" + issueId, function(data) { + return this.put("projects/" + projectId + "/issues/" + issueId, params, function(data) { + if (fn) { + return fn(data); + } + }); + }; + + Issues.prototype.remove = function(projectId, issueId, fn) { + if (fn == null) { + fn = null; + } + this.debug("Issues::remove()"); + if (projectId.toString().indexOf("/") !== -1) { + projectId = encodeURIComponent(projectId); + } else { + projectId = parseInt(projectId); + } + if (issueId.toString().indexOf("/") !== -1) { + issueId = encodeURIComponent(issueId); + } else { + issueId = parseInt(issueId); + } + return this["delete"]("projects/" + projectId + "/issues/" + issueId, function(data) { if (fn) { return fn(data); } @@ -157,7 +180,7 @@ if (fn == null) { fn = null; } - this.debug("Issues::subscribe()"); + this.debug("Issues::unsubscribe()"); if (projectId.toString().indexOf("/") !== -1) { projectId = encodeURIComponent(projectId); } else { diff --git a/src/Models/Issues.coffee b/src/Models/Issues.coffee index 47a4413..7d381ce 100644 --- a/src/Models/Issues.coffee +++ b/src/Models/Issues.coffee @@ -57,7 +57,21 @@ class Issues extends BaseModel else issueId = parseInt(issueId) - @put "projects/#{projectId}/issues/#{issueId}", (data) -> fn data if fn + @put "projects/#{projectId}/issues/#{issueId}", params, (data) -> fn data if fn + + remove: (projectId, issueId, fn = null) => + @debug "Issues::remove()" + if projectId.toString().indexOf("/") isnt -1 + projectId = encodeURIComponent(projectId) + else + projectId = parseInt(projectId) + + if issueId.toString().indexOf("/") isnt -1 + issueId = encodeURIComponent(issueId) + else + issueId = parseInt(issueId) + + @delete "projects/#{projectId}/issues/#{issueId}", (data) -> fn data if fn subscribe: (projectId, issueId, params = {}, fn = null) => @debug "Issues::subscribe()" From 714cbef0ac2c85634fd0d33f32e9b34d0cbef9b8 Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Fri, 13 Jan 2017 23:38:05 +1100 Subject: [PATCH 129/135] Add project share endpoint (#156) --- lib/Models/Projects.js | 16 ++++++++++++++++ src/Models/Projects.coffee | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/lib/Models/Projects.js b/lib/Models/Projects.js index 8fdfcc5..7f3351e 100644 --- a/lib/Models/Projects.js +++ b/lib/Models/Projects.js @@ -17,6 +17,7 @@ this.showTrigger = bind(this.showTrigger, this); this.listTriggers = bind(this.listTriggers, this); this.search = bind(this.search, this); + this.share = bind(this.share, this); this.fork = bind(this.fork, this); this.remove = bind(this.remove, this); this.listTags = bind(this.listTags, this); @@ -300,6 +301,21 @@ }); }; + Projects.prototype.share = function(params, fn) { + if (params == null) { + params = {}; + } + if (fn == null) { + fn = null; + } + this.debug("Projects::share()"); + return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/share", 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 3c1bbac..86ea8dd 100644 --- a/src/Models/Projects.coffee +++ b/src/Models/Projects.coffee @@ -108,6 +108,10 @@ class Projects extends BaseModel @debug "Projects::fork()" @post "projects/fork/#{params.id}", params, (data) -> fn data if fn + share: (params={}, fn=null) => + @debug "Projects::share()" + @post "projects/#{Utils.parseProjectId params.projectId}/share", params, (data) -> fn data if fn + search: (projectName, params={}, fn=null) => if 'function' is typeof params fn = params From 0c0f18544a19174aeb86f5f1399151575e6399a7 Mon Sep 17 00:00:00 2001 From: Kevin Frugier Date: Thu, 16 Mar 2017 11:31:44 +0100 Subject: [PATCH 130/135] Fixed repository.showCommit + Added repository.deleteTag (#157) * Fixed repository.showCommit to use proper URL & sha instead of branch URL and id * Added missing deleteTag feature --- lib/Models/ProjectRepository.js | 19 +++++++++++++++++-- src/Models/ProjectRepository.coffee | 8 ++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index dec8714..cc18004 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -22,6 +22,7 @@ this.listCommits = bind(this.listCommits, this); this.listTags = bind(this.listTags, this); this.showTag = bind(this.showTag, this); + this.deleteTag = bind(this.deleteTag, this); this.addTag = bind(this.addTag, this); this.deleteBranch = bind(this.deleteBranch, this); this.createBranch = bind(this.createBranch, this); @@ -136,6 +137,20 @@ })(this)); }; + ProjectRepository.prototype.deleteTag = function(projectId, tagName, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::deleteTag()"); + return this["delete"]("projects/" + (Utils.parseProjectId(projectId)) + "/repository/tags/" + (encodeURI(tagName)), (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + ProjectRepository.prototype.showTag = function(projectId, tagName, fn) { if (fn == null) { fn = null; @@ -178,12 +193,12 @@ })(this)); }; - ProjectRepository.prototype.showCommit = function(projectId, commitId, fn) { + ProjectRepository.prototype.showCommit = function(projectId, sha, fn) { if (fn == null) { fn = null; } this.debug("Projects::commit()"); - return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/repository/branches/" + (parseInt(commitId)), (function(_this) { + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/repository/commits/" + sha, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index 1643dbe..adb3c80 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -33,6 +33,10 @@ class ProjectRepository extends BaseModel @debug "Projects::addTag()" @post "projects/#{Utils.parseProjectId params.id}/repository/tags", params, (data) => fn data if fn + deleteTag: (projectId, tagName, fn = null) => + @debug "Projects::deleteTag()" + @delete "projects/#{Utils.parseProjectId projectId}/repository/tags/#{encodeURI tagName}", (data) => fn data if fn + showTag: (projectId, tagName, fn = null) => @debug "Projects::showTag()" @get "projects/#{Utils.parseProjectId projectId}/repository/tags/#{encodeURI tagName}", (data) => fn data if fn @@ -46,9 +50,9 @@ class ProjectRepository extends BaseModel @debug "Projects::listCommits()" @get "projects/#{Utils.parseProjectId projectId}/repository/commits", (data) => fn data if fn - showCommit: (projectId, commitId, fn = null) => + showCommit: (projectId, sha, fn = null) => @debug "Projects::commit()" - @get "projects/#{Utils.parseProjectId projectId}/repository/branches/#{parseInt commitId}", (data) => fn data if fn + @get "projects/#{Utils.parseProjectId projectId}/repository/commits/#{sha}", (data) => fn data if fn diffCommit: (projectId, sha, fn = null) => @debug "Projects::diffCommit()" From 8047d47b3a3a2c039f6610a51c6c8494bb6cbbfc Mon Sep 17 00:00:00 2001 From: Antonio Ribeiro Date: Fri, 7 Jul 2017 13:12:55 +0100 Subject: [PATCH 131/135] Fixed API doc, merge request acceptance and protect branch with parameters (#177) * Fixed API url * New merge function to accept a merge request * Protect branch function can now receives parameters --- README.md | 2 +- lib/Models/ProjectMergeRequests.js | 17 +++++++++++++++++ lib/Models/ProjectRepository.js | 7 +++++-- src/Models/ProjectMergeRequests.coffee | 9 +++++++++ src/Models/ProjectRepository.coffee | 4 ++-- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 777be64..0086334 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ node-gitlab -- [GitLab](https://github.com/gitlabhq/gitlabhq) API Nodejs library. -It wraps the HTTP api library described [here](https://github.com/gitlabhq/gitlabhq/tree/master/doc/api). +It wraps the HTTP api library described [here](https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/README.md). Maintained by [Manfred Touron](https://github.com/moul) and [Dave Irvine](https://github.com/dave-irvine) diff --git a/lib/Models/ProjectMergeRequests.js b/lib/Models/ProjectMergeRequests.js index 6bedc55..40a6283 100644 --- a/lib/Models/ProjectMergeRequests.js +++ b/lib/Models/ProjectMergeRequests.js @@ -12,6 +12,7 @@ extend(ProjectMergeRequests, superClass); function ProjectMergeRequests() { + this.merge = bind(this.merge, this); this.comment = bind(this.comment, this); this.update = bind(this.update, this); this.add = bind(this.add, this); @@ -121,6 +122,22 @@ })(this)); }; + ProjectMergeRequests.prototype.merge = function(projectId, mergerequestId, params, fn) { + if (fn == null) { + fn = null; + } + this.debug("Projects::acceptMergeRequest()"); + params.id = Utils.parseProjectId(projectId); + params.merge_request_id = parseInt(mergerequestId); + return this.put("projects/" + (Utils.parseProjectId(projectId)) + "/merge_request/" + (parseInt(mergerequestId)) + "/merge", params, (function(_this) { + return function(data) { + if (fn) { + return fn(data); + } + }; + })(this)); + }; + return ProjectMergeRequests; })(BaseModel); diff --git a/lib/Models/ProjectRepository.js b/lib/Models/ProjectRepository.js index cc18004..90e3df1 100644 --- a/lib/Models/ProjectRepository.js +++ b/lib/Models/ProjectRepository.js @@ -61,12 +61,15 @@ })(this)); }; - ProjectRepository.prototype.protectBranch = function(projectId, branchId, fn) { + ProjectRepository.prototype.protectBranch = function(projectId, branchId, params, fn) { + if (params == null) { + params = {}; + } if (fn == null) { fn = null; } this.debug("Projects::protectBranch()"); - return this.put("projects/" + (Utils.parseProjectId(projectId)) + "/repository/branches/" + (encodeURI(branchId)) + "/protect", null, (function(_this) { + return this.put("projects/" + (Utils.parseProjectId(projectId)) + "/repository/branches/" + (encodeURI(branchId)) + "/protect", params, (function(_this) { return function(data) { if (fn) { return fn(data); diff --git a/src/Models/ProjectMergeRequests.coffee b/src/Models/ProjectMergeRequests.coffee index 3229f05..7d7e80e 100644 --- a/src/Models/ProjectMergeRequests.coffee +++ b/src/Models/ProjectMergeRequests.coffee @@ -43,4 +43,13 @@ class ProjectMergeRequests extends BaseModel note: note @post "projects/#{Utils.parseProjectId projectId}/merge_request/#{parseInt mergerequestId}/comments", params, (data) => fn data if fn + merge: (projectId, mergerequestId, params, fn = null) => + @debug "Projects::acceptMergeRequest()" + + params.id = Utils.parseProjectId projectId + params.merge_request_id = parseInt mergerequestId + + @put "projects/#{Utils.parseProjectId projectId}/merge_request/#{parseInt mergerequestId}/merge", params, (data) => fn data if fn + + module.exports = (client) -> new ProjectMergeRequests client diff --git a/src/Models/ProjectRepository.coffee b/src/Models/ProjectRepository.coffee index adb3c80..9832901 100644 --- a/src/Models/ProjectRepository.coffee +++ b/src/Models/ProjectRepository.coffee @@ -12,9 +12,9 @@ class ProjectRepository extends BaseModel @debug "Projects::branch()" @get "projects/#{Utils.parseProjectId projectId}/repository/branches/#{encodeURI branchId}", (data) => fn data if fn - protectBranch: (projectId, branchId, fn = null) => + protectBranch: (projectId, branchId, params = {}, fn = null) => @debug "Projects::protectBranch()" - @put "projects/#{Utils.parseProjectId projectId}/repository/branches/#{encodeURI branchId}/protect", null, (data) => fn data if fn + @put "projects/#{Utils.parseProjectId projectId}/repository/branches/#{encodeURI branchId}/protect", params, (data) => fn data if fn unprotectBranch: (projectId, branchId, fn = null) => @debug "Projects::unprotectBranch()" From ad0ce2fec3d84d5895219e8e20fd546f87e15f61 Mon Sep 17 00:00:00 2001 From: Felix Fichte Date: Mon, 4 Sep 2017 14:05:37 +0200 Subject: [PATCH 132/135] fix double parsing of response.body (#159) * fix double parsing of response.body when the response body is already an object don't try to parse it again should be fixing #149 * update to make houndci happy --- src/ApiBaseHTTP.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ApiBaseHTTP.coffee b/src/ApiBaseHTTP.coffee index ace87a7..2aa87cc 100644 --- a/src/ApiBaseHTTP.coffee +++ b/src/ApiBaseHTTP.coffee @@ -43,7 +43,11 @@ class module.exports.ApiBaseHTTP extends ApiBase arity = fn.length switch arity when 1 then fn ret - when 2 then fn err, ret || JSON.parse(response.body).message + when 2 + if typeof response.body == 'object' + fn err, ret || response.body.message + else + fn err, ret || JSON.parse(response.body).message when 3 then fn err, response, ret get: (path, query={}, fn=null) => From 22c175dac03283bb9a0c77476064518ee742ff68 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Fri, 30 Mar 2018 11:44:27 +0200 Subject: [PATCH 133/135] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 14fda5a..8dc7278 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab", - "version": "1.7.1+dev", + "version": "1.8.0", "description": "GitLab API Nodejs library.", "main": "lib/index.js", "directories": { From 52d0fa32450e188f6fd0259d74cc20c43174bcd8 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Fri, 30 Mar 2018 22:21:33 +0200 Subject: [PATCH 134/135] increase Node.js versions, fixes unit tests --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc4b897..e664de8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: node_js node_js: - - "0.12" - - "0.11" - - "0.10" + - "lts/boron" + - "lts/carbon" + - "stable" sudo: false notifications: webhooks: From 3e26a8e64cfb7d34d0a1e1f5dff01942a817f502 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 24 Oct 2019 11:56:05 +0200 Subject: [PATCH 135/135] Update README.md --- README.md | 243 +----------------------------------------------------- 1 file changed, 1 insertion(+), 242 deletions(-) diff --git a/README.md b/README.md index 0086334..0ff3cb6 100644 --- a/README.md +++ b/README.md @@ -1,242 +1 @@ -node-gitlab -=========== - -[![Build Status (Travis)](https://travis-ci.org/node-gitlab/node-gitlab.png?branch=master)](https://travis-ci.org/node-gitlab/node-gitlab) -[![Dependency Status](https://david-dm.org/node-gitlab/node-gitlab.png?theme=shields.io)](https://david-dm.org/node-gitlab/node-gitlab) -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/node-gitlab/node-gitlab/trend.png)](https://bitdeli.com/free "Bitdeli Badge") -[![Code Climate](https://codeclimate.com/github/node-gitlab/node-gitlab/badges/gpa.svg)](https://codeclimate.com/github/node-gitlab/node-gitlab) - -[![NPM Badge](https://nodei.co/npm/gitlab.png?downloads=true&stars=true)](https://npmjs.org/package/gitlab) --- - -[GitLab](https://github.com/gitlabhq/gitlabhq) API Nodejs library. -It wraps the HTTP api library described [here](https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/README.md). - -Maintained by [Manfred Touron](https://github.com/moul) and [Dave Irvine](https://github.com/dave-irvine) - - -Install -======= - -```bash -# Install from npm -npm install gitlab -``` - -Usage -===== - -URL to your GitLab instance should not include `/api/v3` path. - -Coffee-Script -------------- -```coffee -# Connection -gitlab = (require 'gitlab') - url: 'http://example.com' - token: 'abcdefghij123456' - -# Listing users -gitlab.users.all (users) -> - console.log "##{user.id}: #{user.email}, #{user.name}, #{user.created_at}" for user in users - -# Listing projects -gitlab.projects.all (projects) -> - for project in projects - console.log "##{project.id}: #{project.name}, path: #{project.path}, default_branch: #{project.default_branch}, private: #{project.private}, owner: #{project.owner.name} (#{project.owner.email}), date: #{project.created_at}" -``` - -Javascript ----------- -```javascript -// Connection -var gitlab = require('gitlab')({ - url: 'http://example.com', - token: 'abcdefghij123456' -}); - -// Listing users -gitlab.users.all(function(users) { - for (var i = 0; i < users.length; i++) { - console.log("#" + users[i].id + ": " + users[i].email + ", " + users[i].name + ", " + users[i].created_at); - } -}); - -// Listing projects -gitlab.projects.all(function(projects) { - for (var i = 0; i < projects.length; i++) { - console.log("#" + projects[i].id + ": " + projects[i].name + ", path: " + projects[i].path + ", default_branch: " + projects[i].default_branch + ", private: " + projects[i]["private"] + ", owner: " + projects[i].owner.name + " (" + projects[i].owner.email + "), date: " + projects[i].created_at); - } -}); -``` - -See [Examples directory](https://github.com/node-gitlab/node-gitlab/tree/master/examples) for more examples - -Develop -======= - -[![Gitter chat](https://badges.gitter.im/node-gitlab/node-gitlab.png)](https://gitter.im/node-gitlab/node-gitlab) - -Edit the Coffee-Script files in `src`, then build them using `cake build`. -Use `cake watch` to build files continuously while developing. - -CLI ---- - -Check out [cli-gitlab](https://github.com/mdsb100/cli-gitlab) - - -Contributors ------------- - -- [Glavin Wiechert](https://github.com/Glavin001) -- [Florian Quiblier](https://github.com/fofoy) -- [Anthony Heber](https://github.com/aheber) -- [Evan Heidtmann](https://github.com/ezheidtmann) -- [luoqpolyvi](https://github.com/luoqpolyvi) -- [Brian Vanderbusch](https://github.com/LongLiveCHIEF) -- [daprahamian](https://github.com/daprahamian) -- [pgorecki](https://github.com/pgorecki) -- [CaoJun](https://github.com/mdsb100) -- [nalabjp](https://github.com/nalabjp) -- [shaoshuai0102](https://github.com/shaoshuai0102) -- [Sakesan Panjamawat](https://github.com/sakp) -- [Jose Jiménez](https://github.com/jjimenezlopez) -- [huhgawz](https://github.com/huhgawz) -- [Connor Weng](https://github.com/ConnorWeng) -- [Felix Fichte](https://github.com/spruce) -- [Steve Norman](https://github.com/stevenorman) -- [Pete Ward](https://github.com/peteward44) -- [Pieter Soudan](https://github.com/Sewdn) -- [Ryan Southern](https://github.com/ryansouthern) -- [Zhongyi Tong](https://github.com/geeeeeeeeek) -- [mrawdon](https://github.com/mrawdon) -- [Marcus M. Darden](https://github.com/marcus-darden) - -License -------- - -MIT - - -Changelog -========= - -master (unreleased) -------------------- - -* No entry. - -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.7.1...master) - -[1.7.1](https://github.com/node-gitlab/node-gitlab/tree/v1.7.1) (2016-08-04) -------------------- - -- Bug: fix create MR ([@zhangqingyv](https://github.com/zhangqingyv)) - -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.7.0...v1.7.1) - -[1.7.0](https://github.com/node-gitlab/node-gitlab/tree/v1.7.0) (2016-07-11) ----------------------- - -- Add support for adding a tag to a project -- Add gitlab.projects.repository.compare() -- Add support for portion builds API -- Set slumber version to non-breaking - -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.6.0...v1.7.0) - - -[1.6.0](https://github.com/node-gitlab/node-gitlab/tree/v1.6.0) (2016-05-10) ----------------------- - -- Add function to query all projects as admin -- Add oauth_token option to authenticate connection -- Add possibility to showFile by sha id -- Add support for the GitLab services API -- Fix undefined assigneeId in merge request (#111) - -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.5.0...v1.6.0) - -[1.5.0](https://github.com/node-gitlab/node-gitlab/tree/v1.5.0) (2015-11-26) ----------------------- - -- Add `Project.edit` -- Add `Projects.create_for_user` -- Add ssh key to user -- Add Projects forks - -Thanks to [@peteward44](https://github.com/peteward44), -[@Sewdn](https://github.com/Sewdn), [@ryansouthern](https://github.com/ryansouthern) -and [@geeeeeeeeek](https://github.com/geeeeeeeeek) - -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.4.1...v1.5.0) - -1.4.1 (2015-08-11) ------------------- - -- Coffee rebuild - -[1.4.0](https://github.com/node-gitlab/node-gitlab/tree/v1.4.0) (2015-08-11) ------------------- - -- Now using headers for PRIVATE-TOKEN -- Add `Groups.create`, `Groups.addProject` and `Groups.search` methods -- Add `Projects.remove` and `Projects.search` methods -- Add `UserKeys` resource -- Add `Users.search` method -- Rename `ProjectMielstones.get` to `ProjectMilestones.all` -- Handling pagination on multiple new `.all()` methods -- Various stability and performance fixes - -Thanks to [@huhgawz](https://github.com/huhgawz), -[@ConnorWeng](https://github.com/ConnorWeng), [@langma](https://github.com/langma), -[@spruce](https://github.com/spruce), [@stevenorman](https://github.com/stevenorman) -and [@nogs](https://github.com/nogs) - - -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.3.0...v1.4.0) - -[1.3.0](https://github.com/node-gitlab/node-gitlab/tree/v1.3.0) (2015-02-09) ------------------- - -- Now handling notes -- Now handling lables -- Added Groups.addMember() and Groups.access_levels -- Checking for permissions -- Added tests -- Code cleanup and various small improvements - -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.2.0...v1.3.0) - -[1.2.0](https://github.com/node-gitlab/node-gitlab/tree/v1.2.0) (2014-12-24) ------------------- - -- Switched to new organization, some urls changed -- Improve development tools -- Cleaned code -- Changed AddHook parameters -- Happy Christmas - -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.1.0...v1.2.0) - -[1.1.0](https://github.com/node-gitlab/node-gitlab/tree/v1.1.0) (2014-11-04) ------------------- - -- Added project branch support -- Improved compatibility with API -- Improved global error handling -- Rebuilt javascript using latest Coffee-Script - -[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.0.0...v1.1.0) - -[1.0.0](https://github.com/node-gitlab/node-gitlab/tree/v1.0.0) (2014-08-19) ------------------- - -- Not fully stable, need more tests -- Now we have a CHANGELOG - -[POC](https://github.com/node-gitlab/node-gitlab/tree/e7a5eedea4c27aed8bd567a3c455ec311b915d60) (2012-12-11) ----------------- - -- POC +## DEPRECATED, see https://github.com/node-gitlab/node-gitlab