gitlab 4.1.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/lib/gitlab/client.rb +4 -0
  4. data/lib/gitlab/client/award_emojis.rb +135 -0
  5. data/lib/gitlab/client/boards.rb +88 -0
  6. data/lib/gitlab/client/branches.rb +12 -7
  7. data/lib/gitlab/client/commits.rb +6 -6
  8. data/lib/gitlab/client/environments.rb +87 -0
  9. data/lib/gitlab/client/labels.rb +33 -4
  10. data/lib/gitlab/client/merge_requests.rb +0 -59
  11. data/lib/gitlab/client/notes.rb +106 -0
  12. data/lib/gitlab/client/projects.rb +48 -44
  13. data/lib/gitlab/client/repository_files.rb +32 -26
  14. data/lib/gitlab/client/system_hooks.rb +5 -2
  15. data/lib/gitlab/client/todos.rb +44 -0
  16. data/lib/gitlab/version.rb +1 -1
  17. data/spec/fixtures/board_list.json +1 -0
  18. data/spec/fixtures/board_lists.json +1 -0
  19. data/spec/fixtures/boards.json +1 -0
  20. data/spec/fixtures/environment.json +6 -0
  21. data/spec/fixtures/environments.json +14 -0
  22. data/spec/fixtures/issue_award_emoji.json +16 -0
  23. data/spec/fixtures/issue_award_emojis.json +34 -0
  24. data/spec/fixtures/label.json +1 -1
  25. data/spec/fixtures/label_unsubscribe.json +1 -0
  26. data/spec/fixtures/merge_request_award_emoji.json +16 -0
  27. data/spec/fixtures/merge_request_award_emojis.json +34 -0
  28. data/spec/fixtures/note_award_emoji.json +16 -0
  29. data/spec/fixtures/note_award_emojis.json +18 -0
  30. data/spec/fixtures/snippet_award_emoji.json +16 -0
  31. data/spec/fixtures/snippet_award_emojis.json +34 -0
  32. data/spec/fixtures/todo.json +73 -0
  33. data/spec/fixtures/todos.json +148 -0
  34. data/spec/gitlab/client/award_emojis_spec.rb +391 -0
  35. data/spec/gitlab/client/boards_spec.rb +94 -0
  36. data/spec/gitlab/client/branches_spec.rb +22 -5
  37. data/spec/gitlab/client/commits_spec.rb +2 -2
  38. data/spec/gitlab/client/environments_spec.rb +132 -0
  39. data/spec/gitlab/client/groups_spec.rb +10 -12
  40. data/spec/gitlab/client/labels_spec.rb +32 -0
  41. data/spec/gitlab/client/notes_spec.rb +128 -0
  42. data/spec/gitlab/client/projects_spec.rb +20 -10
  43. data/spec/gitlab/client/repository_files_spec.rb +30 -12
  44. data/spec/gitlab/client/system_hooks_spec.rb +2 -2
  45. data/spec/gitlab/client/todos_spec.rb +45 -0
  46. metadata +46 -2
@@ -45,17 +45,19 @@ class Gitlab::Client
45
45
  # Gitlab.create_file(42, "path", "branch", "content", "commit message")
46
46
  #
47
47
  # @param [Integer, String] project The ID or name of a project.
48
- # @param [String] full path to new file.
49
- # @param [String] the name of the branch.
50
- # @param [String] file content.
51
- # @param [String] commit message.
48
+ # @param [String] path full path to new file.
49
+ # @param [String] branch the name of the branch.
50
+ # @param [String] content file content.
51
+ # @param [String] commit_message ...commit message.
52
+ # @param [Hash] options Optional additional details for commit
53
+ # @option options [String] :author_name Commit author's name
54
+ # @option options [String] :author_email Commit author's email address
52
55
  # @return [Gitlab::ObjectifiedHash]
53
- def create_file(project, path, branch, content, commit_message)
54
- post("/projects/#{url_encode project}/repository/files", body: {
55
- file_path: path,
56
- branch_name: branch,
56
+ def create_file(project, path, branch, content, commit_message, options = {})
57
+ post("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: {
58
+ branch: branch,
57
59
  commit_message: commit_message
58
- }.merge(encoded_content_attributes(content)))
60
+ }.merge(options).merge(encoded_content_attributes(content)))
59
61
  end
