gitlab 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.travis.yml +6 -2
  4. data/CHANGELOG.md +244 -0
  5. data/CONTRIBUTING.md +195 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.md +122 -10
  8. data/Rakefile +1 -1
  9. data/bin/console +10 -0
  10. data/bin/setup +6 -0
  11. data/exe/gitlab +7 -0
  12. data/gitlab.gemspec +9 -3
  13. data/lib/gitlab.rb +18 -2
  14. data/lib/gitlab/api.rb +6 -4
  15. data/lib/gitlab/cli.rb +89 -0
  16. data/lib/gitlab/cli_helpers.rb +241 -0
  17. data/lib/gitlab/client.rb +42 -6
  18. data/lib/gitlab/client/branches.rb +91 -0
  19. data/lib/gitlab/client/build_triggers.rb +51 -0
  20. data/lib/gitlab/client/build_variables.rb +66 -0
  21. data/lib/gitlab/client/builds.rb +106 -0
  22. data/lib/gitlab/client/commits.rb +146 -0
  23. data/lib/gitlab/client/groups.rb +66 -10
  24. data/lib/gitlab/client/issues.rb +61 -16
  25. data/lib/gitlab/client/labels.rb +57 -0
  26. data/lib/gitlab/client/merge_requests.rb +137 -26
  27. data/lib/gitlab/client/milestones.rb +44 -9
  28. data/lib/gitlab/client/namespaces.rb +20 -0
  29. data/lib/gitlab/client/notes.rb +71 -16
  30. data/lib/gitlab/client/pipelines.rb +68 -0
  31. data/lib/gitlab/client/projects.rb +236 -27
  32. data/lib/gitlab/client/repositories.rb +39 -45
  33. data/lib/gitlab/client/repository_files.rb +107 -0
  34. data/lib/gitlab/client/runners.rb +115 -0
  35. data/lib/gitlab/client/services.rb +50 -0
  36. data/lib/gitlab/client/snippets.rb +26 -21
  37. data/lib/gitlab/client/system_hooks.rb +59 -0
  38. data/lib/gitlab/client/tags.rb +96 -0
  39. data/lib/gitlab/client/users.rb +151 -7
  40. data/lib/gitlab/configuration.rb +20 -4
  41. data/lib/gitlab/error.rb +55 -12
  42. data/lib/gitlab/file_response.rb +46 -0
  43. data/lib/gitlab/help.rb +95 -0
  44. data/lib/gitlab/objectified_hash.rb +19 -3
  45. data/lib/gitlab/page_links.rb +33 -0
  46. data/lib/gitlab/paginated_response.rb +97 -0
  47. data/lib/gitlab/request.rb +65 -33
  48. data/lib/gitlab/shell.rb +84 -0
  49. data/lib/gitlab/shell_history.rb +59 -0
  50. data/lib/gitlab/version.rb +1 -1
  51. data/spec/fixtures/{project_branch.json → branch.json} +1 -1
  52. data/spec/fixtures/branch_delete.json +3 -0
  53. data/spec/fixtures/{project_branches.json → branches.json} +0 -0
  54. data/spec/fixtures/build.json +38 -0
  55. data/spec/fixtures/build_artifacts.json +0 -0
  56. data/spec/fixtures/build_cancel.json +24 -0
  57. data/spec/fixtures/build_erase.json +24 -0
  58. data/spec/fixtures/build_retry.json +24 -0
  59. data/spec/fixtures/builds.json +78 -0
  60. data/spec/fixtures/builds_commits.json +64 -0
  61. data/spec/fixtures/compare_merge_request_diff.json +31 -0
  62. data/spec/fixtures/error_project_not_found.json +1 -0
  63. data/spec/fixtures/get_repository_file.json +1 -0
  64. data/spec/fixtures/group_create_with_description.json +1 -0
  65. data/spec/fixtures/group_delete.json +1 -0
  66. data/spec/fixtures/group_member_edit.json +1 -0
  67. data/spec/fixtures/group_projects.json +44 -0
  68. data/spec/fixtures/group_search.json +2 -0
  69. data/spec/fixtures/label.json +1 -0
  70. data/spec/fixtures/labels.json +1 -0
  71. data/spec/fixtures/merge_request_changes.json +1 -0
  72. data/spec/fixtures/merge_request_closes_issues.json +1 -0
  73. data/spec/fixtures/{comment_merge_request.json → merge_request_comment.json} +0 -0
  74. data/spec/fixtures/merge_request_comments.json +1 -0
  75. data/spec/fixtures/merge_request_commits.json +1 -0
  76. data/spec/fixtures/milestone_issues.json +1 -0
  77. data/spec/fixtures/milestone_merge_requests.json +1 -0
  78. data/spec/fixtures/namespaces.json +1 -0
  79. data/spec/fixtures/pipeline.json +23 -0
  80. data/spec/fixtures/pipeline_cancel.json +23 -0
  81. data/spec/fixtures/pipeline_create.json +23 -0
  82. data/spec/fixtures/pipeline_retry.json +23 -0
  83. data/spec/fixtures/pipelines.json +48 -0
  84. data/spec/fixtures/project_commit.json +13 -0
  85. data/spec/fixtures/project_commit_comment.json +1 -0
  86. data/spec/fixtures/project_commit_comments.json +1 -0
  87. data/spec/fixtures/project_commit_create.json +22 -0
  88. data/spec/fixtures/project_commit_diff.json +10 -0
  89. data/spec/fixtures/project_commit_status.json +42 -0
  90. data/spec/fixtures/project_edit.json +21 -0
  91. data/spec/fixtures/project_events.json +1 -0
  92. data/spec/fixtures/project_fork.json +50 -0
  93. data/spec/fixtures/project_forked_for_user.json +50 -0
  94. data/spec/fixtures/project_runner_enable.json +7 -0
  95. data/spec/fixtures/project_runners.json +16 -0
  96. data/spec/fixtures/project_search.json +1 -0
  97. data/spec/fixtures/project_star.json +44 -0
  98. data/spec/fixtures/project_tag_annotated.json +1 -0
  99. data/spec/fixtures/project_tag_lightweight.json +1 -0
  100. data/spec/fixtures/project_unstar.json +44 -0
  101. data/spec/fixtures/project_update_commit_status.json +20 -0
  102. data/spec/fixtures/push_rule.json +1 -0
  103. data/spec/fixtures/raw_file.json +2 -0
  104. data/spec/fixtures/release_create.json +1 -0
  105. data/spec/fixtures/release_update.json +1 -0
  106. data/spec/fixtures/repository_file.json +1 -0
  107. data/spec/fixtures/runner.json +26 -0
  108. data/spec/fixtures/runner_delete.json +7 -0
  109. data/spec/fixtures/runner_edit.json +26 -0
  110. data/spec/fixtures/runners.json +16 -0
  111. data/spec/fixtures/runners_all.json +30 -0
  112. data/spec/fixtures/service.json +1 -0
  113. data/spec/fixtures/shell_history.json +2 -0
  114. data/spec/fixtures/snippet_content.json +3 -0
  115. data/spec/fixtures/system_hook.json +1 -0
  116. data/spec/fixtures/system_hooks.json +1 -0
  117. data/spec/fixtures/tag.json +1 -0
  118. data/spec/fixtures/tag_create.json +1 -0
  119. data/spec/fixtures/tag_create_with_description.json +1 -0
  120. data/spec/fixtures/tag_delete.json +1 -0
  121. data/spec/fixtures/tags.json +1 -0
  122. data/spec/fixtures/tree.json +1 -0
  123. data/spec/fixtures/trigger.json +7 -0
  124. data/spec/fixtures/triggers.json +16 -0
  125. data/spec/fixtures/user.json +1 -1
  126. data/spec/fixtures/user_block_unblock.json +1 -0
  127. data/spec/fixtures/user_email.json +1 -0
  128. data/spec/fixtures/user_emails.json +1 -0
  129. data/spec/fixtures/user_search.json +1 -0
  130. data/spec/fixtures/users.json +1 -1
  131. data/spec/fixtures/variable.json +4 -0
  132. data/spec/fixtures/variables.json +10 -0
  133. data/spec/gitlab/cli_helpers_spec.rb +57 -0
  134. data/spec/gitlab/cli_spec.rb +119 -0
  135. data/spec/gitlab/client/branches_spec.rb +99 -0
  136. data/spec/gitlab/client/build_triggers_spec.rb +67 -0
  137. data/spec/gitlab/client/build_variables_spec.rb +86 -0
  138. data/spec/gitlab/client/builds_spec.rb +148 -0
  139. data/spec/gitlab/client/client_spec.rb +11 -0
  140. data/spec/gitlab/client/commits_spec.rb +168 -0
  141. data/spec/gitlab/client/groups_spec.rb +116 -30
  142. data/spec/gitlab/client/issues_spec.rb +93 -29
  143. data/spec/gitlab/client/labels_spec.rb +68 -0
  144. data/spec/gitlab/client/merge_requests_spec.rb +171 -39
  145. data/spec/gitlab/client/milestones_spec.rb +45 -13
  146. data/spec/gitlab/client/namespaces_spec.rb +22 -0
  147. data/spec/gitlab/client/notes_spec.rb +82 -33
  148. data/spec/gitlab/client/pipelines_spec.rb +95 -0
  149. data/spec/gitlab/client/projects_spec.rb +371 -71
  150. data/spec/gitlab/client/repositories_spec.rb +51 -30
  151. data/spec/gitlab/client/repository_files_spec.rb +77 -0
  152. data/spec/gitlab/client/runners_spec.rb +185 -0
  153. data/spec/gitlab/client/services_spec.rb +55 -0
  154. data/spec/gitlab/client/snippets_spec.rb +35 -20
  155. data/spec/gitlab/client/system_hooks_spec.rb +69 -0
  156. data/spec/gitlab/client/tags_spec.rb +109 -0
  157. data/spec/gitlab/client/users_spec.rb +296 -34
  158. data/spec/gitlab/error_spec.rb +45 -0
  159. data/spec/gitlab/file_response_spec.rb +33 -0
  160. data/spec/gitlab/help_spec.rb +46 -0
  161. data/spec/gitlab/objectified_hash_spec.rb +48 -0
  162. data/spec/gitlab/page_links_spec.rb +16 -0
  163. data/spec/gitlab/paginated_response_spec.rb +60 -0
  164. data/spec/gitlab/request_spec.rb +73 -0
  165. data/spec/gitlab/shell_history_spec.rb +53 -0
  166. data/spec/gitlab/shell_spec.rb +80 -0
  167. data/spec/gitlab_spec.rb +48 -7
  168. data/spec/spec_helper.rb +24 -13
  169. metadata +287 -33
  170. data/spec/fixtures/create_merge_request.json +0 -1
  171. data/spec/fixtures/project_delete_key.json +0 -8
  172. data/spec/fixtures/update_merge_request.json +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "active": true,
