Skip to content
This repository was archived by the owner on Oct 24, 2019. It is now read-only.

Commit f8d103e

Browse files
authored
Merge pull request #139 from node-gitlab/develop
develop -> master
2 parents 98c21f7 + fe1b4b1 commit f8d103e

12 files changed

Lines changed: 233 additions & 5 deletions

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ MIT
122122
Changelog
123123
=========
124124

125+
[1.7.0](https://github.com/node-gitlab/node-gitlab/tree/v1.7.0) (2016-07-11)
126+
----------------------
127+
128+
- Add support for adding a tag to a project
129+
- Add gitlab.projects.repository.compare()
130+
- Add support for portion builds API
131+
- Set slumber version to non-breaking
132+
133+
[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.6.0...v1.7.0)
134+
135+
125136
[1.6.0](https://github.com/node-gitlab/node-gitlab/tree/v1.6.0) (2016-05-10)
126137
----------------------
127138

@@ -131,6 +142,8 @@ Changelog
131142
- Add support for the GitLab services API
132143
- Fix undefined assigneeId in merge request (#111)
133144

145+
[Full commits list](https://github.com/node-gitlab/node-gitlab/compare/v1.5.0...v1.6.0)
146+
134147
[1.5.0](https://github.com/node-gitlab/node-gitlab/tree/v1.5.0) (2015-11-26)
135148
----------------------
136149

lib/Models/ProjectBuilds.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
(function() {
2+
var BaseModel, ProjectBuilds, Utils,
3+
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
4+
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; },
5+
hasProp = {}.hasOwnProperty;
6+
7+
BaseModel = require('../BaseModel');
8+
9+
Utils = require('../Utils');
10+
11+
ProjectBuilds = (function(superClass) {
12+
extend(ProjectBuilds, superClass);
13+
14+
function ProjectBuilds() {
15+
this.triggerBuild = bind(this.triggerBuild, this);
16+
this.showBuild = bind(this.showBuild, this);
17+
this.listBuilds = bind(this.listBuilds, this);
18+
return ProjectBuilds.__super__.constructor.apply(this, arguments);
19+
}
20+
21+
ProjectBuilds.prototype.listBuilds = function(projectId, fn) {
22+
if (fn == null) {
23+
fn = null;
24+
}
25+
this.debug("Projects::listBuilds()");
26+
return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/builds", (function(_this) {
27+
return function(data) {
28+
if (fn) {
29+
return fn(data);
30+
}
31+
};
32+
})(this));
33+
};
34+
35+
ProjectBuilds.prototype.showBuild = function(projectId, buildId, fn) {
36+
if (fn == null) {
37+
fn = null;
38+
}
39+
this.debug("Projects::build()");
40+
return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/builds/" + buildId, null, (function(_this) {
41+
return function(data) {
42+
if (fn) {
43+
return fn(data);
44+
}
45+
};
46+
})(this));
47+
};
48+
49+
ProjectBuilds.prototype.triggerBuild = function(params, fn) {
50+
if (params == null) {
51+
params = {};
52+
}
53+
if (fn == null) {
54+
fn = null;
55+
}
56+
this.debug("Projects::triggerBuild()");
57+
return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/trigger/builds", params, null, (function(_this) {
58+
return function(data) {
59+
if (fn) {
60+
return fn(data);
61+
}
62+
};
63+
})(this));
64+
};
65+
66+
return ProjectBuilds;
67+
68+
})(BaseModel);
69+
70+
module.exports = function(client) {
71+
return new ProjectBuilds(client);
72+
};
73+
74+
}).call(this);

lib/Models/ProjectRepository.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
extend(ProjectRepository, superClass);
1313

1414
function ProjectRepository() {
15+
this.compare = bind(this.compare, this);
1516
this.updateFile = bind(this.updateFile, this);
1617
this.createFile = bind(this.createFile, this);
1718
this.showFile = bind(this.showFile, this);
@@ -20,6 +21,7 @@
2021
this.showCommit = bind(this.showCommit, this);
2122
this.listCommits = bind(this.listCommits, this);
2223
this.listTags = bind(this.listTags, this);
24+
this.addTag = bind(this.addTag, this);
2325
this.deleteBranch = bind(this.deleteBranch, this);
2426
this.createBranch = bind(this.createBranch, this);
2527
this.unprotectBranch = bind(this.unprotectBranch, this);
@@ -116,6 +118,23 @@
116118
})(this));
117119
};
118120