60
62
 
61
63
  # Edits an existing repository file.
@@ -64,17 +66,19 @@ class Gitlab::Client
64
66
  # Gitlab.edit_file(42, "path", "branch", "content", "commit message")
65
67
  #
66
68
  # @param [Integer, String] project The ID or name of a project.
67
- # @param [String] full path to new file.
68
- # @param [String] the name of the branch.
69
- # @param [String] file content.
70
- # @param [String] commit message.
69
+ # @param [String] path full path of file to update.
70
+ # @param [String] branch the name of the branch to commit changes to.
71
+ # @param [String] content new file content.
72
+ # @param [String] commit_message ...commit message.
73
+ # @param [Hash] options Optional additional details for commit
74
+ # @option options [String] :author_name Commit author's name
75
+ # @option options [String] :author_email Commit author's email address
71
76
  # @return [Gitlab::ObjectifiedHash]
72
- def edit_file(project, path, branch, content, commit_message)
73
- put("/projects/#{url_encode project}/repository/files", body: {
74
- file_path: path,
75
- branch_name: branch,
77
+ def edit_file(project, path, branch, content, commit_message, options = {})
78
+ put("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: {
79
+ branch: branch,
76
80
  commit_message: commit_message
77
- }.merge(encoded_content_attributes(content)))
81
+ }.merge(options).merge(encoded_content_attributes(content)))
78
82
  end
79
83
 
80
84
  # Removes an existing repository file.
@@ -83,16 +87,18 @@ class Gitlab::Client
83
87
  # Gitlab.remove_file(42, "path", "branch", "commit message")
84
88
  #
85
89
  # @param [Integer, String] project The ID or name of a project.
86
- # @param [String] full path to new file.
87
- # @param [String] the name of the branch.
88
- # @param [String] commit message.
90
+ # @param [String] path full path of file to delete.
91
+ # @param [String] branch the name of the branch to commit the deletion to.
92
+ # @param [String] commit_message ...a commit message ;)
93
+ # @param [Hash] options Optional additional details for commit
94
+ # @option options [String] :author_name Commit author's name
95
+ # @option options [String] :author_email Commit author's email address
89
96
  # @return [Gitlab::ObjectifiedHash]
90
- def remove_file(project, path, branch, commit_message)
91
- delete("/projects/#{url_encode project}/repository/files", body: {
92
- file_path: path,
93
- branch_name: branch,
97
+ def remove_file(project, path, branch, commit_message, options = {})
98
+ delete("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: {
99
+ branch: branch,
94
100
  commit_message: commit_message
95
- })
101
+ }.merge(options))
96
102
  end
97
103
 
98
104
  private
@@ -24,9 +24,12 @@ class Gitlab::Client
24
24
  # Gitlab.add_system_hook('https://api.example.net/v1/hook')
25
25
  #
26
26
  # @param [String] url The hook URL.
27
+ # @param [Hash] options Additional options, as allowed by Gitlab API, including but not limited to:
28
+ # @option options [String] :token A secret token for Gitlab to send in the `X-Gitlab-Token` header for authentication.
29
+ # @option options [boolean] :enable_ssl_verification `false` will cause Gitlab to ignore invalid/unsigned certificate errors (default is `true`)
27
30
  # @return [Gitlab::ObjectifiedHash]
28
- def add_hook(url)
29
- post("/hooks", body: { url: url })
31
+ def add_hook(url, options = {})
32
+ post("/hooks", body: options.merge(url: url))
30
33
  end
31
34
  alias_method :add_system_hook, :add_hook
32
35
 
