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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop: (34 commits)
  v1.4.0
  Removed sourcegraph badges
  Reverted version number change
  Added project search functionality
  Added Steve Norman to Contributors list.
  Added ability to get users keys
  Fixed loading all users and groups by getting all pages.
  Added Felix Fichte to Contributors list.
  Drop 0.8 from Travis, add 0.12.
  Containers *are* cool Travis.
  Update ProjectMilestones.coffee
  Update ProjectMilestones.coffee
  showcase new option
  add possibility to pass params to list milestones
  Added functionality to remove projects
  Use headers for PRIVATE-TOKEN
  Fix broken link for HTTP api
  Use cake and mocha under node_modules
  Added Connor Weng to Contributors list.
  Update LICENSE.md
  ...
  • Loading branch information
moul committed Aug 11, 2015
2 parents d338c9a + 6ff5fa6 commit 39cbeb7
Show file tree
Hide file tree
Showing 40 changed files with 552 additions and 280 deletions.
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: node_js
node_js:
- "0.12"
- "0.11"
- "0.10"
- "0.8"
sudo: false
notifications:
webhooks:
urls:
Expand Down
14 changes: 8 additions & 6 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -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?
Expand All @@ -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 ->
Expand Down
24 changes: 24 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
The MIT License
===============

Copyright (c)
**2012-2015 Manfred Touron** <[email protected]> ([@moul](https://twitter.com/moul)),
**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
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.
44 changes: 35 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ 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)

[![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/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)

Expand Down Expand Up @@ -105,6 +102,10 @@ Contributors
- [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)

License
-------
Expand All @@ -115,7 +116,27 @@ MIT
Changelog
=========

1.3.0 (2015-02-09)
[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...develop)

[1.3.0](https://github.com/node-gitlab/node-gitlab/tree/v1.3.0) (2015-02-09)
------------------

- Now handling notes
Expand All @@ -125,7 +146,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
Expand All @@ -134,16 +155,21 @@ 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
- Improved compatibility with API
- 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
12 changes: 6 additions & 6 deletions examples/list-projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
12 changes: 6 additions & 6 deletions examples/list-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
18 changes: 9 additions & 9 deletions examples/reset-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -43,7 +43,7 @@
});
})());
}
return _results;
return results;
});

}).call(this);
5 changes: 5 additions & 0 deletions examples/show-project.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions lib/ApiBase.js
Original file line number Diff line number Diff line change
@@ -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()");
};
Expand Down
50 changes: 26 additions & 24 deletions lib/ApiBaseHTTP.js
Original file line number Diff line number Diff line change
@@ -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');

Expand All @@ -12,39 +12,39 @@

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";
}
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) {
Expand All @@ -64,17 +64,19 @@
if (opts.__query == null) {
opts.__query = {};
}
opts.__query.private_token = this.options.token;
opts.headers = {
'PRIVATE-TOKEN': this.options.token
};
return opts;
};

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.";
}
}
Expand Down
Loading

0 comments on commit 39cbeb7

Please sign in to comment.