121+
ProjectRepository.prototype.addTag = function(params, fn) {
122+
if (params == null) {
123+
params = {};
124+
}
125+
if (fn == null) {
126+
fn = null;
127+
}
128+
this.debug("Projects::addTag()");
129+
return this.post("projects/" + (Utils.parseProjectId(params.id)) + "/repository/tags", params, (function(_this) {
130+
return function(data) {
131+
if (fn) {
132+
return fn(data);
133+
}
134+
};
135+
})(this));
136+
};
137+
119138
ProjectRepository.prototype.listTags = function(projectId, fn) {
120139
if (fn == null) {
121140
fn = null;
@@ -260,6 +279,23 @@
260279
})(this));
261280
};
262281

282+
ProjectRepository.prototype.compare = function(params, fn) {
283+
if (params == null) {
284+
params = {};
285+
}
286+
if (fn == null) {
287+
fn = null;
288+
}
289+
this.debug("Projects::compare()", params);
290+
return this.get("projects/" + (Utils.parseProjectId(params.projectId)) + "/repository/compare", params, (function(_this) {
291+
return function(data) {
292+
if (fn) {
293+
return fn(data);
294+
}
295+
};
296+
})(this));
297+
};
298+
263299
return ProjectRepository;
264300

265301
})(BaseModel);

lib/Models/Projects.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
extend(Projects, superClass);
1313

1414
function Projects() {
15+
this.listTriggers = bind(this.listTriggers, this);
1516
this.search = bind(this.search, this);
1617
this.fork = bind(this.fork, this);
1718
this.remove = bind(this.remove, this);
@@ -24,8 +25,8 @@
2425
this.create_for_user = bind(this.create_for_user, this);
2526
this.create = bind(this.create, this);
2627
this.show = bind(this.show, this);
27-
this.all = bind(this.all, this);
2828
this.allAdmin = bind(this.allAdmin, this);
29+
this.all = bind(this.all, this);
2930
this.init = bind(this.init, this);
3031
return Projects.__super__.constructor.apply(this, arguments);
3132
}
@@ -39,7 +40,8 @@
3940
this.milestones = this.load('ProjectMilestones');
4041
this.deploy_keys = this.load('ProjectDeployKeys');
4142
this.merge_requests = this.load('ProjectMergeRequests');
42-
return this.services = this.load('ProjectServices');
43+
this.services = this.load('ProjectServices');
44+
return this.builds = this.load('ProjectBuilds');
4345
};
4446

4547
Projects.prototype.all = function(params, fn) {
@@ -314,6 +316,20 @@
314316
})(this));
315317
};
316318

319+
Projects.prototype.listTriggers = function(projectId, fn) {
320+
if (fn == null) {
321+
fn = null;
322+
}
323+
this.debug("Projects::listTriggers()");
324+
return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/triggers", (function(_this) {
325+
return function(data) {
326+
if (fn) {
327+
return fn(data);
328+
}
329+
};
330+
})(this));
331+
};
332+
317333
return Projects;
318334