@@ -0,0 +1,44 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to todos
3
+ # @see https://docs.gitlab.com/ce/api/todos.html
4
+ module Todos
5
+ # Gets a list of todos.
6
+ #
7
+ # @example
8
+ # Gitlab.todos
9
+ # Gitlab.todos({ action: 'assigned' })
10
+ # Gitlab.todos({ state: 'pending' })
11
+ #
12
+ # @param [Hash] options A customizable set of options.
13
+ # @option options [Integer] :action The action to be filtered. Can be `assigned`, `mentioned`, `build_failed`, `marked`, or `approval_required`.
14
+ # @option options [Integer] :author_id The ID of an author
15
+ # @option options [Integer] :project_id The ID of a project
16
+ # @option options [Integer] :state The state of the todo. Can be either `pending` or `done`
17
+ # @option options [Integer] :type The type of a todo. Can be either `Issue` or `MergeRequest`
18
+ # @return [Array<Gitlab::ObjectifiedHash>]
19
+ def todos(options={})
20
+ get("/todos", query: options)
21
+ end
22
+
23
+ # Marks a single pending todo for the current user as done.
24
+ #
25
+ # @example
26
+ # Gitlab.mark_todo_as_done(42)
27
+ #
28
+ # @param [Integer] id The ID of the todo.
29
+ # @return [Gitlab::ObjectifiedHash]
30
+ def mark_todo_as_done(id)
31
+ post("/todos/#{id}/mark_as_done")
32
+ end
33
+
34
+ # Marks all todos for the current user as done
35
+ #
36
+ # @example
37
+ # Gitlab.mark_all_todos_as_done
38
+ #
39
+ # @return [void] This API call returns an empty response body.
40
+ def mark_all_todos_as_done
41
+ post("/todos/mark_as_done")
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Gitlab
2
- VERSION = "4.1.0"
2
+ VERSION = "4.2.0"
3
3
  end