3
+ "description": "test-2016-02-01",
4
+ "id": 9,
5
+ "is_shared": false,
6
+ "name": null
7
+ }
@@ -0,0 +1,16 @@
1
+ [
2
+ {
3
+ "active": true,
4
+ "description": "test-2-20150125",
5
+ "id": 8,
6
+ "is_shared": false,
7
+ "name": null
8
+ },
9
+ {
10
+ "active": true,
11
+ "description": "development_runner",
12
+ "id": 5,
13
+ "is_shared": true,
14
+ "name": null
15
+ }
16
+ ]
@@ -0,0 +1 @@
1
+ [{"id":3,"code":"gitlab","name":"Gitlab","description":null,"path":"gitlab","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"private":true,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:58Z"}]
@@ -0,0 +1,44 @@
1
+ {
2
+ "id": 3,
3
+ "description": null,
4
+ "default_branch": "master",
5
+ "public": false,
6
+ "visibility_level": 10,
7
+ "ssh_url_to_repo":"git@git.gitlab.com:root/gitlab.git",
8
+ "http_url_to_repo":"http://git.gitlab.com/root/gitlab.git",
9
+ "web_url":"http://git.gitlab.com/root/gitlab",
10
+ "tag_list": [
11
+
12
+ ],
13
+ "name": "GitLab Community Edition",
14
+ "name_with_namespace": "GitLab / GitLab Community Edition",
15
+ "path": "gitlab-ce",
16
+ "path_with_namespace": "gitlab/gitlab-ce",
17
+ "issues_enabled": true,
18
+ "open_issues_count": 1,
19
+ "merge_requests_enabled": true,
20
+ "builds_enabled": true,
21
+ "wiki_enabled": true,
22
+ "snippets_enabled": false,
23
+ "container_registry_enabled": false,
24
+ "created_at": "2013-09-30T13:46:02Z",
25
+ "last_activity_at": "2013-09-30T13:46:02Z",
26
+ "creator_id": 3,
27
+ "namespace": {
28
+ "created_at": "2013-09-30T13:46:02Z",
29
+ "description": "",
30
+ "id": 3,
31
+ "name": "GitLab",
32
+ "owner_id": 1,
33
+ "path": "gitlab",
34
+ "updated_at": "2013-09-30T13:46:02Z"
35
+ },
36
+ "archived": true,
37
+ "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
38
+ "shared_runners_enabled": true,
39
+ "forks_count": 0,
40
+ "star_count": 1,
41
+ "public_builds": true,
42
+ "shared_with_groups": [],
43
+ "only_allow_merge_if_build_succeeds": false
44
+ }
@@ -0,0 +1 @@
1
+ {"name": "v1.1.0","message": "Release 1.1.0","commit": {"id": "2695effb5807a22ff3d138d593fd856244e155e7","parents": [],"message": "Initial commit","authored_date": "2012-05-28T04:42:42-07:00","author_name": "John Smith","author email": "john@example.com","committer_name": "Jack Smith","committed_date": "2012-05-28T04:42:42-07:00","committer_email": "jack@example.com"}}
@@ -0,0 +1 @@
1
+ {"name": "v1.0.0","message": null,"commit": {"id": "2695effb5807a22ff3d138d593fd856244e155e7","parents": [],"message": "Initial commit","authored_date": "2012-05-28T04:42:42-07:00","author_name": "John Smith","author email": "john@example.com","committer_name": "Jack Smith","committed_date": "2012-05-28T04:42:42-07:00","committer_email": "jack@example.com"}}
@@ -0,0 +1,44 @@
1
+ {
2
+ "id": 3,
3
+ "description": null,
4
+ "default_branch": "master",
5
+ "public": false,
6
+ "visibility_level": 10,
7
+ "ssh_url_to_repo":"git@git.gitlab.com:root/gitlab.git",
8
+ "http_url_to_repo":"http://git.gitlab.com/root/gitlab.git",
9
+ "web_url":"http://git.gitlab.com/root/gitlab",
10
+ "tag_list": [
11
+
12
+ ],
13
+ "name": "GitLab Community Edition",
14
+ "name_with_namespace": "GitLab / GitLab Community Edition",
15
+ "path": "gitlab-ce",
16
+ "path_with_namespace": "gitlab/gitlab-ce",
17
+ "issues_enabled": true,
18
+ "open_issues_count": 1,
19
+ "merge_requests_enabled": true,
20
+ "builds_enabled": true,
21
+ "wiki_enabled": true,
22
+ "snippets_enabled": false,
23
+ "container_registry_enabled": false,
24
+ "created_at": "2013-09-30T13:46:02Z",
25
+ "last_activity_at": "2013-09-30T13:46:02Z",
26
+ "creator_id": 3,
27
+ "namespace": {
28
+ "created_at": "2013-09-30T13:46:02Z",
29
+ "description": "",
30
+ "id": 3,
31
+ "name": "GitLab",
32
+ "owner_id": 1,
33
+ "path": "gitlab",
34
+ "updated_at": "2013-09-30T13:46:02Z"
35
+ },
36
+ "archived": true,
37
+ "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
38
+ "shared_runners_enabled": true,
39
+ "forks_count": 0,
40
+ "star_count": 0,
41
+ "public_builds": true,
42
+ "shared_with_groups": [],
43
+ "only_allow_merge_if_build_succeeds": false
44
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "id": 498,
3
+ "sha": "7d938cb8ac15788d71f4b67c035515a160ea76d8",
4
+ "ref": "decreased-spec",
5
+ "status": "failed",
6
+ "name": "test",
7
+ "target_url": null,
8
+ "description": null,
9
+ "created_at": "2015-10-23T23:56:49.499+02:00",
10
+ "started_at": null,
11
+ "finished_at": "2015-10-23T23:56:49.534+02:00",
12
+ "author": {
13
+ "name": "Dominik Sander",
14
+ "username": "dsander",
15
+ "id": 1,
16
+ "state": "active",
17
+ "avatar_url": "https://secure.gravatar.com/avatar/xxx?s=40&d=identicon",
18
+ "web_url": "https://github.com/u/dsander"
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ {"id": 1, "project_id": 1, "created_at": "2016-05-25T20:27:15.545Z", "commit_message_regex": "\\b[A-Z]{3}-[0-9]+\\b", "deny_delete_tag": false}
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rails', '4.1.2'
@@ -0,0 +1 @@
1
+ {"tag_name":"0.0.1","description":"Amazing release. Wow"}
@@ -0,0 +1 @@
1
+ {"tag_name":"0.0.1","description":"Amazing release. Wow"}
@@ -0,0 +1 @@
1
+ {"file_path":"path","branch_name":"branch","encoding":"base64","content":"Y29udGVudA==","commit_message":"commit message"}
@@ -0,0 +1,26 @@
1
+ {
2
+ "active": true,
3
+ "architecture": null,
4
+ "description": "test-1-20150125",
5
+ "id": 6,
6
+ "is_shared": false,
7
+ "contacted_at": "2016-01-25T16:39:48.066Z",
8
+ "name": null,
9
+ "platform": null,
10
+ "projects": [
11
+ {
12
+ "id": 1,
13
+ "name": "GitLab Community Edition",
14
+ "name_with_namespace": "GitLab.org / GitLab Community Edition",
15
+ "path": "gitlab-ce",
16
+ "path_with_namespace": "gitlab-org/gitlab-ce"
17
+ }
18
+ ],
19
+ "token": "205086a8e3b9a2b818ffac9b89d102",
20
+ "revision": null,
21
+ "tag_list": [
22
+ "ruby",
23
+ "mysql"
24
+ ],
25
+ "version": null
26
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "active": true,
3
+ "description": "test-1-20150125-test",
4
+ "id": 6,
5
+ "is_shared": false,
6
+ "name": null
7
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "active": true,
3
+ "architecture": null,
4
+ "description": "abcefg",
5
+ "id": 6,
6
+ "is_shared": false,
7
+ "contacted_at": "2016-01-25T16:39:48.066Z",
8
+ "name": null,
9
+ "platform": null,
10
+ "projects": [
11
+ {
12
+ "id": 1,
13
+ "name": "GitLab Community Edition",
14
+ "name_with_namespace": "GitLab.org / GitLab Community Edition",
15
+ "path": "gitlab-ce",
16
+ "path_with_namespace": "gitlab-org/gitlab-ce"
17
+ }
18
+ ],
19
+ "token": "205086a8e3b9a2b818ffac9b89d102",
20
+ "revision": null,
21
+ "tag_list": [
22
+ "ruby",
23
+ "mysql"
24
+ ],
25
+ "version": null
26
+ }
@@ -0,0 +1,16 @@
1
+ [
2
+ {
3
+ "active": true,
4
+ "description": "test-1-20150125",
5
+ "id": 6,
6
+ "is_shared": false,
7
+ "name": null
8
+ },
9
+ {
10
+ "active": true,
11
+ "description": "test-2-20150125",
12
+ "id": 8,
13
+ "is_shared": false,
14
+ "name": null
15
+ }
16
+ ]
@@ -0,0 +1,30 @@
1
+ [
2
+ {
3
+ "active": true,
4
+ "description": "shared-runner-1",
5
+ "id": 1,
6
+ "is_shared": true,
7
+ "name": null
8
+ },
9
+ {
10
+ "active": true,
11
+ "description": "shared-runner-2",
12
+ "id": 3,
13
+ "is_shared": true,
14
+ "name": null
15
+ },
16
+ {
17
+ "active": true,
18
+ "description": "test-1-20150125",
19
+ "id": 6,
20
+ "is_shared": false,
21
+ "name": null
22
+ },
23
+ {
24
+ "active": true,
25
+ "description": "test-2-20150125",
26
+ "id": 8,
27
+ "is_shared": false,
28
+ "name": null
29
+ }
30
+ ]
@@ -0,0 +1 @@
1
+ {"id":38,"title":"Redmine","created_at":"2015-12-18T14:17:17.592+03:00","updated_at":"2015-12-18T17:55:09.594+03:00","active":true,"push_events":true,"issues_events":true,"merge_requests_events":true,"tag_push_events":true,"note_events":true,"build_events":false,"properties":{"description":"Redmine","project_url":"https://example.com/projects/test_project/issue","issues_url":"https://example.com/issues/:id","new_issue_url":"'https://example.com/projects/test_project/issues/new"}}
@@ -0,0 +1,2 @@
1
+ party on, dudes
2
+ be excellent to each other
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts "Cool snippet!"
@@ -0,0 +1 @@
1
+ {"id": 3, "url": "http://example.com/hook", "created_at": "2013-10-02T10:15:31Z"}
@@ -0,0 +1 @@
1
+ [{"id": 3, "url": "http://example.com/hook", "created_at": "2013-10-02T10:15:31Z"}]
@@ -0,0 +1 @@
1
+ {"name":"0.0.1","message":null,"commit":{"id":"c260c39f4d73d9087482d29b4d7a88bec834a3d1","message":"rubocop 100%","parent_ids":["b55be4dc5c052fb0058ef1ea96acd5e4e37f1bed"],"authored_date":"2016-04-29T16:11:32.000+01:00","author_name":"Bob Bloggs","author_email":"bob.bloggs@nowhere","committed_date":"2016-04-29T16:11:32.000+01:00","committer_name":"Bob Bloggs","committer_email":"bob.bloggs@nowhere"},"release":null}
@@ -0,0 +1 @@
1
+ {"name":"0.0.1","message":"this tag is annotated","commit":{"id":"3d3f9288d70f75aa55ea495a3ed5948a628fce11","message":"Added README.md\n","parent_ids":[],"authored_date":"2016-05-25T11:23:07.000+01:00","author_name":"Bob Bloggs","author_email":"bob.bloggs@nowhere","committed_date":"2016-05-25T11:23:07.000+01:00","committer_name":"Bob Bloggs","committer_email":"bob.bloggs@nowhere"},"release":{"tag_name":"0.0.1","description":"and it has release notes"}}
@@ -0,0 +1 @@
1
+ {"name":"0.0.1","message":"this tag is annotated","commit":{"id":"7225ddbe28add8d168e3175266830ab8e6aabdcc","message":"Readme updated","parent_ids":["c3f101968138aa9b09a92c8b6399b3269d17865e"],"authored_date":"2016-03-07T13:38:07.000+00:00","author_name":"Bob Bloggs","author_email":"bob.bloggs@nowhere","committed_date":"2016-03-07T13:38:07.000+00:00","committer_name":"Bob Bloggs","committer_email":"bob.bloggs@nowhere"},"release":null}
@@ -0,0 +1 @@
1
+ {"tag_name":"0.0.1"}
@@ -0,0 +1 @@
1
+ [{"name":"0.0.2","message":null,"commit":{"id":"c260c39f4d73d9087482d29b4d7a88bec834a3d1","message":"rubocop 100%","parent_ids":["b55be4dc5c052fb0058ef1ea96acd5e4e37f1bed"],"authored_date":"2016-04-29T16:11:32.000+01:00","author_name":"Bob Bloggs","author_email":"bob.bloggs@nowhere","committed_date":"2016-04-29T16:11:32.000+01:00","committer_name":"Bob Bloggs","committer_email":"bob.bloggs@nowhere"},"release":null},{"name":"0.0.1","message":null,"commit":{"id":"c260c39f4d73d9087482d29b4d7a88bec834a3d1","message":"rubocop 100%","parent_ids":["b55be4dc5c052fb0058ef1ea96acd5e4e37f1bed"],"authored_date":"2016-04-29T16:11:32.000+01:00","author_name":"Bob Bloggs","author_email":"bob.bloggs@nowhere","committed_date":"2016-04-29T16:11:32.000+01:00","committer_name":"Bob Bloggs","committer_email":"bob.bloggs@nowhere"},"release":null}]
@@ -0,0 +1 @@
1
+ [{"id":"a2cc3b0ffc1c7d06fab5642eb99ea387b57f22f8","name":"app","type":"tree","mode":"040000"},{"id":"63164bdfbc11b69f1032fbe35da0f1e9c18af2fd","name":"bin","type":"tree","mode":"040000"},{"id":"2cf682191722f20f00a371d7da58f6a35701c11d","name":"config","type":"tree","mode":"040000"},{"id":"2e76c8c1bbc46bcc762788a432d802d65a534a28","name":"db","type":"tree","mode":"040000"},{"id":"767cfc8360b50c50bb5bdde288b96a84e3efa66e","name":"doc","type":"tree","mode":"040000"},{"id":"3fa0d1024f5e372bf9e43d1dac47bd1e95ab0858","name":"lib","type":"tree","mode":"040000"},{"id":"4e79d0ac6225844602a1b9273b26d8996f777bf2","name":"log","type":"tree","mode":"040000"},{"id":"7cb7f593c6914d20fa6cc4ab5a7c34337a50e97c","name":"public","type":"tree","mode":"040000"},{"id":"d97169eef778f3cd1d4d94cbe3415b3166d15c71","name":"spec","type":"tree","mode":"040000"},{"id":"97c97da29fa97e2158cfdcdcb042af9da0bc3de4","name":"vendor","type":"tree","mode":"040000"},{"id":"d316760e4746059c117007507594a1d75b47df38","name":".gitignore","type":"blob","mode":"100644"},{"id":"f2e7cd477536f18d8e939faf452930b59a27063d","name":".travis.yml","type":"blob","mode":"100644"},{"id":"d5c68bda5f0fe703a80906f66cfe537ca807a5a6","name":"Capfile","type":"blob","mode":"100644"},{"id":"8f46eac03c6cd7ce03cda7ec3d78afdc6971e4c0","name":"Gemfile","type":"blob","mode":"100644"},{"id":"5e260573173b51eaa073661d7914fb0e935ee27f","name":"Gemfile.lock","type":"blob","mode":"100644"},{"id":"e57032f682b69f14243c09d66a0892a03b4c6045","name":"Procfile","type":"blob","mode":"100644"},{"id":"905e96da839dad683dfcf4e202bf1e030390b964","name":"README.md","type":"blob","mode":"100644"},{"id":"24a16769fd94926350a59f7b1cbd78e9e2674c57","name":"Rakefile","type":"blob","mode":"100644"},{"id":"b384d6d57c6a775a9b6bc35d79ad7f03e673a233","name":"config.ru","type":"blob","mode":"100644"}]
@@ -0,0 +1,7 @@
1
+ {
2
+ "created_at": "2015-12-23T16:25:56.760Z",
3
+ "deleted_at": null,
4
+ "last_used": null,
5
+ "token": "7b9148c158980bbd9bcea92c17522d",
6
+ "updated_at": "2015-12-23T16:25:56.760Z"
7
+ }
@@ -0,0 +1,16 @@
1
+ [
2
+ {
3
+ "created_at": "2015-12-23T16:24:34.716Z",
4
+ "deleted_at": null,
5
+ "last_used": "2016-01-04T15:41:21.986Z",
6
+ "token": "fbdb730c2fbdb095a0862dbd8ab88b",
7
+ "updated_at": "2015-12-23T16:24:34.716Z"
8
+ },
9
+ {
10
+ "created_at": "2015-12-23T16:25:56.760Z",
11
+ "deleted_at": null,
12
+ "last_used": null,
13
+ "token": "7b9148c158980bbd9bcea92c17522d",
14
+ "updated_at": "2015-12-23T16:25:56.760Z"
15
+ }
16
+ ]
@@ -1 +1 @@
1
- {"id":1,"email":"john@example.com","name":"John Smith","bio":null,"skype":"","linkedin":"","twitter":"john","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"}
1
+ {"id":1,"email":"john@example.com","name":"John Smith","username":"john.smith","bio":null,"skype":"","linkedin":"","twitter":"john","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"}
@@ -0,0 +1 @@
1
+ {"id":1,"email":"email@example.com"}
@@ -0,0 +1 @@
1
+ [{"id":1,"email":"email@example.com"},{"id":3,"email":"email2@example.com"}]
@@ -0,0 +1 @@
1
+ [{"id":1,"email":"john1@example.com","name":"John Smith 1","username":"john.smith1","bio":null,"skype":"","linkedin":"","twitter":"john1","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"},{"id":2,"email":"john2@example.com","name":"John Smith 2","username":"john.smith2","bio":null,"skype":"","linkedin":"","twitter":"john2","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:56Z"}]
@@ -1 +1 @@
1
- [{"id":1,"email":"john@example.com","name":"John Smith","bio":null,"skype":"","linkedin":"","twitter":"john","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"},{"id":2,"email":"jack@example.com","name":"Jack Smith","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":6,"email":"faye.watsica@rohanwalter.com","name":"Ambrose Hansen","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":7,"email":"maida@walshtorp.name","name":"Alana Hahn","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"}]
1
+ [{"id":1,"email":"john@example.com","name":"John Smith","username":"john.smith","bio":null,"skype":"","linkedin":"","twitter":"john","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"},{"id":2,"email":"jack@example.com","name":"Jack Smith","username":"jack.smith","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","username":"beatrice.jewess","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","username":"felipe.davis","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","username":"michale.von","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":6,"email":"faye.watsica@rohanwalter.com","name":"Ambrose Hansen","username":"ambrose.hansen","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":7,"email":"maida@walshtorp.name","name":"Alana Hahn","username":"alana.hahn","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"}]
@@ -0,0 +1,4 @@
1
+ {
2
+ "key": "VARIABLE",
3
+ "value": "the value"
4
+ }
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "key": "TEST_VARIABLE_1",
4
+ "value": "TEST_1"
5
+ },
6
+ {
7
+ "key": "TEST_VARIABLE_2",
8
+ "value": "TEST_2"
9
+ }
10
+ ]
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::CLI::Helpers do
4
+ describe ".method_owners" do
5
+ before do
6
+ @methods = Gitlab::CLI::Helpers.method_owners
7
+ end
8
+ it "should return Array of Hashes containing method names and owners" do
9
+ expect(@methods).to be_a Array
10
+ expect(@methods.all? { |m| m.is_a? Hash }).to be true
11
+ expect(@methods.all? { |m| m.keys.sort === [:name, :owner] }).to be true
12
+ end
13
+ end
14
+
15
+ describe ".valid_command?" do
16
+ it "should return true when command is valid" do
17
+ expect(Gitlab::CLI::Helpers.valid_command? 'merge_requests').to be_truthy
18
+ end
19
+ it "should return false when command is NOT valid" do
20
+ expect(Gitlab::CLI::Helpers.valid_command? 'mmmmmerge_requests').to be_falsy
21
+ end
22
+ end
23
+
24
+ describe ".symbolize_keys" do
25
+ context "when input is a Hash" do
26
+ it "should return a Hash with symbols for keys" do
27
+ hash = { 'key1' => 'val1', 'key2' => 'val2' }
28
+ symbolized_hash = Gitlab::CLI::Helpers.symbolize_keys(hash)
29
+ expect(symbolized_hash).to eq(key1: 'val1', key2: 'val2')
30
+ end
31
+ end
32
+ context "when input is NOT a Hash" do
33
+ it "should return input untouched" do
34
+ array = [1, 2, 3]
35
+ new_array = Gitlab::CLI::Helpers.symbolize_keys(array)
36
+ expect(new_array).to eq([1, 2, 3])
37
+ end
38
+ end
39
+ end
40
+
41
+ describe ".yaml_load" do
42
+ context "when argument is a YAML string" do
43
+ it "should return Ruby objects" do
44
+ argument = "{foo: bar, sna: fu}"
45
+ output = Gitlab::CLI::Helpers.yaml_load argument
46
+ expect(output).to eq('foo' => 'bar', 'sna' => 'fu')
47
+ end
48
+ end
49
+
50
+ context "when input is NOT valid YAML" do
51
+ it "should raise" do
52
+ ruby_array = [1, 2, 3, 4]
53
+ expect { Gitlab::CLI::Helpers.yaml_load ruby_array }.to raise_error TypeError
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,119 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe Gitlab::CLI do
5
+ describe ".run" do
6
+ context "when command is version" do
7
+ it "should show gem version" do
8
+ output = capture_output { Gitlab::CLI.run('-v') }
9
+ expect(output).to eq("Gitlab Ruby Gem #{Gitlab::VERSION}\n")
10
+ end
11
+ end
12
+
13
+ context "when command is info" do
14
+ it "should show environment info" do
15
+ output = capture_output { Gitlab::CLI.run('info') }
16
+ expect(output).to include("Gitlab endpoint is")
17
+ expect(output).to include("Gitlab private token is")
18
+ expect(output).to include("Ruby Version is")
19
+ expect(output).to include("Gitlab Ruby Gem")
20
+ end
21
+ end
22
+
23
+ context "when command is help" do
24
+ it "should show available actions" do
25
+ output = capture_output { Gitlab::CLI.run('help') }
26
+ expect(output).to include('Help Topics')
27
+ expect(output).to include('MergeRequests')
28
+ end
29
+ end
30
+
31
+ context "when command is user" do
32
+ before do
33
+ stub_get("/user", "user")
34
+ @output = capture_output { Gitlab::CLI.run('user') }
35
+ end
36
+
37
+ it "should show executed command" do
38
+ expect(@output).to include('Gitlab.user')
39
+ end
40
+
41
+ it "should show user data" do
42
+ expect(@output).to include('name')
43
+ expect(@output).to include('John Smith')
44
+ end
45
+ end
46
+
47
+ context "when command is users" do
48
+ before do
49
+ stub_get("/users", "users")
50
+ @output = capture_output { Gitlab::CLI.run('users') }
51
+ end
52
+
53
+ it "should show executed command" do
54
+ expect(@output).to include('Gitlab.users')
55
+ end
56
+
57
+ it "should show users data" do
58
+ expect(@output).to include('name')
59
+ expect(@output).to include('John Smith')
60
+ expect(@output).to include('Jack Smith')
61
+ end
62
+ end
63
+ end
64
+
65
+ describe ".start" do
66
+ context "when command with excluded fields" do
67
+ before do
68
+ stub_get("/user", "user")
69
+ args = ['user', '--except=id,email,name']
70
+ @output = capture_output { Gitlab::CLI.start(args) }
71
+ end
72
+
73
+ it "should show user data with excluded fields" do
74
+ expect(@output).to_not include('John Smith')
75
+ expect(@output).to include('bio')
76
+ expect(@output).to include('created_at')
77
+ end
78
+ end
79
+
80
+ context "when command with json output" do
81
+ before do
82
+ stub_get("/user", "user")
83
+ args = ['user', '--json']
84
+ @output = capture_output { Gitlab::CLI.start(args) }
85
+ end
86
+
87
+ it "should render output as json" do
88
+ expect(JSON.parse(@output)['result']).to eq(JSON.parse(File.read(File.dirname(__FILE__) + '/../fixtures/user.json')))
89
+ expect(JSON.parse(@output)['cmd']).to eq('Gitlab.user')
90
+ end
91
+ end
92
+
93
+ context "when command with required fields" do
94
+ before do
95
+ stub_get("/user", "user")
96
+ args = ['user', '--only=id,email,name']
97
+ @output = capture_output { Gitlab::CLI.start(args) }
98
+ end
99
+
100
+ it "should show user data with required fields" do
101
+ expect(@output).to include('id')
102
+ expect(@output).to include('name')
103
+ expect(@output).to include('email')
104
+ expect(@output).to include('John Smith')
105
+ expect(@output).to_not include('bio')
106
+ expect(@output).to_not include('created_at')
107
+ end
108
+ end
109
+
110
+ context "fetch project with namespace/repo" do
111
+ it "should encode delimiter" do
112
+ stub_get("/projects/gitlab-org%2Fgitlab-ce", "project")
113
+ args = ['project', 'gitlab-org/gitlab-ce']
114
+ @output = capture_output { Gitlab::CLI.start(args) }
115
+ expect(@output).to include('id')
116
+ end
117
+ end
118
+ end
119
+ end