319335
})(BaseModel);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gitlab",
3-
"version": "1.6.0",
3+
"version": "1.7.0",
44
"description": "GitLab API Nodejs library.",
55
"main": "lib/index.js",
66
"directories": {
@@ -17,7 +17,7 @@
1717
},
1818
"dependencies": {
1919
"debug": "*",
20-
"slumber": ">=0.7.0"
20+
"slumber": "0.9.0"
2121
},
2222
"devDependencies": {
2323
"coffee-script": ">=1.9.1",

src/Models/ProjectBuilds.coffee

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
BaseModel = require '../BaseModel'
2+
Utils = require '../Utils'
3+
4+
class ProjectBuilds extends BaseModel
5+
6+
# === Builds
7+
listBuilds: (projectId, fn = null) =>
8+
@debug "Projects::listBuilds()"
9+
@get "projects/#{Utils.parseProjectId projectId}/builds", (data) => fn data if fn
10+
11+
showBuild: (projectId, buildId, fn = null) =>
12+
@debug "Projects::build()"
13+
@get "projects/#{Utils.parseProjectId projectId}/builds/#{buildId}", null, (data) => fn data if fn
14+
15+
triggerBuild: (params={}, fn = null) =>
16+
@debug "Projects::triggerBuild()"
17+
@post "projects/#{Utils.parseProjectId params.projectId}/trigger/builds", params, null, (data) => fn data if fn
18+
19+
module.exports = (client) -> new ProjectBuilds client

src/Models/ProjectRepository.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class ProjectRepository extends BaseModel
2929
@delete "projects/#{Utils.parseProjectId projectId}/repository/branches/#{encodeURI branchId}", (data) => fn data if fn
3030

3131
# === Tags
32+
addTag: (params = {}, fn = null) =>
33+
@debug "Projects::addTag()"
34+
@post "projects/#{Utils.parseProjectId params.id}/repository/tags", params, (data) => fn data if fn
35+
3236
listTags: (projectId, fn = null) =>
3337
@debug "Projects::listTags()"
3438
@get "projects/#{Utils.parseProjectId projectId}/repository/tags", (data) => fn data if fn
@@ -76,6 +80,10 @@ class ProjectRepository extends BaseModel
7680
@debug "Projects::updateFile()", params
7781
@put "projects/#{Utils.parseProjectId params.projectId}/repository/files", params, (data) => fn data if fn
7882

83+
compare: (params = {}, fn = null) =>
84+
@debug "Projects::compare()", params
85+
@get "projects/#{Utils.parseProjectId params.projectId}/repository/compare", params, (data) => fn data if fn
86+
7987
## TODO:
8088
# - Raw file content
8189
# - Raw blob content

src/Models/Projects.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Projects extends BaseModel
1212
@deploy_keys = @load 'ProjectDeployKeys'
1313
@merge_requests = @load 'ProjectMergeRequests'
1414
@services = @load 'ProjectServices'
15+
@builds = @load 'ProjectBuilds'
1516

1617
all: (params={}, fn=null) =>
1718
if 'function' is typeof params
@@ -113,4 +114,8 @@ class Projects extends BaseModel
113114
@debug "Projects::search()"
114115
@get "projects/search/#{projectName}", params, (data) => fn data if fn
115116

117+
listTriggers: (projectId, fn = null) =>
118+
@debug "Projects::listTriggers()"
119+
@get "projects/#{Utils.parseProjectId projectId}/triggers", (data) => fn data if fn
120+
116121
module.exports = (client) -> new Projects client

tests/ProjectRepository.test.coffee

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ describe "ProjectRepository", ->
3838
getStub.restore()
3939
expect(getStub).to.have.been.called
4040

41+
describe "addTag()", ->
42+
it "should use POST verb", ->
43+
postStub = sinon.stub repository, "post"
44+
45+
opts =
46+
id: 1,
47+
tag_name: "v1.0.0",
48+
ref: "2695effb5807a22ff3d138d593fd856244e155e7",
49+
message: "Annotated message",
50+
release_description: "Release description"
51+
repository.addTag opts
52+
53+
postStub.restore()
54+
expect(postStub).to.have.been.called
55+
4156
describe "listTags()", ->
4257
it "should use GET verb", ->
4358
getStub = sinon.stub repository, "get"
@@ -66,4 +81,4 @@ describe "ProjectRepository", ->
6681
}
6782

6883
getStub.restore()
69-
expect(getStub).to.have.been.called
84+
expect(getStub).to.have.been.called

tests/ProjectRepository.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@
4343
return expect(getStub).to.have.been.called;
4444
});
4545
});
46+
describe("addTag()", function() {
47+
return it("should use POST verb", function() {
48+
var opts, postStub;
49+
postStub = sinon.stub(repository, "post");
50+
opts = {
51+
id: 1,
52+
tag_name: "v1.0.0",
53+
ref: "2695effb5807a22ff3d138d593fd856244e155e7",
54+
message: "Annotated message",
55+
release_description: "Release description"
56+
};
57+
repository.addTag(opts);
58+
postStub.restore();
59+
return expect(postStub).to.have.been.called;
60+
});
61+
});
4662
describe("listTags()", function() {
4763
return it("should use GET verb", function() {
4864
var getStub;

0 commit comments

Comments
 (0)