Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add tags apis #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,157 @@ Parameters:

---

### Repository Tags

https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/tags.md

#### client.repositoryTags.list({id})

Get a list of repository tags from a project.

Parameters:

- id (required) - The ID or NAMESPACE/PROJECT_NAME of a project

```json
[
{
"commit": {
"author_name": "John Smith",
"author_email": "john@example.com",
"authored_date": "2012-05-28T04:42:42-07:00",
"committed_date": "2012-05-28T04:42:42-07:00",
"committer_name": "Jack Smith",
"committer_email": "jack@example.com",
"id": "2695effb5807a22ff3d138d593fd856244e155e7",
"message": "Initial commit",
"parents_ids": [
"2a4b78934375d7f53875269ffd4f45fd83a84ebe"
]
},
"release": {
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
},
"name": "v1.0.0",
"message": null
}
]
```

#### client.repositoryTags.get({id, tag_name})

Get a specific repository tag determined by its name.

Parameters:

- id (required) - The ID or NAMESPACE/PROJECT_NAME of a project
- tag_name (required) - The name of the tag

```json
{
"name": "v5.0.0",
"message": null,
"commit": {
"id": "60a8ff033665e1207714d6670fcd7b65304ec02f",
"message": "v5.0.0\n",
"parent_ids": [
"f61c062ff8bcbdb00e0a1b3317a91aed6ceee06b"
],
"authored_date": "2015-02-01T21:56:31.000+01:00",
"author_name": "Arthur Verschaeve",
"author_email": "contact@arthurverschaeve.be",
"committed_date": "2015-02-01T21:56:31.000+01:00",
"committer_name": "Arthur Verschaeve",
"committer_email": "contact@arthurverschaeve.be"
},
"release": null
}
```

#### client.repositoryTags.create({id, tag_name, ref})

Creates a new tag in the repository that points to the supplied ref.

Parameters:

- id (required) - The ID or NAMESPACE/PROJECT_NAME of a project
- tag_name (required) - The name of the tag
- ref (required) - Create tag using commit SHA, another tag name, or branch name.
- message (optional) - Creates annotated tag.
- release_description (optional) - Add release notes to the git tag and store it in the GitLab database.


```json
{
"commit": {
"author_name": "John Smith",
"author_email": "john@example.com",
"authored_date": "2012-05-28T04:42:42-07:00",
"committed_date": "2012-05-28T04:42:42-07:00",
"committer_name": "Jack Smith",
"committer_email": "jack@example.com",
"id": "2695effb5807a22ff3d138d593fd856244e155e7",
"message": "Initial commit",
"parents_ids": [
"2a4b78934375d7f53875269ffd4f45fd83a84ebe"
]
},
"release": {
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
},
"name": "v1.0.0",
"message": null
}
```

#### client.repositoryTags.remove({id, tag_name})

Deletes a tag of a repository with given name.

Parameters:

- `id` (required) - The ID of a project
- `tag_name` (required) - The name of a tag

#### client.repositoryTags.createRelease({id, tag_name, description})

Add release notes to the existing git tag. If there
already exists a release for the given tag, status code `409` is returned.

Parameters:

- `id` (required) - The ID of a project
- `tag_name` (required) - The name of a tag
- `description` (required) - Release notes with markdown support

```json
{
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
}
```

#### client.repositoryTags.updateRelease({id, tag_name, description})

Updates the release notes of a given release.

Parameters:

- `id` (required) - The ID of a project
- `tag_name` (required) - The name of a tag
- `description` (required) - Release notes with markdown support

```json
{
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
}
```

---

### Issues

https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/issues.md
Expand Down
2 changes: 2 additions & 0 deletions lib/resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ module.exports = {

repositoryBranches: require('./repository_branch'),

repositoryTags: require('./repository_tag'),

repositoryFiles: {
resourcePath: '/projects/:id/repository/files'
},
Expand Down
22 changes: 22 additions & 0 deletions lib/resources/repository_tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var util = require('util')
var restful = require('restful-client')

function Tag(client) {
this.constructor.super_.call(this, client, '/projects/:id/repository/tags', 'tag_name');
}

util.inherits(Tag, restful.RESTFulResource);

Tag.prototype.createRelease = function (params, callback) {
this.client.request('post', this.onePath + '/release', params, callback);
return this;
};

Tag.prototype.updateRelease = function (params, callback) {
this.client.request('put', this.onePath + '/release', params, callback);
return this;
};

module.exports = Tag;
6 changes: 3 additions & 3 deletions test/repository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe.skip('repository.test.js', function () {
});
});
});

describe('client.repository.archive()', function () {
it('should return archive file', function (done) {
client.repository.archive({id: 55045, sha: '946579807281bd26b75b91986c78f15ad0bd40f7'}, function (err, raw) {
Expand All @@ -248,7 +248,7 @@ describe.skip('repository.test.js', function () {
});
});
});

describe('client.repository.compare()', function () {
it('should return diffs', function (done) {
client.repository.compare({id: 55045, to: 'master', from: '946579807281bd26b75b91986c78f15ad0bd40f7'}, function (err, diffs) {
Expand All @@ -260,5 +260,5 @@ describe.skip('repository.test.js', function () {
done();
});
});
});
});
});
Loading