@@ -0,0 +1 @@
1
+ { "id" : 1, "label" : { "name" : "Testing", "color" : "#F0AD4E", "description" : null }, "position" : 1 }
@@ -0,0 +1 @@
1
+ [ { "id" : 1, "label" : { "name" : "Testing", "color" : "#F0AD4E", "description" : null }, "position" : 1 }, { "id" : 2, "label" : { "name" : "Ready", "color" : "#FF0000", "description" : null }, "position" : 2 }, { "id" : 3, "label" : { "name" : "Production", "color" : "#FF5F00", "description" : null }, "position" : 3 } ]
@@ -0,0 +1 @@
1
+ [ { "id" : 1, "lists" : [ { "id" : 1, "label" : { "name" : "Testing", "color" : "#F0AD4E", "description" : null }, "position" : 1 }, { "id" : 2, "label" : { "name" : "Ready", "color" : "#FF0000", "description" : null }, "position" : 2 }, { "id" : 3, "label" : { "name" : "Production", "color" : "#FF5F00", "description" : null }, "position" : 3 } ] } ]
@@ -0,0 +1,6 @@
1
+ {
2
+ "id": 12,
3
+ "name": "staging",
4
+ "slug": "staging-cb247rv",
5
+ "external_url": "https://staging.example.gitlab.com"
6
+ }
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "name": "review/fix-foo",
5
+ "slug": "review-fix-foo-dfjre3",
6
+ "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com"
7
+ },
8
+ {
9
+ "id": 12,
10
+ "name": "review/fix-bar",
11
+ "slug": "review-fix-bar-dbwr18",
12
+ "external_url": "https://review-fix-bar-dbwr18.example.gitlab.com"
13
+ }
14
+ ]
@@ -0,0 +1,16 @@
1
+ {
2
+ "id": 4,
3
+ "name": "blowfish",
4
+ "user": {
5
+ "name": "Administrator",
6
+ "username": "root",
7
+ "id": 1,
8
+ "state": "active",
9
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
10
+ "web_url": "http://gitlab.example.com/root"
11
+ },
12
+ "created_at": "2016-06-15T10:09:34.206Z",
13
+ "updated_at": "2016-06-15T10:09:34.206Z",
14
+ "awardable_id": 80,
15
+ "awardable_type": "Issue"
16
+ }
@@ -0,0 +1,34 @@
1
+ [
2
+ {
3
+ "id": 4,
4
+ "name": "1234",
5
+ "user": {
6
+ "name": "Administrator",
7
+ "username": "root",
8
+ "id": 1,
9
+ "state": "active",
10
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
11
+ "web_url": "http://gitlab.example.com/root"
12
+ },
13
+ "created_at": "2016-06-15T10:09:34.206Z",
14
+ "updated_at": "2016-06-15T10:09:34.206Z",
15
+ "awardable_id": 80,
16
+ "awardable_type": "Issue"
17
+ },
18
+ {
19
+ "id": 1,
20
+ "name": "microphone",
21
+ "user": {
22
+ "name": "User 4",
23
+ "username": "user4",
24
+ "id": 26,
25
+ "state": "active",
26
+ "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon",
27
+ "web_url": "http://gitlab.example.com/user4"
28
+ },
29
+ "created_at": "2016-06-15T10:09:34.177Z",
30
+ "updated_at": "2016-06-15T10:09:34.177Z",
31
+ "awardable_id": 80,
32
+ "awardable_type": "Issue"
33
+ }
34
+ ]
@@ -1 +1 @@
1
- {"name": "Backlog", "color": "#DD10AA"}
1
+ {"name": "Backlog", "color": "#DD10AA", "subscribed": true}
@@ -0,0 +1 @@
1
+ {"name": "Backlog", "color": "#DD10AA", "subscribed": false}
@@ -0,0 +1,16 @@
1
+ {
2
+ "id": 4,
3
+ "name": "blowfish",
4
+ "user": {
5
+ "name": "Administrator",
6
+ "username": "root",
7
+ "id": 1,
8
+ "state": "active",
9
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
10
+ "web_url": "http://gitlab.example.com/root"
11
+ },
12
+ "created_at": "2016-06-15T10:09:34.206Z",
13
+ "updated_at": "2016-06-15T10:09:34.206Z",
14
+ "awardable_id": 80,
15
+ "awardable_type": "MergeRequest"
16
+ }
@@ -0,0 +1,34 @@
1
+ [
2
+ {
3
+ "id": 4,
4
+ "name": "1234",
5
+ "user": {
6
+ "name": "Administrator",
7
+ "username": "root",
8
+ "id": 1,
9
+ "state": "active",
10
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
11
+ "web_url": "http://gitlab.example.com/root"
12
+ },
13
+ "created_at": "2016-06-15T10:09:34.206Z",
14
+ "updated_at": "2016-06-15T10:09:34.206Z",
15
+ "awardable_id": 80,
16
+ "awardable_type": "MergeRequest"
17
+ },
18
+ {
19
+ "id": 1,
20
+ "name": "microphone",
21
+ "user": {
22
+ "name": "User 4",
23
+ "username": "user4",
24
+ "id": 26,
25
+ "state": "active",
26
+ "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon",
27
+ "web_url": "http://gitlab.example.com/user4"
28
+ },
29
+ "created_at": "2016-06-15T10:09:34.177Z",
30
+ "updated_at": "2016-06-15T10:09:34.177Z",
31
+ "awardable_id": 80,
32
+ "awardable_type": "MergeRequest"
33
+ }
34
+ ]
@@ -0,0 +1,16 @@
1
+ {
2
+ "id": 4,
3
+ "name": "mood_bubble_lightning",
4
+ "user": {
5
+ "name": "User 4",
6
+ "username": "user4",
7
+ "id": 26,
8
+ "state": "active",
9
+ "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon",
10
+ "web_url": "http://gitlab.example.com/user4"
11
+ },
12
+ "created_at": "2016-06-15T10:09:34.197Z",
13
+ "updated_at": "2016-06-15T10:09:34.197Z",
14
+ "awardable_id": 1,
15
+ "awardable_type": "Note"
16
+ }
@@ -0,0 +1,18 @@
1
+ [
2
+ {
3
+ "id": 2,
4
+ "name": "mood_bubble_lightning",
5
+ "user": {
6
+ "name": "User 4",
7
+ "username": "user4",
8
+ "id": 26,
9
+ "state": "active",
10
+ "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon",
11
+ "web_url": "http://gitlab.example.com/user4"
12
+ },
13
+ "created_at": "2016-06-15T10:09:34.197Z",
14
+ "updated_at": "2016-06-15T10:09:34.197Z",
15
+ "awardable_id": 1,
16
+ "awardable_type": "Note"
17
+ }
18
+ ]
@@ -0,0 +1,16 @@
1
+ {
2
+ "id": 4,
3
+ "name": "blowfish",
4
+ "user": {
5
+ "name": "Administrator",
6
+ "username": "root",
7
+ "id": 1,
8
+ "state": "active",
9
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
10
+ "web_url": "http://gitlab.example.com/root"
11
+ },
12
+ "created_at": "2016-06-15T10:09:34.206Z",
13
+ "updated_at": "2016-06-15T10:09:34.206Z",
14
+ "awardable_id": 80,
15
+ "awardable_type": "Snippet"
16
+ }
@@ -0,0 +1,34 @@
1
+ [
2
+ {
3
+ "id": 4,
4
+ "name": "1234",
5
+ "user": {
6
+ "name": "Administrator",
7
+ "username": "root",
8
+ "id": 1,
9
+ "state": "active",
10
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
11
+ "web_url": "http://gitlab.example.com/root"
12
+ },
13
+ "created_at": "2016-06-15T10:09:34.206Z",
14
+ "updated_at": "2016-06-15T10:09:34.206Z",
15
+ "awardable_id": 80,
16
+ "awardable_type": "Snippet"
17
+ },
18
+ {
19
+ "id": 1,
20
+ "name": "microphone",
21
+ "user": {
22
+ "name": "User 4",
23
+ "username": "user4",
24
+ "id": 26,
25
+ "state": "active",
26
+ "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon",
27
+ "web_url": "http://gitlab.example.com/user4"
28
+ },
29
+ "created_at": "2016-06-15T10:09:34.177Z",
30
+ "updated_at": "2016-06-15T10:09:34.177Z",
31
+ "awardable_id": 80,
32
+ "awardable_type": "Snippet"
33
+ }
34
+ ]
@@ -0,0 +1,73 @@
1
+ {
2
+ "id": 102,
3
+ "project": {
4
+ "id": 2,
5
+ "name": "Gitlab Ce",
6
+ "name_with_namespace": "Gitlab Org / Gitlab Ce",
7
+ "path": "gitlab-ce",
8
+ "path_with_namespace": "gitlab-org/gitlab-ce"
9
+ },
10
+ "author": {
11
+ "name": "Administrator",
12
+ "username": "root",
13
+ "id": 1,
14
+ "state": "active",
15
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
16
+ "web_url": "https://gitlab.example.com/root"
17
+ },
18
+ "action_name": "marked",
19
+ "target_type": "MergeRequest",
20
+ "target": {
21
+ "id": 34,
22
+ "iid": 7,
23
+ "project_id": 2,
24
+ "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
25
+ "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.",
26
+ "state": "opened",
27
+ "created_at": "2016-06-17T07:49:24.419Z",
28
+ "updated_at": "2016-06-17T07:52:43.484Z",
29
+ "target_branch": "tutorials_git_tricks",
30
+ "source_branch": "DNSBL_docs",
31
+ "upvotes": 0,
32
+ "downvotes": 0,
33
+ "author": {
34
+ "name": "Maxie Medhurst",
35
+ "username": "craig_rutherford",
36
+ "id": 12,
37
+ "state": "active",
38
+ "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
39
+ "web_url": "https://gitlab.example.com/craig_rutherford"
40
+ },
41
+ "assignee": {
42
+ "name": "Administrator",
43
+ "username": "root",
44
+ "id": 1,
45
+ "state": "active",
46
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
47
+ "web_url": "https://gitlab.example.com/root"
48
+ },
49
+ "source_project_id": 2,
50
+ "target_project_id": 2,
51
+ "labels": [],
52
+ "work_in_progress": false,
53
+ "milestone": {
54
+ "id": 32,
55
+ "iid": 2,
56
+ "project_id": 2,
57
+ "title": "v1.0",
58
+ "description": "Assumenda placeat ea voluptatem voluptate qui.",
59
+ "state": "active",
60
+ "created_at": "2016-06-17T07:47:34.163Z",
61
+ "updated_at": "2016-06-17T07:47:34.163Z",
62
+ "due_date": null
63
+ },
64
+ "merge_when_pipeline_succeeds": false,
65
+ "merge_status": "cannot_be_merged",
66
+ "subscribed": true,
67
+ "user_notes_count": 7
68
+ },
69
+ "target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7",
70
+ "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
71
+ "state": "done",
72
+ "created_at": "2016-06-17T07:52:35.225Z"
73
+ }