Codebase list ruby-gitlab / dab36f1
New upstream version 4.1.0 Sophie Brun 6 years ago
211 changed file(s) with 10542 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 *.gem
1 *.rbc
2 *.swp
3 .bundle
4 .config
5 .yardoc
6 Gemfile.lock
7 InstalledFiles
8 _yardoc
9 coverage
10 doc/
11 lib/bundler/man
12 pkg
13 rdoc
14 spec/reports
15 test/tmp
16 test/version_tmp
17 tmp
18 vendor/bundle
19 .idea
20 .ruby-version
21 .ruby-gemset
0 language: ruby
1 rvm:
2 - 2.0
3 - 2.1
4 - 2.2
5 - 2.3
6 - 2.4.0
7 before_install: gem update bundler
0 ## Change Log
1
2 ### Unreleased
3
4 ### 4.1.0 (26/05/2017)
5 - Add appropriate Content-Type header (@mltsy)
6 - Add `Jobs` endpoint methods (@hjanuschka)
7 - Update `BuildTriggers` to v4 API and rename to `PipelineTriggers`. (@IgnoredAmbience)
8 - Add support for `keys` resource (@dirker)
9 - Remove version-lock for terminal-table (@SuperTux88)
10
11 ### 4.0.0 (10/04/2017)
12 - Adds ability to create commits in a repository - (@logicminds)
13 - Remove Ruby 1.x support from the project - (@orta)
14 - Add `star_project` and `unstar_project` methods. (@connorshea)
15 - Lock terminal-table to prevent build failures on Ruby 1.9/2.0. (@connorshea)
16 - Update documentation to link to docs.gitlab.com instead of the GitHub mirror for GitLab CE. (@connorshea)
17 - Add method `share_project_with_group` (@danhalligan)
18 - Allow to retrieve `ssh_keys` for a specific user(@dirker)
19 - Allow issues to use NAMESPACE/REPO identifier (@brodock)
20 - Add issues subscribe/unsubscribe (@newellista)
21 - Add merge_requests subscribe/unsubscribe (@newellista)
22 - Updated `deploy_key` endpoints (@epintozzi)
23 - Add milestone/merge_requests (API V4 only) (@joren)
24 - Rename "git hook" to "push rule". (@asedge)
25 - Change project fork endpoint for v4 API. (@asedge)
26 - Block/unblock user now uses POST instead of PUT. (@asedge)
27 - Project ID can also be a string (namespace/project_name). (@bergholdt)
28 - Support pipeline. (@bergholdt)
29 - Add methods to disable and enable deploy keys on projects. (@buzzdeee)
30 - Add method to fetch issues a merge request will close. (@joren)
31 - Fix `get_file` and `file_contents` methods to work with APIv4. (@asedge)
32
33 ### 3.7.0 (16/08/2016)
34
35 - Add in GitlabCI Runner support (@davidcollum)
36 - Implemented tags API methods (@jblackman)
37 - Expose response status when Gitlab raises an error. (@calavera)
38 - Add `build_artifacts` method (@nanofi)
39 - Add `user_search` method (@Dreeg)
40 - Added project git hook support (@liger1978)
41 - Add the ability to delete an issue (@dandunckelman)
42 - Add missing Build APIs (@edgemaster)
43 - Improve record table output to use Hash `id` field if it exists. (@asedge)
44 - Support for listing merge request notes (@dlukman)
45 - Update YARD so it can be formatted easier for the CLI. (@asedge)
46 - Add `options` to `build` method (@sanderhahn)
47 - Add `delete_group` method (@shadeslayer)
48 - Add `group_projects` method (@shadeslayer)
49 - Add `edit_merge_request_comment` (@hjanuschka)
50 - Add `merge_request_commits` method (@nomeaning777)
51 - Add method `edit_group_member` (@coder-hugo)
52 - New builds endpoints (@kmarcisz)
53 - Use `respond_to_missing?` instead of `respond_to?` (@tsigo)
54 - Added possibility to change emails of user (@azomazo)
55 - Added possibility to change services in the project (@azomazo)
56 - Update README.md (@walterheck)
57
58 ### 3.6.1 (13/12/2015)
59
60 - Fixed CLI output for collections
61
62 ### 3.6.0 (11/12/2015)
63
64 - Improved output of the CLI help (@thomasdarimont)
65 - Added `search_projects` alias for `project_search` method
66 - Added pagination and auto pagination support (@nanofi)
67
68 ### 3.5.0 (26/11/2015)
69 - [a4f2150](https://github.com/NARKOZ/gitlab/commit/a4f21504a7288caace5b7433b49f49dc31e32b30) Add support for namespaces endpoint
70 - [3ad81a1](https://github.com/NARKOZ/gitlab/commit/3ad81a19a10b35ea422c0abcf08e6d03a325f4cd) Add missing "@" in doc. (@asedge)
71 - [fc34acb](https://github.com/NARKOZ/gitlab/commit/fc34acb6b475bb2555e4b035c11fdf42b3db4085) Add Gitlab::Client::Commits and rearrange methods and tests related to commits. (@asedge)
72 - [527089b](https://github.com/NARKOZ/gitlab/commit/527089b17fa7ed74a39b30dc6e8bb33482c1044b) Add commit status API, was added in Gitlab 8.1 (@dsander)
73 - [0a2f1db](https://github.com/NARKOZ/gitlab/commit/0a2f1dbe3efb66511dc836ef0ef884efedd70ef3) Add --json CLI parameter to output results as JSON
74 - [3f9cb62](https://github.com/NARKOZ/gitlab/commit/3f9cb625517c7294652139f2748e4bc7b98848cc) Adding sudo option for when forking a project (@gregoriomelo)
75 - [8dd964e](https://github.com/NARKOZ/gitlab/commit/8dd964ee743e051fade3137d8fac9bb387770150) Fix CLI configuration example comment line width to <= 80. (@asedge)
76 - [bbb8b61](https://github.com/NARKOZ/gitlab/commit/bbb8b61db46b32b8649956cb81d9a41e132493d4) Add comment for CLI configuration example. (@asedge)
77 - [30e96b9](https://github.com/NARKOZ/gitlab/commit/30e96b9444f7d60d4c0a56f57202c609497126eb) Update README.md (@raine)
78 - [d81f05b](https://github.com/NARKOZ/gitlab/commit/d81f05b80b7aaccef49641acfada3b2181f1633d) Change #handle_error method so it handles errors that are returned as an Array. (@asedge)
79 - [4c0395e](https://github.com/NARKOZ/gitlab/commit/4c0395ebc58c5a907489b6dc9dcac151e07b4dc8) Add Unprocessable error handler (@ondra-m)
80 - [3179bed](https://github.com/NARKOZ/gitlab/commit/3179bedc498b6c5577cc3c0b04633f67eb286ea9) Add block/unblock user. This API feature was added in GitLab 7.13 (@azomazo)
81 - [9946c7d](https://github.com/NARKOZ/gitlab/commit/9946c7d2a2c4261cbfc9c4a492b079c79abc2767) Check for specific exceptions in tests to suppress rspec warnings. (@asedge)
82 - [5e1c025](https://github.com/NARKOZ/gitlab/commit/5e1c025b8fdf723770c7c7ac0116acdf5cc9f2d5) Added support description option in create_group method (@azomazo)
83 - [46b657e](https://github.com/NARKOZ/gitlab/commit/46b657e47a29bc18f4122fff593a9eb58b73e4f1) deleting a gitlab project returns the string "true" (@tosmi)
84 - [cc3b489](https://github.com/NARKOZ/gitlab/commit/cc3b489cdeb3bd18b4ec841f80e76e74ddd0ce37) add development scripts (@NARKOZ)
85 - [24ad7fd](https://github.com/NARKOZ/gitlab/commit/24ad7fd2a1bd99eb468f1181d95c75fbec5d8fe0) Added specs edit_project, create_fork, create_user_with_username (@p404)
86 - [42e73a2](https://github.com/NARKOZ/gitlab/commit/42e73a2fde3e64dc8e3cf0ec73b8cfad88e43ca8) Added edit_project method to Projects module && updated the create_user method (@p404)
87 - [c9822f1](https://github.com/NARKOZ/gitlab/commit/c9822f1b61a8d7a5e855616e80e725730340cd48) Refactor create_user method (@p404)
88 - [6d7c4e7](https://github.com/NARKOZ/gitlab/commit/6d7c4e7c3285ee082513b3125346e6ed9c18b24b) Added create_fork method to Projects module (@p404)
89 - [54155b6](https://github.com/NARKOZ/gitlab/commit/54155b6c59d6e307744668cb3592ca98cf11d8f2) Add snippet_content method + tests. (@asedge)
90 - [cfff385](https://github.com/NARKOZ/gitlab/commit/cfff385b7f528223bf9ddc5f4177883e5ca56492) Remove executable permission on fixture file. (@asedge)
91 - [487a372](https://github.com/NARKOZ/gitlab/commit/487a372f7041d104975570747a63c9021881c952) Add RepositoryFiles#get_file method. (@asedge)
92 - [c9c05ad](https://github.com/NARKOZ/gitlab/commit/c9c05adee50828cc2e31048006cc95b5f2b9b7ce) Hide auth_token method from CLI/shell. (@asedge)
93 - [ef408a7](https://github.com/NARKOZ/gitlab/commit/ef408a7de0e677a568a66dbf212139aafc2e6186) Remove unnecessary require. (@asedge)
94 - [a2752d1](https://github.com/NARKOZ/gitlab/commit/a2752d1f5a01759a85d1e2003bb81c8e59cf85d3) Add some missing examples. (@asedge)
95 - [ac595af](https://github.com/NARKOZ/gitlab/commit/ac595af15a07601b3b657d4b4c1c479651aaa7d7) Add group_search method. (@asedge)
96 - [53a6671](https://github.com/NARKOZ/gitlab/commit/53a667184ed3640aefcb3f67836d37f58a504f24) Added Users#delete_user method (@cthulhu666)
97 - [a2360f0](https://github.com/NARKOZ/gitlab/commit/a2360f08019632c2660dbbc6753bd3094286b993) Add httparty ENV variable for CLI. Fixes #127. (@asedge)
98
99 ### 3.4.0 (22/04/2015)
100 - [9acb83d](https://github.com/NARKOZ/gitlab/commit/9acb83d2d068720b07934f5152313dc22a2f6374) remove check for missing attributes
101 - [8896e2b](https://github.com/NARKOZ/gitlab/commit/8896e2b7d5e8df509d48a411fd4440e27ed13995) return false when response body is empty
102 - [a04f3af](https://github.com/NARKOZ/gitlab/commit/a04f3af2d7aa8eec60c4f044fdb148e45c1ca133) escape ref parameter for repo_file_contents
103 - [8dcfec5](https://github.com/NARKOZ/gitlab/commit/8dcfec5aaaff9ef1c12687c5f9ca90f6aed0f912) Add tests for project_search. (@asedge)
104 - [75ead81](https://github.com/NARKOZ/gitlab/commit/75ead813b4335bab2464b6af0fb776c3d746242f) Added :page and :per_page query options to snippet_notes method (@StephenOTT)
105 - [f9818cb](https://github.com/NARKOZ/gitlab/commit/f9818cb121c8eeb9197e66732fec30ab90deecad) Added :page and :per_page query options to issue_notes method (@StephenOTT)
106 - [f92d745](https://github.com/NARKOZ/gitlab/commit/f92d745f1f561955d8fcbed4e23b43bb92ace255) Added :page and :per_page query options to notes method (@StephenOTT)
107 - [d4c3f20](https://github.com/NARKOZ/gitlab/commit/d4c3f2052c844486cf2b99a5346af4cd3fc001c9) Add support for merge_request_changes (@dsander)
108 - [2253fba](https://github.com/NARKOZ/gitlab/commit/2253fbab0a915d23f30de04a90167a0c783f9a6b) Allow authenticating via oauth with the private_token (@dsander)
109 - [8b7bcb4](https://github.com/NARKOZ/gitlab/commit/8b7bcb478e168f5ce2c94b8633b33128c29252b9) add inspect method to ObjectifiedHash
110 - [257737c](https://github.com/NARKOZ/gitlab/commit/257737c80ca93a71dfb5f8d990e5de1423603dfc) add delete_branch (@marc-ta)
111 - [f6532d5](https://github.com/NARKOZ/gitlab/commit/f6532d5074e0bb0d06bc251fb43b73f49a7af17a) improve docs
112 - [5164e6d](https://github.com/NARKOZ/gitlab/commit/5164e6de544bc34c57c3444e0b63cf3aada23776) Adding options hash to milestone_issues method.
113 - [57fa92d](https://github.com/NARKOZ/gitlab/commit/57fa92d7eef96e84498fa005e7ab83abc2a41a2b) Added support to get milestone issues. (@pbendersky)
114 - [d604e58](https://github.com/NARKOZ/gitlab/commit/d604e58732ea08fb15acdc1be339535e34e68d73) Add create_merge_request_note
115 - [cea19b8](https://github.com/NARKOZ/gitlab/commit/cea19b8e607033700dcab4648c05ac398cfe9566) Add project_search method (@ey3ball)
116 - [d0ebd3b](https://github.com/NARKOZ/gitlab/commit/d0ebd3b3a0ed83fc62d2a2e22ba9aa29a99cdcb6) Catch SIGINT earlier during shell session. Fixes #111. (@asedge)
117 - [2133562](https://github.com/NARKOZ/gitlab/commit/21335623009553197b61826d9894a739de152665) Redo the actions_table to make it more readable. CLI can now display the same help as the Shell. Closes #106. (@asedge)
118 - [da18909](https://github.com/NARKOZ/gitlab/commit/da1890949fb9eb60c13ab670dd8428d27de1814b) Add some method documentation and small style fixes. (@asedge)
119 - [7e1b408](https://github.com/NARKOZ/gitlab/commit/7e1b408e48152df1ce6e2be74a653c3801a37c10) Authenticate via oauth an auth_token (@dsander)
120 - [adb28b3](https://github.com/NARKOZ/gitlab/commit/adb28b30dab47bd3a58eae697d40e4aa346ea2c8) Update create_merge_request doc to include :target_project_id parameter. Closes #108. (@asedge)
121 - [525e913](https://github.com/NARKOZ/gitlab/commit/525e9131fe99a3f7396b547810e957058ab5a092) add ruby-2.2 to travis-ci
122 - [3671c89](https://github.com/NARKOZ/gitlab/commit/3671c89071d712ee71fa51cac67f3e0b9a28b03b) Save shell history when user presses Ctrl-d (@asedge)
123 - [c8e5f50](https://github.com/NARKOZ/gitlab/commit/c8e5f50684533e00550bfa4474062665000df28a) Hide httparty & httparty= methods from Gitlab.actions - just like endpoint, private_token, etc. (@asedge)
124 - [358deeb](https://github.com/NARKOZ/gitlab/commit/358deeb8ed849defe28c7cba84e1935d549fce22) Fix a regression with exception handling in shell. (@asedge)
125 - [9612ce3](https://github.com/NARKOZ/gitlab/commit/9612ce3b8274a385ce8c1fcd5ca5d0a0eba71c7e) Added support for repository files create, edit and remove. (@razielgn)
126 - [2203ad7](https://github.com/NARKOZ/gitlab/commit/2203ad7fcaa337da3d9700cbbc342d961be18eee) Fix headings in action_table. (@asedge)
127 - [b4dceb3](https://github.com/NARKOZ/gitlab/commit/b4dceb3d2d582682f3cb35ca63e41e237d222596) add CHANGELOG.md
128 - [e2bd91c](https://github.com/NARKOZ/gitlab/commit/e2bd91ccf488dfede7688801e54270da0d395a56) Small refactor of Gitlab::Help, Gitlab::Shell & Gitlab::CLI::Helpers. Add some new tests and refactor ones recently added. (@asedge)
129 - [bffd84f](https://github.com/NARKOZ/gitlab/commit/bffd84f4e9e37d056772536f33a52f40df0b7882) Refactor Gitlab::Help. Add tests some. (@asedge)
130 - [9bd4f7a](https://github.com/NARKOZ/gitlab/commit/9bd4f7ad69614ee009c351811deee9eb2a6c3d05) Add test for Gitlab::Shell. (@asedge)
131 - [bc14ec5](https://github.com/NARKOZ/gitlab/commit/bc14ec5173e432ced601c108cae6eca56026d41e) Refactor of Gitlab::Shell to hopefully make it more readable & testable. Wrote tests for some Gitlab::Shell & Gitlab::CLI::Helper methods. Other minor improvements and refactors. (@asedge)
132
133 ### 3.3.0 (22/12/2014)
134 - [42b4bc7](https://github.com/NARKOZ/gitlab/commit/42b4bc7b0e5e35f151ab61e27099606f0f38af31) fix docs and specs
135 - [04e39e0](https://github.com/NARKOZ/gitlab/commit/04e39e013a7a74f6101a97c3791da0594da232a3) ability to update hook triggers
136 - [6c66fe9](https://github.com/NARKOZ/gitlab/commit/6c66fe92a56cca58630a34ed3e7991517dd63604) remove useless check for available hook events
137 - [c4b981d](https://github.com/NARKOZ/gitlab/commit/c4b981dd69974aa7e1cb088c9b9fd44e0c0a9b54) add accept_merge_request method
138 - [51611fe](https://github.com/NARKOZ/gitlab/commit/51611fe669987cd9f4c1fac0ed96c743e391bbf2) Use endpoint instance var instead of base_uri class method. Fixes #94. (@asedge)
139 - [1ec8b38](https://github.com/NARKOZ/gitlab/commit/1ec8b38322657c3f97a60deb10dc08b828ba9875) test multiple clients
140 - [44d013a](https://github.com/NARKOZ/gitlab/commit/44d013af76535a2227678869148fb7a8195691df) Capture CTRL-C in Shell (@chrisdambrosio)
141 - [3cba3b2](https://github.com/NARKOZ/gitlab/commit/3cba3b2420d72d8aead0febf0ba3564c7615cf8c) Adding respond_to override to the ObjectifiedHash class so it properly responds to respond_to? calls (@koglinjg)
142 - [ce20c47](https://github.com/NARKOZ/gitlab/commit/ce20c4768c3e591b0cea72e8738371ab76d7289e) limit history file size - closes #93 (@chrisdambrosio)
143 - [1cf656f](https://github.com/NARKOZ/gitlab/commit/1cf656f7cf9f1821339b9e6ed711f6218cddbf0f) Save/load shell mode history - closes #79 (@chrisdambrosio)
144 - [727780b](https://github.com/NARKOZ/gitlab/commit/727780b8f282bb8fe461a54e558fe0775b4b36fd) HTTP proxy support - closes #52 (@chrisdambrosio)
145 - [e4ceb18](https://github.com/NARKOZ/gitlab/commit/e4ceb187aa5e47d20740676aea4f36c473ddd241) implement .file_contents (@chrisdambrosio)
146 - [0d0e7e0](https://github.com/NARKOZ/gitlab/commit/0d0e7e01bab1708cd85294788f9b9cca33a33ddb) Now must use YAML valid syntax in CLI or CLI Shell where Gitlab methods expect Hashes (usually in the form of options). (@asedge)
147 - [a7d0e0a](https://github.com/NARKOZ/gitlab/commit/a7d0e0a8c1c50c4ab43faccdb88f049f5b84a1cf) add CONTRIBUTING.md
148 - [1f4ef8e](https://github.com/NARKOZ/gitlab/commit/1f4ef8ed25ccd1bdbeccf677a0a94106903d0f24) improve docs
149 - [3a8d339](https://github.com/NARKOZ/gitlab/commit/3a8d33946adec71724304f661d70eb515a2f6848) Repository tree root level files (@semenyukdmitriy)
150 - [ddab89e](https://github.com/NARKOZ/gitlab/commit/ddab89e6aa9917d06cddd121aa486424753bdf84) Adds support for comments on commits (@jeroenj)
151 - [a7c18f1](https://github.com/NARKOZ/gitlab/commit/a7c18f1180157021ef8d24791f32a30511940fbf) Add labels api for list, create, edit and delete. (@artworx)
152 - [d9940d5](https://github.com/NARKOZ/gitlab/commit/d9940d5f4dfd8fdc4530b249b518e0d048dbfdbb) Support pagination in Gitlab.merge_request_comments (@cubiware)
153 - [13a550c](https://github.com/NARKOZ/gitlab/commit/13a550cb82a4775f3c72850dcd65e807abe46e69) Update tests for create_tags method so it more closely matches what will happen in Gitlab 7.5.0. (@asedge)
154 - [6d8a98f](https://github.com/NARKOZ/gitlab/commit/6d8a98f7930d2df5af19cc838eb95ae9c775e1a1) Add repo compare API (@zlx)
155 - [76e29e6](https://github.com/NARKOZ/gitlab/commit/76e29e632ce345ed17d69401dcb286dc85a951aa) Add support for annotated tag creation. Update tests for create_tag. (@asedge)
156 - [40295b8](https://github.com/NARKOZ/gitlab/commit/40295b8889c0094babffc81a5d7749d32b0fbda6) introduce HTTParty-configuration, fix #61 (@barraq)
157 - [916e8a7](https://github.com/NARKOZ/gitlab/commit/916e8a72371a097fa63065b05d3dca0be7bc9e93) Improved arg parsing for gitlab readline shell. Other small fixes/improvements on regexes. (@asedge)
158 - [382fe71](https://github.com/NARKOZ/gitlab/commit/382fe71e3d509a57f736138ffbb673695577f709) Add missing documentation: :group_id, :namespace_id (@arioch)
159 - [c9f9662](https://github.com/NARKOZ/gitlab/commit/c9f9662a9b1116c838b523ed64c6abdb4aae4b8b) add exit command to shell
160
161 ### 3.2.0 (22/06/2014)
162 - [fee67da](https://github.com/NARKOZ/gitlab/commit/fee67da36cdab7906004e7a060602eb342c8b946) Handling some error cases when calling for help. (@asedge)
163 - [7705b01](https://github.com/NARKOZ/gitlab/commit/7705b01c94d8833fb055ca072d34c0019c622caf) Adding online help for Gitlab::Shell using "ri" command. I'm unsure if this is the best idea. Some refactoring still needs to be done to remove duplicate code. (@asedge)
164 - [599deff](https://github.com/NARKOZ/gitlab/commit/599deffbe193aed420747be16516b29b8beeb31f) Fix output_table call in CLI. (@asedge)
165 - [4a5f81f](https://github.com/NARKOZ/gitlab/commit/4a5f81f0e605a89205c05a4baefdbf6d2331d667) Initial commit of Gitlab CLI shell. Tab completion for Gitlab.actions. (@asedge)
166 - [48ba2a1](https://github.com/NARKOZ/gitlab/commit/48ba2a178b0e3f206588ccd5aeed14e52d1ba269) fix specs after update to RSpec 3
167 - [a8284af](https://github.com/NARKOZ/gitlab/commit/a8284af9af017e0bf381347a534f9a2426e35d64) Add spec for project_events method (@hassaku)
168 - [8e8527c](https://github.com/NARKOZ/gitlab/commit/8e8527cc4743a11ea285072e11f1bb4e703757ff) Add method to get a list of project events (@hassaku)
169 - [8c2aa8f](https://github.com/NARKOZ/gitlab/commit/8c2aa8fc9f660696596639d458444bc00fe17f0c) Add create_tag method. Add tests for new method. (@asedge)
170 - [cd5ae8b](https://github.com/NARKOZ/gitlab/commit/cd5ae8ba8aca5025a41ec1dd9fad70dae10c2fd3) clarify default config options
171
172 ### 3.1.0 (22/05/2014)
173 - [16834bb](https://github.com/NARKOZ/gitlab/commit/16834bb178fa6bf6c7ec8b67bfedfdc32145769d) add info command to CLI
174 - [68aebb7](https://github.com/NARKOZ/gitlab/commit/68aebb76b24972b7d00a78f3d4f923fca009ba31) ability to delete a project
175 - [ac54e55](https://github.com/NARKOZ/gitlab/commit/ac54e55825d16373862fbbc176d6c9c2594dc593) set command arguments when no filters
176 - [23be13e](https://github.com/NARKOZ/gitlab/commit/23be13e87c3c99764fcb27393ce99d9cc05633b9) fix docs
177 - [1b298dc](https://github.com/NARKOZ/gitlab/commit/1b298dcd5f71321867ad2bd3c18522a7602357ad) fix ruby 1.9 compatibility
178 - [af92ff5](https://github.com/NARKOZ/gitlab/commit/af92ff546af578ba0753c254fabf73761553f4c8) add confirmation for destructive commands
179 - [b1602d2](https://github.com/NARKOZ/gitlab/commit/b1602d2f5ce0a614de48d5295654d0699fe69c0d) move methods related to CLI output to a separate module
180 - [4183a52](https://github.com/NARKOZ/gitlab/commit/4183a52ca6344d86aa152e189bc20c467c96c5a5) improve help message
181 - [0bba284](https://github.com/NARKOZ/gitlab/commit/0bba284e9447a4a6aa95990b65db5ae4d44ce989) add specs for CLI
182 - [5ec08bc](https://github.com/NARKOZ/gitlab/commit/5ec08bc0173e986e5979ca0c809d70002186f0cc) ability to filter CLI output
183 - [ba86169](https://github.com/NARKOZ/gitlab/commit/ba861692bae33cba8d22ac3beb223995a4df216c) add table output for multiple records
184 - [9cc540c](https://github.com/NARKOZ/gitlab/commit/9cc540c948bd71a70e3c1f6fc656e1bbde0dcb00) initial wrap-up of CLI
185 - [bee9745](https://github.com/NARKOZ/gitlab/commit/bee9745f2202f9dafd20b0edee185fe54f413cb2) include modules alphabetically
186 - [4963f16](https://github.com/NARKOZ/gitlab/commit/4963f16f3eb0a3f3a6dd7fbdc3b7f3aeab8d57cc) add special method that lists available actions for client
187 - [fe50c24](https://github.com/NARKOZ/gitlab/commit/fe50c24437ea2bd729044f30ef6afe8df1932f32) support environment variables
188 - [7a5d40c](https://github.com/NARKOZ/gitlab/commit/7a5d40ccd576abfb35c137f9e172821351d2dac8) eliminate ruby warning
189 - [b7fc447](https://github.com/NARKOZ/gitlab/commit/b7fc447211fe281e01f111f8a9fad08396fdfa4d) convert specs to new RSpec 2.14 syntax
190 - [471a643](https://github.com/NARKOZ/gitlab/commit/471a643a60a17ea9048615a2ac2d295e0682edd4) pass private token using HTTP headers
191 - [bbf6521](https://github.com/NARKOZ/gitlab/commit/bbf6521362d5af460c63a730d95f822e55160e82) fix users session spec
192 - [672a8d5](https://github.com/NARKOZ/gitlab/commit/672a8d54988dfafce4e3288a63f6cf67bf13c292) test Request class
193 - [3bf0363](https://github.com/NARKOZ/gitlab/commit/3bf03631769a419504f669bd3154953072701c61) set private_token param separately for each request
194 - [90760cd](https://github.com/NARKOZ/gitlab/commit/90760cdeb3dfaa7be5fdfa5eba792c3a8e617c57) Single commit and diff of a commit (@nanofi)
195 - [9b696d4](https://github.com/NARKOZ/gitlab/commit/9b696d4bd07c1ca5d8d41e6aaeb51f260393b789) pluralize module name: SystemHook -> SystemHooks
196 - [3b2cda9](https://github.com/NARKOZ/gitlab/commit/3b2cda9e974568f8d1d6bfebbf3f114686638f44) get rid of ruby argument prefix warning
197 - [0d6ca05](https://github.com/NARKOZ/gitlab/commit/0d6ca0565ee0eaf02ae077332f8082c8d939ce22) System Hook API (@nanofi)
198 - [29e31e0](https://github.com/NARKOZ/gitlab/commit/29e31e0a565a083c22401bb99b3cb28c8a43f5d6) Create branches.rb. Move branch related actions there. Add new methods for (un)protecting branches and creating new branches - which requires Gitlab 6.8-stable or newer. Added tests for new methods and fixed old tests looking for methods in old locations. (@asedge)
199 - [7f91a9a](https://github.com/NARKOZ/gitlab/commit/7f91a9a10dc8071d14d3ffaea001e32ac2f70180) Fixed: create project deploy key (@semenyukdmitriy)
200 - [b347574](https://github.com/NARKOZ/gitlab/commit/b3475743c624e7cc426ca099f0c86411ffaf6dd8) Project hooks: set events to trigger on (@semenyukdmitriy)
201 - [af49245](https://github.com/NARKOZ/gitlab/commit/af492453819678eca9f2a8e25b51d318e23d148c) Add merge_request_comments to get a MR's comments
202 - [2b9e659](https://github.com/NARKOZ/gitlab/commit/2b9e659afd646f8ffca7b323e40246096837eae7) Doc & test that update_merge_request can set state
203 - [45b0b9f](https://github.com/NARKOZ/gitlab/commit/45b0b9fc86016ba31e66b600172da6ace63f7a00) add 'to_hash' method for ObjectifiedHash
204 - [ce5294f](https://github.com/NARKOZ/gitlab/commit/ce5294f2ec74417626403595899a85c97d92318c) test against MRI 2.1.0
205 - [35aadef](https://github.com/NARKOZ/gitlab/commit/35aadef3f321d4d700c3f7926f2206ac241e7191) scope for projects api (@voanhduy1512)
206 - [7152c85](https://github.com/NARKOZ/gitlab/commit/7152c8520bf77f49385bb71ef82a574172500b00) Add edit_user method (@robertomiranda)
207
208 ### 3.0.0 (22/10/2013)
209 - [da31730](https://github.com/NARKOZ/gitlab/commit/da3173016870d76aabbd43ee1b04e7348cbdbb1e) handle response code 405
210 - [3c18ad0](https://github.com/NARKOZ/gitlab/commit/3c18ad0d373b4647232be3bbc1ee88aed9a3bbfc) remove ruby 1.8 patch
211 - [3fca003](https://github.com/NARKOZ/gitlab/commit/3fca0033e8dabbefdbf50fc15713866521d0e1d3) re-implement handling of sudo requests
212 - [49c54a6](https://github.com/NARKOZ/gitlab/commit/49c54a67a8c1a67dd1f471c93e63c6dace329817) ability to paginate group members
213 - [8ba8361](https://github.com/NARKOZ/gitlab/commit/8ba8361d6fed3967986243a9c48871b79040bb51) fix compatibility with API v3; update docs
214 - [93e8b81](https://github.com/NARKOZ/gitlab/commit/93e8b81632067879d874a31e18ab48a50ccaf05c) prettify error message
215 - [1752997](https://github.com/NARKOZ/gitlab/commit/1752997f22586c76929c7396db8892fe930cb93a) Add methods to manage deployment keys (@sosedoff)
216 - [613dda8](https://github.com/NARKOZ/gitlab/commit/613dda8f7b42770635023137fb6844709ad77ffd) Add group api, removed user_teams api
217 - [8db4e88](https://github.com/NARKOZ/gitlab/commit/8db4e88ade68401e3e2dc26f8cc9b78a48a0f8ea) Update error_message to print request uri on response failure
218 - [dd33a2f](https://github.com/NARKOZ/gitlab/commit/dd33a2feaa96022d6bd3795fb861eaf57f554bfa) Adding a check_attributes method in order to verify that the correct parameters have been passed into create_merge_request and comment_merge_request. Updating tests. (@thomasbiddle)
219 - [6f4a170](https://github.com/NARKOZ/gitlab/commit/6f4a170191a401c7eaf97522c5b8e20970e90249) Adding tests for missing merge request api calls. (@thomasbiddle)
220 - [af42bcb](https://github.com/NARKOZ/gitlab/commit/af42bcb7c18b27db266efdf7c9645d795d691760) Adding support for creating, updating, and commenting on merge requests. (@thomasbiddle)
221 - [f7aac38](https://github.com/NARKOZ/gitlab/commit/f7aac3860169ce0d0268676dc278d8150e497df8) minor updates indicating support for creating public projects (@amacarthur)
222 - [44a090d](https://github.com/NARKOZ/gitlab/commit/44a090d983de178ebdc7f6cd9cdcc339d731f9ef) added apis for the admin of fork links (@amacarthur)
223 - [32f1419](https://github.com/NARKOZ/gitlab/commit/32f14199c53da58ce00572530a002f769c808024) Added sudo functionality
224 - [b7f6c48](https://github.com/NARKOZ/gitlab/commit/b7f6c48b65b4d18cc18919fab12cefa99826578e) Made 409's throw exceptions
225 - [d1f581f](https://github.com/NARKOZ/gitlab/commit/d1f581ff410ba5c42d03e2cf98efa548a6139b01) Fixed an issue with access level var in add team project
226 - [8a5d679](https://github.com/NARKOZ/gitlab/commit/8a5d679806bd1dc8501965450fe12d0e807fbd93) Add user_team api
227 - [b4444fc](https://github.com/NARKOZ/gitlab/commit/b4444fce8c3dd9f0caa2d1a096e61ce6373136fe) Adding user_teams api
228 - [53d7a8a](https://github.com/NARKOZ/gitlab/commit/53d7a8a86dfed63e56eeb16ea496bb7a82de337e) consistently refer to feature as "project for user" per documentation @ https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/projects.md#create-project-for-user (@dylee)
229 - [13457a4](https://github.com/NARKOZ/gitlab/commit/13457a4bfd67088e156489d09db148739a0af700) add support for POST /projects/user:user_id (@leesolutions)
230 - [5e556fa](https://github.com/NARKOZ/gitlab/commit/5e556fac11daa25d3d9683904cf8f96b8e0bb009) update travis-ci config with ruby-2.0
231 - [3b8513d](https://github.com/NARKOZ/gitlab/commit/3b8513da22c8d78ce6a284ac8a7a5eaad6ab349d) Groups api additions
232 - [f2ba111](https://github.com/NARKOZ/gitlab/commit/f2ba111dba70eca5346a880c541dafaf35d3332a) don't expose data in ObjectifiedHash
233 - [c6889eb](https://github.com/NARKOZ/gitlab/commit/c6889ebfd455892690c0cddc3b88c670d8723435) add specs for notes
234 - [e562a7d](https://github.com/NARKOZ/gitlab/commit/e562a7db8ffdf9ec947895800e9c5b7753b83bfb) bring support for ruby 1.8
235 - [63c3592](https://github.com/NARKOZ/gitlab/commit/63c3592af45aa0d01de09910f562a4f875d01f6a) Notes api for wall, issues, and snippets notes. List, read and create. (@jozefvaclavik)
236
237 ### 2.2.0 (22/11/2012)
238 - [2ef4d48](https://github.com/NARKOZ/gitlab/commit/2ef4d48a0db13a7363973455c3c0ac9d2bf6df56) support merge requests API
239
240 ### 2.1.0 (22/10/2012)
241 - [89541c1](https://github.com/NARKOZ/gitlab/commit/89541c1dddccf185318645bb2748541955f221b0) add ability to create a user
242 - [483b4f6](https://github.com/NARKOZ/gitlab/commit/483b4f6812e657e9ea12c0c89199654393554aa7) fix typos in docs
243 - [7632ecb](https://github.com/NARKOZ/gitlab/commit/7632ecba57c8fa3fe966ee6eb0055bb7752d79fd) add ability to list project snippets
244 - [6c5637e](https://github.com/NARKOZ/gitlab/commit/6c5637e526f73bfb1c7791b12756ebdadeae4e5f) add project_hook and edit_project_hook methods
245 - [5fcf078](https://github.com/NARKOZ/gitlab/commit/5fcf078437b62a39de7d49c6d92fd5cdf09c565c) Fix add_team_member (@mizzy)
246 - [6a0176a](https://github.com/NARKOZ/gitlab/commit/6a0176aac542eacd9df24da20a8994f9f70e6ed7) refactor Request class
247 - [53746d5](https://github.com/NARKOZ/gitlab/commit/53746d55f19f75e72b3439d25f7940ba66151c94) add convenient methods to change a state of an issue
248
249 ### 2.0.0 (21/09/2012)
250 - [b47a324](https://github.com/NARKOZ/gitlab/commit/b47a324d616b7fa4e23160abae357887b9dde13f) initial implementation
0 # Contributing to Gitlab
1
2 Please take a moment to review this document in order to make the contribution
3 process easy and effective for everyone involved!
4
5 ## Using the issue tracker
6
7 You can use the issues tracker for:
8
9 * [bug reports](#bug-reports)
10 * [feature requests](#feature-requests)
11 * [submitting pull requests](#pull-requests)
12
13 Use [Stackoverflow](http://stackoverflow.com/) for questions and personal support requests.
14
15 ## Bug reports
16
17 A bug is a _demonstrable problem_ that is caused by the code in the repository.
18 Good bug reports are extremely helpful - thank you!
19
20 Guidelines for bug reports:
21
22 1. **Use the GitHub issue search** &mdash; check if the issue has already been
23 reported.
24
25 2. **Check if the issue has been fixed** &mdash; try to reproduce it using the
26 `master` branch in the repository.
27
28 3. **Isolate and report the problem** &mdash; ideally create a reduced test
29 case.
30
31 Please try to be as detailed as possible in your report. Include information about
32 your Ruby, Gitlab client and GitLab instance versions. Please provide steps to
33 reproduce the issue as well as the outcome you were expecting! All these details
34 will help developers to fix any potential bugs.
35
36 Example:
37
38 > Short and descriptive example bug report title
39 >
40 > A summary of the issue and the environment in which it occurs. If suitable,
41 > include the steps required to reproduce the bug.
42 >
43 > 1. This is the first step
44 > 2. This is the second step
45 > 3. Further steps, etc.
46 >
47 > Any other information you want to share that is relevant to the issue being
48 > reported. This might include the lines of code that you have identified as
49 > causing the bug, and potential solutions (and your opinions on their
50 > merits).
51
52 ## Feature requests
53
54 Feature requests are welcome. But take a moment to find out whether your idea
55 fits with the scope and aims of the project. It's up to *you* to make a strong
56 case to convince the community of the merits of this feature.
57 Please provide as much detail and context as possible.
58
59 ## Contributing Documentation
60
61 Code documentation has a special convention: it uses [YARD](http://yardoc.org/)
62 formatting and the first paragraph is considered to be a short summary.
63
64 For methods say what it will do. For example write something like:
65
66 ```ruby
67 # Reverses the contents of a String or IO object.
68 #
69 # @param [String, #read] contents the contents to reverse
70 # @return [String] the contents reversed lexically
71 def reverse(contents)
72 contents = contents.read if contents.respond_to? :read
73 contents.reverse
74 end
75 ```
76
77 For classes, modules say what it is. For example write something like:
78
79 ```ruby
80 # Defines methods related to groups.
81 module Groups
82 ```
83
84 Keep in mind that the documentation notes might show up in a summary somewhere,
85 long texts in the documentation notes create very ugly summaries. As a rule of thumb
86 anything longer than 80 characters is too long.
87
88 Try to keep unnecessary details out of the first paragraph, it's only there to
89 give a user a quick idea of what the documented "thing" does/is. The rest of the
90 documentation notes can contain the details, for example parameters and what
91 is returned.
92
93 If possible include examples. For example:
94
95 ```ruby
96 # Gets information about a project.
97 #
98 # @example
99 # Gitlab.project(3)
100 # Gitlab.project('gitlab')
101 #
102 # @param [Integer, String] id The ID or name of a project.
103 # @return [Gitlab::ObjectifiedHash]
104 def project(id)
105 ```
106
107 This makes it easy to test the examples so that they don't go stale and examples
108 are often a great help in explaining what a method does.
109
110 ## Pull requests
111
112 Good pull requests - patches, improvements, new features - are a fantastic
113 help. They should remain focused in scope and avoid containing unrelated
114 commits.
115
116 **IMPORTANT**: By submitting a patch, you agree that your work will be
117 licensed under the license used by the project.
118
119 If you have any large pull request in mind (e.g. implementing features,
120 refactoring code, etc), **please ask first** otherwise you risk spending
121 a lot of time working on something that the project's developers might
122 not want to merge into the project.
123
124 Please adhere to the coding conventions in the project (indentation,
125 accurate comments, etc.) and don't forget to add your own tests and
126 documentation. When working with git, we recommend the following process
127 in order to craft an excellent pull request:
128
129 1. [Fork](https://help.github.com/articles/fork-a-repo/) the project, clone your fork,
130 and configure the remotes:
131
132 ```sh
133 # Clone your fork of the repo into the current directory
134 git clone https://github.com/<your-username>/gitlab
135 # Navigate to the newly cloned directory
136 cd gitlab
137 # Assign the original repo to a remote called "upstream"
138 git remote add upstream https://github.com/NARKOZ/gitlab
139 ```
140
141 2. If you cloned a while ago, get the latest changes from upstream:
142
143 ```bash
144 git checkout master
145 git pull upstream master
146 ```
147
148 3. Create a new topic branch (off of `master`) to contain your feature, change,
149 or fix.
150
151 **IMPORTANT**: Making changes in `master` is discouraged. You should always
152 keep your local `master` in sync with upstream `master` and make your
153 changes in topic branches.
154
155 ```sh
156 git checkout -b <topic-branch-name>
157 ```
158
159 4. Commit your changes in logical chunks. Keep your commit messages organized,
160 with a short description in the first line and more detailed information on
161 the following lines. Feel free to use Git's
162 [interactive rebase](https://help.github.com/articles/about-git-rebase/)
163 feature to tidy up your commits before making them public.
164
165 5. Make sure all the tests are still passing.
166
167 ```sh
168 rake
169 ```
170
171 6. Push your topic branch up to your fork:
172
173 ```sh
174 git push origin <topic-branch-name>
175 ```
176
177 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
178 with a clear title and description.
179
180 8. If you haven't updated your pull request for a while, you should consider
181 rebasing on master and resolving any conflicts.
182
183 **IMPORTANT**: _Never ever_ merge upstream `master` into your branches. You
184 should always `git rebase` on `master` to bring your changes up to date when
185 necessary.
186
187 ```sh
188 git checkout master
189 git pull upstream master
190 git checkout <your-topic-branch>
191 git rebase master
192 ```
193
194 Thank you for your contributions!
0 source 'https://rubygems.org'
1
2 # Specify your gem's dependencies in gitlab.gemspec
3 gemspec
0 Copyright (c) 2012-2015 Nihad Abbasov <mail@narkoz.me>
1 All rights reserved.
2
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions are met:
5
6 1. Redistributions of source code must retain the above copyright notice,
7 this list of conditions and the following disclaimer.
8
9 2. Redistributions in binary form must reproduce the above copyright notice,
10 this list of conditions and the following disclaimer in the documentation
11 and/or other materials provided with the distribution.
12
13 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 POSSIBILITY OF SUCH DAMAGE.
0 # Gitlab
1
2 [![Build Status](https://img.shields.io/travis/NARKOZ/gitlab.svg?style=flat)](https://travis-ci.org/NARKOZ/gitlab)
3 [![Code Climate](https://img.shields.io/codeclimate/github/NARKOZ/gitlab.svg?style=flat)](https://codeclimate.com/github/NARKOZ/gitlab)
4 [![Inline docs](http://inch-ci.org/github/NARKOZ/gitlab.svg?style=flat)](https://inch-ci.org/github/NARKOZ/gitlab)
5 [![Gem version](https://img.shields.io/gem/v/gitlab.svg?style=flat)](https://rubygems.org/gems/gitlab)
6 [![License](https://img.shields.io/badge/license-BSD-red.svg?style=flat)](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt)
7
8 [website](http://narkoz.github.io/gitlab) |
9 [documentation](http://rubydoc.info/gems/gitlab/frames) |
10 [gitlab-live](https://github.com/NARKOZ/gitlab-live)
11
12 Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://docs.gitlab.com/ce/api/README.html).
13 As of version `4.0.0` this gem will only support Ruby 2.0+ and Gitlab API v4.
14
15 ## Installation
16
17 Install it from rubygems:
18
19 ```sh
20 gem install gitlab
21 ```
22
23 Or add to a Gemfile:
24
25 ```ruby
26 gem 'gitlab'
27 # gem 'gitlab', github: 'NARKOZ/gitlab'
28 ```
29
30 ## Usage
31
32 Configuration example:
33
34 ```ruby
35 Gitlab.configure do |config|
36 config.endpoint = 'https://example.net/api/v4' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
37 config.private_token = 'qEsq1pt6HJPaNciie3MG' # user's private token or OAuth2 access token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
38 # Optional
39 # config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]'
40 # config.sudo = 'user' # username for sudo mode, default: nil
41 end
42 ```
43
44 (Note: If you are using GitLab.com's hosted service, your endpoint will be `https://gitlab.com/api/v4`)
45
46 Usage examples:
47
48 ```ruby
49 # set an API endpoint
50 Gitlab.endpoint = 'http://example.net/api/v4'
51 # => "http://example.net/api/v4"
52
53 # set a user private token
54 Gitlab.private_token = 'qEsq1pt6HJPaNciie3MG'
55 # => "qEsq1pt6HJPaNciie3MG"
56
57 # configure a proxy server
58 Gitlab.http_proxy('proxyhost', 8888)
59 # proxy server w/ basic auth
60 Gitlab.http_proxy('proxyhost', 8888, 'proxyuser', 'strongpasswordhere')
61
62 # list projects
63 Gitlab.projects(per_page: 5)
64 # => [#<Gitlab::ObjectifiedHash:0x000000023326e0 @data={"id"=>1, "code"=>"brute", "name"=>"Brute", "description"=>nil, "path"=>"brute", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x00000002331600 @data={"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:56Z"}>, #<Gitlab::ObjectifiedHash:0x000000023450d8 @data={"id"=>2, "code"=>"mozart", "name"=>"Mozart", "description"=>nil, "path"=>"mozart", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x00000002344ca0 @data={"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:57Z"}>, #<Gitlab::ObjectifiedHash:0x00000002344958 @data={"id"=>3, "code"=>"gitlab", "name"=>"Gitlab", "description"=>nil, "path"=>"gitlab", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x000000023447a0 @data={"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"}>]
65
66 # initialize a new client
67 g = Gitlab.client(endpoint: 'https://api.example.com', private_token: 'qEsq1pt6HJPaNciie3MG')
68 # => #<Gitlab::Client:0x00000001e62408 @endpoint="https://api.example.com", @private_token="qEsq1pt6HJPaNciie3MG", @user_agent="Gitlab Ruby Gem 2.0.0">
69
70 # get a user
71 user = g.user
72 # => #<Gitlab::ObjectifiedHash:0x00000002217990 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "bio"=>nil, "skype"=>"", "linkedin"=>"", "twitter"=>"john", "dark_scheme"=>false, "theme_id"=>1, "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>
73
74 # get a user's email
75 user.email
76 # => "john@example.com"
77
78 # set a sudo mode to perform API calls as another user
79 Gitlab.sudo = 'other_user'
80 # => "other_user"
81
82 # disable a sudo mode
83 Gitlab.sudo = nil
84 # => nil
85
86 # a paginated response
87 projects = Gitlab.projects(per_page: 5)
88
89 # check existence of the next page
90 projects.has_next_page?
91
92 # retrieve the next page
93 projects.next_page
94
95 # iterate all projects
96 projects.auto_paginate do |project|
97 # do something
98 end
99
100 # retrieve all projects as an array
101 projects.auto_paginate
102 ```
103
104 For more information, refer to [documentation](http://rubydoc.info/gems/gitlab/frames).
105
106 ## CLI
107
108 It is possible to use this gem as a command line interface to gitlab. In order to make that work you need to set a few environment variables:
109 ```sh
110 export GITLAB_API_ENDPOINT=https://gitlab.yourcompany.com/api/v4
111 export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/account>
112 # This one is optional and can be used to set any HTTParty option you may need
113 # using YAML hash syntax. For example, this is how you would disable SSL
114 # verification (useful if using a self-signed cert).
115 export GITLAB_API_HTTPARTY_OPTIONS="{verify: false}"
116 ```
117
118 Usage:
119
120 When you want to know which CLI commands are supported, take a look at the client [commands implemented in this gem](http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client). Any of those methods can be called as a command by passing the parameters of the commands as parameters of the CLI.
121
122 Usage examples:
123
124 ```sh
125 # list users
126 # see: http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client/Users#users-instance_method
127 gitlab users
128
129 # get current user
130 # see: http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client/Users#user-instance_method
131 gitlab user
132
133 # get a user
134 # see: http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client/Users#user-instance_method
135 gitlab user 2
136
137 # filter output
138 gitlab user --only=id,username
139
140 gitlab user --except=email,bio
141
142 # get a user and render result as json
143 gitlab user 2 --json
144
145 # passing options hash to a command (use YAML)
146 # see: http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client/MergeRequests#create_merge_request-instance_method
147 gitlab create_merge_request 4 "New merge request" "{source_branch: 'new_branch', target_branch: 'master', assignee_id: 42}"
148
149 ```
150
151 ## CLI Shell
152
153 Usage examples:
154
155 ```sh
156 # start shell session
157 gitlab shell
158
159 # list available commands
160 gitlab> help
161
162 # list groups
163 gitlab> groups
164
165 # protect a branch
166 gitlab> protect_branch 1 master
167
168 # passing options hash to a command (use YAML)
169 gitlab> create_merge_request 4 "New merge request" "{source_branch: 'new_branch', target_branch: 'master', assignee_id: 42}"
170 ```
171
172 Web version is available at https://gitlab-live.herokuapp.com
173 For more information, refer to [website](http://narkoz.github.io/gitlab).
174
175 ## Development
176
177 After checking out the repo, run `bin/setup` to install dependencies. Then, run
178 `rake spec` to run the tests. You can also run `bin/console` for an interactive
179 prompt that will allow you to experiment.
180
181 For more information see [CONTRIBUTING.md](https://github.com/NARKOZ/gitlab/blob/master/CONTRIBUTING.md).
182
183 ## License
184
185 Released under the BSD 2-clause license. See LICENSE.txt for details.
0 require "bundler/gem_tasks"
1
2 require 'rspec/core/rake_task'
3 RSpec::Core::RakeTask.new(:spec) do |spec|
4 spec.pattern = FileList['spec/**/*_spec.rb']
5 spec.rspec_opts = ['--color', '--format d']
6 end
7
8 task default: :spec
0 #!/usr/bin/env ruby
1
2 # ENV['GITLAB_API_ENDPOINT'] = ''
3 # ENV['GITLAB_API_PRIVATE_TOKEN'] = ''
4
5 require 'bundler/setup'
6 require 'gitlab'
7 require 'pry'
8
9 Pry.start
0 #!/bin/bash
1 set -euo pipefail
2 IFS=$'\n\t'
3
4 bundle install &&
5 echo 'NOTE: You may need to set GITLAB_API_ENDPOINT and GITLAB_API_PRIVATE_TOKEN environment variables.'
0 #!/usr/bin/env ruby
1
2 $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
4 require 'gitlab/cli'
5
6 Gitlab::CLI.start(ARGV)
0 # -*- encoding: utf-8 -*-
1 lib = File.expand_path('../lib', __FILE__)
2 $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3 require 'gitlab/version'
4
5 Gem::Specification.new do |gem|
6 gem.name = "gitlab"
7 gem.version = Gitlab::VERSION
8 gem.authors = ["Nihad Abbasov"]
9 gem.email = ["mail@narkoz.me"]
10 gem.description = %q{Ruby client and CLI for GitLab API}
11 gem.summary = %q{A Ruby wrapper and CLI for the GitLab API}
12 gem.homepage = "https://github.com/narkoz/gitlab"
13
14 gem.files = `git ls-files`.split($/)
15 gem.bindir = "exe"
16 gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
17 gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18 gem.require_paths = ["lib"]
19 gem.license = "BSD"
20
21 gem.required_ruby_version = ">= 2.0.0"
22
23 gem.add_runtime_dependency 'httparty'
24 gem.add_runtime_dependency 'terminal-table'
25
26 gem.add_development_dependency 'pry'
27 gem.add_development_dependency 'rake'
28 gem.add_development_dependency 'rspec'
29 gem.add_development_dependency 'webmock'
30 end
0 module Gitlab
1 # @private
2 class API < Request
3 # @private
4 attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
5 # @private
6 alias_method :auth_token=, :private_token=
7
8 # Creates a new API.
9 # @raise [Error:MissingCredentials]
10 def initialize(options={})
11 options = Gitlab.options.merge(options)
12 (Configuration::VALID_OPTIONS_KEYS + [:auth_token]).each do |key|
13 send("#{key}=", options[key]) if options[key]
14 end
15 set_request_defaults(@sudo)
16 end
17 end
18 end
0 require 'gitlab'
1 require 'terminal-table/import'
2 require_relative 'cli_helpers'
3 require_relative 'shell'
4
5 class Gitlab::CLI
6 extend Helpers
7
8 # If set to true, JSON will be rendered as output
9 @render_json = false
10
11 # Starts a new CLI session.
12 #
13 # @example
14 # Gitlab::CLI.start(['help'])
15 # Gitlab::CLI.start(['help', 'issues'])
16 #
17 # @param [Array] args The command and it's optional arguments.
18 def self.start(args)
19 command = args.shift.strip rescue 'help'
20 run(command, args)
21 end
22
23 # Processes a CLI command and outputs a result to the stream (stdout).
24 #
25 # @example
26 # Gitlab::CLI.run('help')
27 # Gitlab::CLI.run('help', ['issues'])
28 #
29 # @param [String] cmd The name of a command.
30 # @param [Array] args The optional arguments for a command.
31 # @return [nil]
32 def self.run(cmd, args=[])
33 case cmd
34 when 'help'
35 puts help(args.shift) { |out| out.gsub!(/Gitlab\./, 'gitlab ') }
36 when 'info'
37 endpoint = Gitlab.endpoint ? Gitlab.endpoint : 'not set'
38 private_token = Gitlab.private_token ? Gitlab.private_token : 'not set'
39 puts "Gitlab endpoint is #{endpoint}"
40 puts "Gitlab private token is #{private_token}"
41 puts "Ruby Version is #{RUBY_VERSION}"
42 puts "Gitlab Ruby Gem #{Gitlab::VERSION}"
43 when '-v', '--version'
44 puts "Gitlab Ruby Gem #{Gitlab::VERSION}"
45 when 'shell'
46 Gitlab::Shell.start
47 else
48 if args.include? '--json'
49 @json_output = true
50 args.delete '--json'
51 end
52
53 unless valid_command?(cmd)
54 puts "Unknown command. Run `gitlab help` for a list of available commands."
55 exit(1)
56 end
57
58 if args.any? && (args.last.start_with?('--only=') || args.last.start_with?('--except='))
59 command_args = args[0..-2]
60 else
61 command_args = args
62 end
63
64 begin
65 command_args.map! { |arg| symbolize_keys(yaml_load(arg)) }
66 rescue => e
67 puts e.message
68 exit 1
69 end
70
71 confirm_command(cmd)
72
73 data = gitlab_helper(cmd, command_args) { exit(1) }
74
75 render_output(cmd, args, data)
76 end
77 end
78
79 # Helper method that checks whether we want to get the output as json
80 # @return [nil]
81 def self.render_output(cmd, args, data)
82 if @json_output
83 output_json(cmd, args, data)
84 else
85 output_table(cmd, args, data)
86 end
87 end
88 end
0 require 'yaml'
1 require 'json'
2 require 'base64'
3
4 class Gitlab::CLI
5 # Defines methods related to CLI output and formatting.
6 module Helpers
7 extend self
8
9 # Returns actions available to CLI & Shell
10 #
11 # @return [Array]
12 def actions
13 @actions ||= Gitlab.actions
14 end
15
16 # Returns Gitlab::Client instance
17 #
18 # @return [Gitlab::Client]
19 def client
20 @client ||= Gitlab::Client.new(endpoint: (Gitlab.endpoint || ''))
21 end
22
23 # Returns method names and their owners
24 #
25 # @return [Array<Hash>]
26 def method_owners
27 @method_owners ||= actions.map do |action|
28 {
29 name: action.to_s,
30 owner: client.method(action).owner.to_s
31 }
32 end
33 end
34
35 # Returns filtered required fields.
36 #
37 # @return [Array]
38 def required_fields(args)
39 if args.any? && args.last.is_a?(String) && args.last.start_with?('--only=')
40 args.last.gsub('--only=', '').split(',')
41 else
42 []
43 end
44 end
45
46 # Returns filtered excluded fields.
47 #
48 # @return [Array]
49 def excluded_fields(args)
50 if args.any? && args.last.is_a?(String) && args.last.start_with?('--except=')
51 args.last.gsub('--except=', '').split(',')
52 else
53 []
54 end
55 end
56
57 # Confirms command is valid.
58 #
59 # @return [Boolean]
60 def valid_command?(cmd)
61 command = cmd.is_a?(Symbol) ? cmd : cmd.to_sym
62 Gitlab.actions.include?(command)
63 end
64
65 # Confirms command with a desctructive action.
66 #
67 # @return [String]
68 def confirm_command(cmd)
69 if cmd.start_with?('remove_') || cmd.start_with?('delete_')
70 puts "Are you sure? (y/n)"
71 if %w(y yes).include?($stdin.gets.to_s.strip.downcase)
72 puts 'Proceeding..'
73 else
74 puts 'Command aborted.'
75 exit(1)
76 end
77 end
78 end
79
80 # Gets defined help for a specific command/action.
81 #
82 # @return [String]
83 def help(cmd=nil, &block)
84 if cmd.nil? || Gitlab::Help.help_map.key?(cmd)
85 Gitlab::Help.actions_table(cmd)
86 else
87 Gitlab::Help.get_help(cmd, &block)
88 end
89 end
90
91 # Outputs a nicely formatted table or error msg.
92 def output_table(cmd, args, data)
93 case data
94 when Gitlab::ObjectifiedHash, Gitlab::FileResponse
95 puts record_table([data], cmd, args)
96 when Gitlab::PaginatedResponse
97 puts record_table(data, cmd, args)
98 else # probably just an error msg
99 puts data
100 end
101 end
102
103 def output_json(cmd, args, data)
104 if data.empty?
105 puts '{}'
106 else
107 hash_result = case data
108 when Gitlab::ObjectifiedHash,Gitlab::FileResponse
109 record_hash([data], cmd, args, true)
110 when Gitlab::PaginatedResponse
111 record_hash(data, cmd, args)
112 else
113 { cmd: cmd, data: data, args: args }
114 end
115 puts JSON.pretty_generate(hash_result)
116 end
117 end
118
119 # Table to display records.
120 #
121 # @return [Terminal::Table]
122 def record_table(data, cmd, args)
123 return 'No data' if data.empty?
124
125 arr, keys = get_keys(args, data)
126
127 table do |t|
128 t.title = "Gitlab.#{cmd} #{args.join(', ')}"
129 t.headings = keys
130
131 arr.each_with_index do |hash, index|
132 values = []
133
134 keys.each do |key|
135 case value = hash[key]
136 when Hash
137 value = value.has_key?('id') ? value['id'] : 'Hash'
138 when StringIO
139 value = 'File'
140 when nil
141 value = 'null'
142 end
143
144 values << value
145 end
146
147 t.add_row values
148 t.add_separator unless arr.size - 1 == index
149 end
150 end
151 end
152
153 # Renders the result of given commands and arguments into a Hash
154 #
155 # @param [Array] data Resultset from the API call
156 # @param [String] cmd The command passed to the API
157 # @param [Array] args Options passed to the API call
158 # @param [bool] single_value If set to true, a single result should be returned
159 # @return [Hash] Result hash
160 def record_hash(data, cmd, args, single_value=false)
161 if data.empty?
162 result = nil
163 else
164 arr, keys = get_keys(args, data)
165 result = []
166 arr.each do |hash|
167 row = {}
168
169 keys.each do |key|
170 case hash[key]
171 when Hash
172 row[key] = 'Hash'
173 when StringIO
174 row[key] = Base64.encode64(hash[key].read)
175 when nil
176 row[key] = nil
177 else
178 row[key] = hash[key]
179 end
180 end
181
182 result.push row
183 end
184 result = result[0] if single_value && result.count > 0
185 end
186
187 {
188 cmd: "Gitlab.#{cmd} #{args.join(', ')}".strip,
189 result: result
190 }
191 end
192
193 # Helper function to get rows and keys from data returned from API call
194 def get_keys(args, data)
195 arr = data.map(&:to_h)
196 keys = arr.first.keys.sort { |x, y| x.to_s <=> y.to_s }
197 keys &= required_fields(args) if required_fields(args).any?
198 keys -= excluded_fields(args)
199 [arr, keys]
200 end
201
202 # Helper function to call Gitlab commands with args.
203 def gitlab_helper(cmd, args=[])
204 begin
205 data = args.any? ? Gitlab.send(cmd, *args) : Gitlab.send(cmd)
206 rescue => e
207 puts e.message
208 yield if block_given?
209 end
210
211 data
212 end
213
214 # Convert a hash (recursively) to use symbol hash keys
215 # @return [Hash]
216 def symbolize_keys(hash)
217 if hash.is_a?(Hash)
218 hash = hash.each_with_object({}) do |(key, value), newhash|
219 begin
220 newhash[key.to_sym] = symbolize_keys(value)
221 rescue NoMethodError
222 raise "error: cannot convert hash key to symbol: #{key}"
223 end
224 end
225 end
226
227 hash
228 end
229
230 # YAML::load on a single argument
231 def yaml_load(arg)
232 begin
233 yaml = YAML.load(arg)
234 rescue Psych::SyntaxError
235 raise "error: Argument is not valid YAML syntax: #{arg}"
236 end
237 yaml
238 end
239 end
240 end
0 class Gitlab::Client
1 # Defines methods related to repositories.
2 # @see https://docs.gitlab.com/ce/api/branches.html
3 module Branches
4 # Gets a list of project repositiory branches.
5 #
6 # @example
7 # Gitlab.branches(42)
8 #
9 # @param [Integer, String] project The ID or name of a project.
10 # @param [Hash] options A customizable set of options.
11 # @option options [Integer] :page The page number.
12 # @option options [Integer] :per_page The number of results per page.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def branches(project, options={})
15 get("/projects/#{url_encode project}/repository/branches", query: options)
16 end
17 alias_method :repo_branches, :branches
18
19 # Gets information about a repository branch.
20 #
21 # @example
22 # Gitlab.branch(3, 'api')
23 # Gitlab.repo_branch(5, 'master')
24 #
25 # @param [Integer, String] project The ID or name of a project.
26 # @param [String] branch The name of the branch.
27 # @return [Gitlab::ObjectifiedHash]
28 def branch(project, branch)
29 get("/projects/#{url_encode project}/repository/branches/#{branch}")
30 end
31 alias_method :repo_branch, :branch
32
33 # Protects a repository branch.
34 #
35 # @example
36 # Gitlab.protect_branch(3, 'api')
37 # Gitlab.repo_protect_branch(5, 'master')
38 #
39 # @param [Integer, String] project The ID or name of a project.
40 # @param [String] branch The name of the branch.
41 # @return [Gitlab::ObjectifiedHash]
42 def protect_branch(project, branch)
43 put("/projects/#{url_encode project}/repository/branches/#{branch}/protect")
44 end
45 alias_method :repo_protect_branch, :protect_branch
46
47 # Unprotects a repository branch.
48 #
49 # @example
50 # Gitlab.unprotect_branch(3, 'api')
51 # Gitlab.repo_unprotect_branch(5, 'master')
52 #
53 # @param [Integer, String] project The ID or name of a project.
54 # @param [String] branch The name of the branch.
55 # @return [Gitlab::ObjectifiedHash]
56 def unprotect_branch(project, branch)
57 put("/projects/#{url_encode project}/repository/branches/#{branch}/unprotect")
58 end
59 alias_method :repo_unprotect_branch, :unprotect_branch
60
61 # Creates a repository branch. Requires Gitlab >= 6.8.x
62 #
63 # @example
64 # Gitlab.create_branch(3, 'api')
65 # Gitlab.repo_create_branch(5, 'master')
66 #
67 # @param [Integer, String] project The ID or name of a project.
68 # @param [String] branch The name of the new branch.
69 # @param [String] ref Create branch from commit sha or existing branch
70 # @return [Gitlab::ObjectifiedHash]
71 def create_branch(project, branch, ref)
72 post("/projects/#{url_encode project}/repository/branches", body: { branch_name: branch, ref: ref })
73 end
74 alias_method :repo_create_branch, :create_branch
75
76 # Deletes a repository branch. Requires Gitlab >= 6.8.x
77 #
78 # @example
79 # Gitlab.delete_branch(3, 'api')
80 # Gitlab.repo_delete_branch(5, 'master')
81 #
82 # @param [Integer, String] project The ID or name of a project.
83 # @param [String] branch The name of the branch to delete
84 # @return [Gitlab::ObjectifiedHash]
85 def delete_branch(project, branch)
86 delete("/projects/#{url_encode project}/repository/branches/#{branch}")
87 end
88 alias_method :repo_delete_branch, :delete_branch
89 end
90 end
0 class Gitlab::Client
1 # Defines methods related to builds.
2 # @see https://docs.gitlab.com/ce/api/build_variables.html
3 module BuildVariables
4 # Gets a list of the project's build variables
5 #
6 # @example
7 # Gitlab.variables(5)
8 #
9 # @param [Integer, String] project The ID or name of a project.
10 # @return [Array<Gitlab::ObjectifiedHash>] The list of variables.
11 def variables(project)
12 get("/projects/#{url_encode project}/variables")
13 end
14
15 # Gets details of a project's specific build variable.
16 #
17 # @example
18 # Gitlab.build(5, "TEST_VARIABLE_1")
19 #
20 # @param [Integer, String] project The ID or name of a project.
21 # @param [String] key The key of a variable.
22 # @return [Gitlab::ObjectifiedHash] The variable.
23 def variable(project, key)
24 get("/projects/#{url_encode project}/variables/#{key}")
25 end
26
27 # Create a build variable for a project.
28 #
29 # @example
30 # Gitlab.create_variable(5, "NEW_VARIABLE", "new value")
31 #
32 # @param [Integer, String] project The ID or name of a project.
33 # @param [String] key The key of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9` and `_` are allowed
34 # @param [String] value The value of a variable
35 # @return [Gitlab::ObjectifiedHash] The variable.
36 def create_variable(project, key, value)
37 post("/projects/#{url_encode project}/variables", body: { key: key, value: value })
38 end
39
40 # Update a project's build variable.
41 #
42 # @example
43 # Gitlab.create_variable(5, "NEW_VARIABLE", "updated value")
44 #
45 # @param [Integer, String] project The ID or name of a project.
46 # @param [String] key The key of a variable
47 # @param [String] value The value of a variable
48 # @return [Gitlab::ObjectifiedHash] The variable.
49 def update_variable(project, key, value)
50 put("/projects/#{url_encode project}/variables/#{key}", body: { value: value })
51 end
52
53 # Remove a project's build variable.
54 #
55 # @example
56 # Gitlab.remove_variable(5, "VARIABLE_1")
57 #
58 # @param [Integer, String] project The ID or name of a project.
59 # @param [String] key The key of a variable.
60 # @return [Gitlab::ObjectifiedHash] The variable.
61 def remove_variable(project, key)
62 delete("/projects/#{url_encode project}/variables/#{key}")
63 end
64 end
65 end
0 class Gitlab::Client
1 # Defines methods related to builds.
2 # @see https://docs.gitlab.com/ce/api/builds.html
3 module Builds
4 # Gets a list of project builds.
5 #
6 # @example
7 # Gitlab.builds(5)
8 # Gitlab.builds(5, { per_page: 10, page: 2 })
9 #
10 # @param [Integer, String] project The ID or name of a project.
11 # @param [Hash] options A customizable set of options.
12 # @option options [Integer] :page The page number.
13 # @option options [Integer] :per_page The number of results per page.
14 # @param [Integer, String] project The ID or name of a project.
15 # @return [Array<Gitlab::ObjectifiedHash>]
16 def builds(project, options={})
17 get("/projects/#{url_encode project}/builds", query: options)
18 end
19
20 # Gets a single build.
21 #
22 # @example
23 # Gitlab.build(5, 36)
24 #
25 # @param [Integer, String] project The ID or name of a project.
26 # @param [Integer] id The ID of a build.
27 # @return [Gitlab::ObjectifiedHash]
28 def build(project, id)
29 get("/projects/#{url_encode project}/builds/#{id}")
30 end
31
32 # Gets build artifacts.
33 #
34 # @example
35 # Gitlab.build_artifacts(1, 8)
36 #
37 # @param [Integer, String] project The ID or name of a project.
38 # @param [Integer] id The ID of a build.
39 # @return [Gitlab::FileResponse]
40 def build_artifacts(project, id)
41 get("/projects/#{url_encode project}/builds/#{id}/artifacts",
42 format: nil,
43 headers: { Accept: 'application/octet-stream' },
44 parser: proc { |body, _|
45 if body.encoding == Encoding::ASCII_8BIT # binary response
46 ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
47 else # error with json response
48 ::Gitlab::Request.parse(body)
49 end
50 })
51 end
52
53 # Gets a list of builds for specific commit in a project.
54 #
55 # @example
56 # Gitlab.commit_builds(5, 'asdf')
57 # Gitlab.commit_builds(5, 'asdf', { per_page: 10, page: 2 })
58 #
59 # @param [Integer, String] project The ID or name of a project.
60 # @param [String] sha The SHA checksum of a commit.
61 # @param [Hash] options A customizable set of options.
62 # @option options [Integer] :page The page number.
63 # @option options [Integer] :per_page The number of results per page.
64 # @return [Array<Gitlab::ObjectifiedHash>] The list of builds.
65 def commit_builds(project, sha, options={})
66 get("/projects/#{url_encode project}/repository/commits/#{sha}/builds", query: options)
67 end
68
69 # Cancels a build.
70 #
71 # @example
72 # Gitlab.build_cancel(5, 1)
73 #
74 # @param [Integer, String] project The ID or name of a project.
75 # @param [Integer] id The ID of a build.
76 # @return [Gitlab::ObjectifiedHash] The builds changes.
77 def build_cancel(project, id)
78 post("/projects/#{url_encode project}/builds/#{id}/cancel")
79 end
80
81 # Retry a build.
82 #
83 # @example
84 # Gitlab.build_retry(5, 1)
85 #
86 # @param [Integer, String] project The ID or name of a project.
87 # @param [Integer] id The ID of a build.
88 # @return [Array<Gitlab::ObjectifiedHash>] The builds changes.
89 def build_retry(project, id)
90 post("/projects/#{url_encode project}/builds/#{id}/retry")
91 end
92
93 # Erase a single build of a project (remove build artifacts and a build trace)
94 #
95 # @example
96 # Gitlab.build_erase(5, 1)
97 #
98 # @param [Integer, String] project The ID or name of a project.
99 # @param [Integer] id The ID of a build.
100 # @return [Gitlab::ObjectifiedHash] The build's changes.
101 def build_erase(project, id)
102 post("/projects/#{url_encode project}/builds/#{id}/erase")
103 end
104 end
105 end
0 class Gitlab::Client
1 # Defines methods related to repository commits.
2 # @see https://docs.gitlab.com/ce/api/commits.html
3 module Commits
4 # Gets a list of project commits.
5 #
6 # @example
7 # Gitlab.commits('viking')
8 # Gitlab.repo_commits('gitlab', { ref_name: 'api' })
9 #
10 # @param [Integer, String] project The ID or name of a project.
11 # @param [Hash] options A customizable set of options.
12 # @option options [String] :ref_name The branch or tag name of a project repository.
13 # @option options [Integer] :page The page number.
14 # @option options [Integer] :per_page The number of results per page.
15 # @return [Array<Gitlab::ObjectifiedHash>]
16 def commits(project, options={})
17 get("/projects/#{url_encode project}/repository/commits", query: options)
18 end
19 alias_method :repo_commits, :commits
20
21 # Gets a specific commit identified by the commit hash or name of a branch or tag.
22 #
23 # @example
24 # Gitlab.commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
25 # Gitlab.repo_commit(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
26 #
27 # @param [Integer, String] project The ID or name of a project.
28 # @param [String] sha The commit hash or name of a repository branch or tag
29 # @return [Gitlab::ObjectifiedHash]
30 def commit(project, sha)
31 get("/projects/#{url_encode project}/repository/commits/#{sha}")
32 end
33 alias_method :repo_commit, :commit
34
35 # Get the diff of a commit in a project.
36 #
37 # @example
38 # Gitlab.commit_diff(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
39 # Gitlab.repo_commit_diff(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
40 #
41 # @param [Integer, String] project The ID or name of a project.
42 # @param [String] sha The name of a repository branch or tag or if not given the default branch.
43 # @return [Gitlab::ObjectifiedHash]
44 def commit_diff(project, sha)
45 get("/projects/#{url_encode project}/repository/commits/#{sha}/diff")
46 end
47 alias_method :repo_commit_diff, :commit_diff
48
49 # Gets a list of comments for a commit.
50 #
51 # @example
52 # Gitlab.commit_comments(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b')
53 #
54 # @param [Integer] project The ID of a project.
55 # @param [String] sha The commit hash or name of a repository branch or tag.
56 # @option options [Integer] :page The page number.
57 # @option options [Integer] :per_page The number of results per page.
58 # @return [Array<Gitlab::ObjectifiedHash>]
59 def commit_comments(project, commit, options={})
60 get("/projects/#{url_encode project}/repository/commits/#{commit}/comments", query: options)
61 end
62 alias_method :repo_commit_comments, :commit_comments
63
64 # Creates a new comment for a commit.
65 #
66 # @example
67 # Gitlab.create_commit_comment(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b', 'Nice work on this commit!')
68 #
69 # @param [Integer, String] project The ID or name of a project.
70 # @param [String] sha The commit hash or name of a repository branch or tag.
71 # @param [String] note The text of a comment.
72 # @param [Hash] options A customizable set of options.
73 # @option options [String] :path The file path.
74 # @option options [Integer] :line The line number.
75 # @option options [String] :line_type The line type (new or old).
76 # @return [Gitlab::ObjectifiedHash] Information about created comment.
77 def create_commit_comment(project, commit, note, options={})
78 post("/projects/#{url_encode project}/repository/commits/#{commit}/comments", body: options.merge(note: note))
79 end
80 alias_method :repo_create_commit_comment, :create_commit_comment
81
82 # Get the status of a commit
83 #
84 # @example
85 # Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
86 # Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins' })
87 # Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins', all: true })
88 #
89 # @param [Integer, String] project The ID or name of a project.
90 # @param [String] sha The commit hash
91 # @param [Hash] options A customizable set of options.
92 # @option options [String] :ref Filter by ref name, it can be branch or tag
93 # @option options [String] :stage Filter by stage
94 # @option options [String] :name Filter by status name, eg. jenkins
95 # @option options [Boolean] :all The flag to return all statuses, not only latest ones
96 def commit_status(id, sha, options={})
97 get("/projects/#{id}/repository/commits/#{sha}/statuses", query: options)
98 end
99 alias_method :repo_commit_status, :commit_status
100
101 # Adds or updates a status of a commit.
102 #
103 # @example
104 # Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'success')
105 # Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'failed', { name: 'jenkins' })
106 # Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'canceled', { name: 'jenkins', target_url: 'http://example.com/builds/1' })
107 #
108 # @param [Integer, String] project The ID or name of a project.
109 # @param [String] sha The commit hash
110 # @param [String] state of the status. Can be: pending, running, success, failed, canceled
111 # @param [Hash] options A customizable set of options.
112 # @option options [String] :ref The ref (branch or tag) to which the status refers
113 # @option options [String] :name Filter by status name, eg. jenkins
114 # @option options [String] :target_url The target URL to associate with this status
115 def update_commit_status(id, sha, state, options={})
116 post("/projects/#{id}/statuses/#{sha}", query: options.merge(state: state))
117 end
118 alias_method :repo_update_commit_status, :update_commit_status
119
120 # Creates a single commit with one or more changes
121 #
122 # @see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
123 # Introduced in Gitlab 8.13
124 #
125 # @example
126 # Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'create', file_path: '/foo.txt', content: 'bar'}])
127 # Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'delete', file_path: '/foo.txt'}])
128 #
129 # @param [Integer, String] project The ID or name of a project.
130 # @param [String] branch the branch name you wish to commit to
131 # @param [String] message the commit message
132 # @param [Array[Hash]] An array of action hashes to commit as a batch. See the next table for what attributes it can take.
133 # @option options [String] :author_email the email address of the author
134 # @option options [String] :author_name the name of the author
135 # @return [Gitlab::ObjectifiedHash] hash of commit related data
136 def create_commit(project, branch, message, actions, options={})
137 payload = {
138 branch_name: branch,
139 commit_message: message,
140 actions: actions,
141 }.merge(options)
142 post("/projects/#{url_encode project}/repository/commits", query: payload)
143 end
144 end
145 end
0 class Gitlab::Client
1 # Defines methods related to groups.
2 # @see https://docs.gitlab.com/ce/api/groups.html
3 module Groups
4 # Gets a list of groups.
5 #
6 # @example
7 # Gitlab.groups
8 # Gitlab.groups({ per_page: 40, page: 2 })
9 #
10 # @param [Hash] options A customizable set of options.
11 # @option options [Integer] :page The page number.
12 # @option options [Integer] :per_page The number of results per page.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def groups(options={})
15 get("/groups", query: options)
16 end
17
18 # Gets a single group.
19 #
20 # @example
21 # Gitlab.group(42)
22 #
23 # @param [Integer] id The ID of a group.
24 # @return [Gitlab::ObjectifiedHash]
25 def group(id)
26 get("/groups/#{id}")
27 end
28
29 # Creates a new group.
30 #
31 # @example
32 # Gitlab.create_group('new-group', 'group-path')
33 # Gitlab.create_group('gitlab', 'gitlab-path', { description: 'New Gitlab project' })
34 #
35 # @param [String] name The name of a group.
36 # @param [String] path The path of a group.
37 # @return [Gitlab::ObjectifiedHash] Information about created group.
38 def create_group(name, path, options={})
39 body = { name: name, path: path }.merge(options)
40 post("/groups", body: body)
41 end
42
43 # Delete's a group.
44 #
45 # @example
46 # Gitlab.delete_group(42)
47 # @param [Integer] id The ID of a group
48 # @return [Gitlab::ObjectifiedHash] Information about the deleted group.
49 def delete_group(id)
50 delete("/groups/#{id}")
51 end
52
53 # Get a list of group members.
54 #
55 # @example
56 # Gitlab.group_members(1)
57 # Gitlab.group_members(1, { per_page: 40 })
58 #
59 # @param [Integer] id The ID of a group.
60 # @param [Hash] options A customizable set of options.
61 # @option options [Integer] :page The page number.
62 # @option options [Integer] :per_page The number of results per page.
63 # @return [Array<Gitlab::ObjectifiedHash>]
64 def group_members(id, options={})
65 get("/groups/#{id}/members", query: options)
66 end
67
68 # Adds a user to group.
69 #
70 # @example
71 # Gitlab.add_group_member(1, 2, 40)
72 #
73 # @param [Integer] team_id The group id to add a member to.
74 # @param [Integer] user_id The user id of the user to add to the team.
75 # @param [Integer] access_level Project access level.
76 # @return [Gitlab::ObjectifiedHash] Information about added team member.
77 def add_group_member(team_id, user_id, access_level)
78 post("/groups/#{team_id}/members", body: { user_id: user_id, access_level: access_level })
79 end
80
81 # Edit a user of a group.
82 #
83 # @example
84 # Gitlab.edit_group_member(1, 2, 40)
85 #
86 # @param [Integer] team_id The group id of member to edit.
87 # @param [Integer] user_id The user id of the user to edit.
88 # @param [Integer] access_level Project access level.
89 # @return [Gitlab::ObjectifiedHash] Information about edited team member.
90 def edit_group_member(team_id, user_id, access_level)
91 put("/groups/#{team_id}/members/#{user_id}", body: { access_level: access_level })
92 end
93
94 # Removes user from user group.
95 #
96 # @example
97 # Gitlab.remove_group_member(1, 2)
98 #
99 # @param [Integer] team_id The group ID.
100 # @param [Integer] user_id The ID of a user.
101 # @return [Gitlab::ObjectifiedHash] Information about removed team member.
102 def remove_group_member(team_id, user_id)
103 delete("/groups/#{team_id}/members/#{user_id}")
104 end
105
106 # Transfers a project to a group
107 #
108 # @example
109 # Gitlab.transfer_project_to_group(3, 50)
110 #
111 # @param [Integer] id The ID of a group.
112 # @param [Integer] project_id The ID of a project.
113 def transfer_project_to_group(id, project_id)
114 body = { id: id, project_id: project_id }
115 post("/groups/#{id}/projects/#{project_id}", body: body)
116 end
117
118 # Search for groups by name
119 #
120 # @example
121 # Gitlab.group_search('gitlab')
122 #
123 # @param [String] search A string to search for in group names and paths.
124 # @param [Hash] options A customizable set of options.
125 # @option options [String] :per_page Number of projects to return per page
126 # @option options [String] :page The page to retrieve
127 # @return [Array<Gitlab::ObjectifiedHash>]
128 def group_search(search, options={})
129 options[:search] = search
130 get("/groups", query: options)
131 end
132
133 # Get a list of projects under a group
134 # @example
135 # Gitlab.group_projects(1)
136 #
137 # @param [Integer] id The ID of a group
138 # @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group
139 def group_projects(id, options={})
140 get("/groups/#{id}/projects", query: options)
141 end
142 end
143 end
0 class Gitlab::Client
1 # Defines methods related to issues.
2 # @see https://docs.gitlab.com/ce/api/issues.html
3 module Issues
4 # Gets a list of user's issues.
5 # Will return a list of project's issues if project ID passed.
6 #
7 # @example
8 # Gitlab.issues
9 # Gitlab.issues(5)
10 # Gitlab.issues({ per_page: 40 })
11 #
12 # @param [Integer, String] project The ID or name of a project.
13 # @param [Hash] options A customizable set of options.
14 # @option options [Integer] :page The page number.
15 # @option options [Integer] :per_page The number of results per page.
16 # @return [Array<Gitlab::ObjectifiedHash>]
17 def issues(project=nil, options={})
18 if project.to_s.empty? && project.to_i.zero?
19 get("/issues", query: options)
20 else
21 get("/projects/#{url_encode project}/issues", query: options)
22 end
23 end
24
25 # Gets a single issue.
26 #
27 # @example
28 # Gitlab.issue(5, 42)
29 #
30 # @param [Integer, String] project The ID or name of a project.
31 # @param [Integer] id The ID of an issue.
32 # @return [Gitlab::ObjectifiedHash]
33 def issue(project, id)
34 get("/projects/#{url_encode project}/issues/#{id}")
35 end
36
37 # Creates a new issue.
38 #
39 # @example
40 # Gitlab.create_issue(5, 'New issue')
41 # Gitlab.create_issue(5, 'New issue', { description: 'This is a new issue', assignee_id: 42 })
42 #
43 # @param [Integer, String] project The ID or name of a project.
44 # @param [String] title The title of an issue.
45 # @param [Hash] options A customizable set of options.
46 # @option options [String] :description The description of an issue.
47 # @option options [Integer] :assignee_id The ID of a user to assign issue.
48 # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
49 # @option options [String] :labels Comma-separated label names for an issue.
50 # @return [Gitlab::ObjectifiedHash] Information about created issue.
51 def create_issue(project, title, options={})
52 body = { title: title }.merge(options)
53 post("/projects/#{url_encode project}/issues", body: body)
54 end
55
56 # Updates an issue.
57 #
58 # @example
59 # Gitlab.edit_issue(6, 1, { title: 'Updated title' })
60 #
61 # @param [Integer, String] project The ID or name of a project.
62 # @param [Integer] id The ID of an issue.
63 # @param [Hash] options A customizable set of options.
64 # @option options [String] :title The title of an issue.
65 # @option options [String] :description The description of an issue.
66 # @option options [Integer] :assignee_id The ID of a user to assign issue.
67 # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
68 # @option options [String] :labels Comma-separated label names for an issue.
69 # @option options [String] :state_event The state event of an issue ('close' or 'reopen').
70 # @return [Gitlab::ObjectifiedHash] Information about updated issue.
71 def edit_issue(project, id, options={})
72 put("/projects/#{url_encode project}/issues/#{id}", body: options)
73 end
74
75 # Closes an issue.
76 #
77 # @example
78 # Gitlab.close_issue(3, 42)
79 #
80 # @param [Integer, String] project The ID or name of a project.
81 # @param [Integer] id The ID of an issue.
82 # @return [Gitlab::ObjectifiedHash] Information about closed issue.
83 def close_issue(project, id)
84 put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'close' })
85 end
86
87 # Reopens an issue.
88 #
89 # @example
90 # Gitlab.reopen_issue(3, 42)
91 #
92 # @param [Integer, String] project The ID or name of a project.
93 # @param [Integer] id The ID of an issue.
94 # @return [Gitlab::ObjectifiedHash] Information about reopened issue.
95 def reopen_issue(project, id)
96 put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'reopen' })
97 end
98
99 # Subscribe to an issue.
100 #
101 # @example
102 # Gitlab.subscribe_to_issue(3, 42)
103 #
104 # @param [Integer, String] project The ID or name of a project.
105 # @param [Integer] id The ID of an issue.
106 # @return [Gitlab::ObjectifiedHash] Information about subscribed issue.
107 def subscribe_to_issue(project, id)
108 post("/projects/#{url_encode project}/issues/#{id}/subscribe")
109 end
110
111 # Unsubscribe from an issue.
112 #
113 # @example
114 # Gitlab.unsubscribe_from_issue(3, 42)
115 #
116 # @param [Integer, String] project The ID or name of a project.
117 # @param [Integer] id The ID of an issue.
118 # @return [Gitlab::ObjectifiedHash] Information about unsubscribed issue.
119 def unsubscribe_from_issue(project, id)
120 post("/projects/#{url_encode project}/issues/#{id}/unsubscribe")
121 end
122
123 # Deletes an issue.
124 # Only for admins and project owners
125 #
126 # @example
127 # Gitlab.delete_issue(3, 42)
128 #
129 # @param [Integer, String] project The ID or name of a project.
130 # @param [Integer] id The ID of an issue.
131 # @return [Gitlab::ObjectifiedHash] Information about deleted issue.
132 def delete_issue(project, id)
133 delete("/projects/#{url_encode project}/issues/#{id}")
134 end
135 end
136 end
0 class Gitlab::Client
1 # Defines methods related to projects.
2 # @see https://docs.gitlab.com/ee/api/jobs.html
3 module Jobs
4 # Gets a list of Jobs for a Project
5 #
6 # @example
7 # Gitlab.jobs(1)
8 # Gitlab.jobs("project")
9 #
10 # @param [Integer, String] id The ID or name of a project.
11 # @param [Hash] options A customizable set of options.
12 # @option options [Array] :scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def jobs(project_id, options = {})
15 get("/projects/#{url_encode project_id}/jobs", query: options)
16 end
17
18 # Gets a list of Jobs from a pipeline
19 #
20 # @example
21 # Gitlab.pipeline_jobs(1, 2)
22 # Gitlab.pipeline_jobs("project", 2)
23 #
24 # @param [Integer, String] The ID or name of a project.
25 # @param [Integer] the id of the pipeline
26 # @param [Hash] options A customizable set of options.
27 # @option options [Array] :scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided.
28 # @return [Array<Gitlab::ObjectifiedHash>]
29 def pipeline_jobs(project_id, pipeline_id, options = {})
30 get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
31 end
32
33 # Gets a single job
34 #
35 # @example
36 # Gitlab.job(1, 2)
37 # Gitlab.job("project", 2)
38 #
39 # @param [Integer, String] The ID or name of a project.
40 # @param [Integer] the id of the job
41 def job(project_id, job_id)
42 get("/projects/#{url_encode project_id}/jobs/#{job_id}")
43 end
44
45 # Gets artifacts from a job
46 #
47 # @example
48 # Gitlab.job_artifacts(1, 2)
49 # Gitlab.job_artifacts("project", 2)
50 #
51 # @param [Integer, String] The ID or name of a project.
52 # @param [Integer] the id of the job
53 # @return [Array<Gitlab::ObjectifiedHash>]
54 def job_artifacts(project_id, job_id)
55 get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts",
56 format: nil,
57 headers: { Accept: 'text/plain' },
58 parser: ::Gitlab::Request::Parser)
59 end
60
61 # Download Job Artifact
62 #
63 # @example
64 # Gitlab.job_artifacts_download(1, "master", "release")
65 # Gitlab.job_artifacts_download("project", "master", "release")
66 #
67 # @param [Integer, String] id, The ID or name of a project.
68 # @param [String] ref, Ref Name
69 # @param [String] job, jobname
70 # @return [Array<Gitlab::ObjectifiedHash>]
71 def job_artifacts_download(project_id, ref_name, job_name)
72 get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download", query: { job: job_name },
73 format: nil,
74 headers: { Accept: 'text/plain' },
75 parser: ::Gitlab::Request::Parser)
76 end
77
78 # Get Job Trace
79 #
80 # @example
81 # Gitlab.job_trace(1,1)
82 # Gitlab.job_trace("project", 1)
83 #
84 # @param [Integer, String] The ID or name of a project.
85 # @param [Integer] the id of the job
86 # @return [Array<Gitlab::ObjectifiedHash>]
87 def job_trace(project_id, job_id)
88 get("/projects/#{url_encode project_id}/jobs/#{job_id}/trace",
89 format: nil,
90 headers: { Accept: 'text/plain' },
91 parser: ::Gitlab::Request::Parser)
92 end
93
94 # Cancel a job
95 #
96 # @example
97 # Gitlab.job_cancel(1,1)
98 # Gitlab.job_cancel("project", 1)
99 #
100 # @param [Integer, String] The ID or name of a project.
101 # @param [Integer] the id of the job
102 # @return [Array<Gitlab::ObjectifiedHash>]
103 def job_cancel(project_id, job_id)
104 post("/projects/#{url_encode project_id}/jobs/#{job_id}/cancel")
105 end
106
107 # Retry a job
108 #
109 # @example
110 # Gitlab.job_retry(1,1)
111 # Gitlab.job_retry("project", 1)
112 #
113 # @param [Integer, String] The ID or name of a project.
114 # @param [Integer] the id of the job
115 # @return [Array<Gitlab::ObjectifiedHash>]
116 def job_retry(project_id, job_id)
117 post("/projects/#{url_encode project_id}/jobs/#{job_id}/retry")
118 end
119
120 # Erase Job
121 #
122 # @example
123 # Gitlab.job_erase(1,1)
124 # Gitlab.job_erase("project", 1)
125 #
126 # @param [Integer, String] The ID or name of a project.
127 # @param [Integer] the id of the job
128 # @return [Array<Gitlab::ObjectifiedHash>]
129 def job_erase(project_id, job_id)
130 post("/projects/#{url_encode project_id}/jobs/#{job_id}/erase")
131 end
132
133 # Play a Job
134 # Triggers a manual action to start a job.
135 #
136 # @example
137 # Gitlab.job_play(1,1)
138 # Gitlab.job_play("project", 1)
139 #
140 # @param [Integer, String] The ID or name of a project.
141 # @param [Integer] the id of the job
142 # @return [Array<Gitlab::ObjectifiedHash>]
143 def job_play(project_id, job_id)
144 post("/projects/#{url_encode project_id}/jobs/#{job_id}/play")
145 end
146
147 # Keep Artifacts
148 # Prevents artifacts from being deleted when expiration is set.
149 #
150 # @example
151 # Gitlab.job_artifacts_keep(1,1)
152 # Gitlab.job_artifacts_keep("project", 1)
153 #
154 # @param [Integer, String] The ID or name of a project.
155 # @param [Integer] the id of the job
156 # @return [Array<Gitlab::ObjectifiedHash>]
157 def job_artifacts_keep(project_id, job_id)
158 post("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/keep")
159 end
160 end
161 end
0 class Gitlab::Client
1 # Defines methods related to keys.
2 # @see https://docs.gitlab.com/ce/api/keys.html
3 module Keys
4 # Gets information about a key.
5 #
6 # @example
7 # Gitlab.key(1)
8 #
9 # @param [Integer] id The ID of a key.
10 # @return [Gitlab::ObjectifiedHash]
11 def key(id)
12 get("/keys/#{id}")
13 end
14 end
15 end
0 class Gitlab::Client
1 # Defines methods related to labels.
2 # @see https://docs.gitlab.com/ce/api/labels.html
3 module Labels
4 # Gets a list of project's labels.
5 #
6 # @example
7 # Gitlab.labels(5)
8 #
9 # @param [Integer, String] project The ID or name of a project.
10 # @return [Array<Gitlab::ObjectifiedHash>]
11 def labels(project)
12 get("/projects/#{url_encode project}/labels")
13 end
14
15 # Creates a new label.
16 #
17 # @example
18 # Gitlab.create_label(42, "Backlog", '#DD10AA')
19 #
20 # @param [Integer, String] project The ID or name of a project.
21 # @option [String] name The name of a label.
22 # @option [String] color The color of a label.
23 # @return [Gitlab::ObjectifiedHash] Information about created label.
24 def create_label(project, name, color)
25 post("/projects/#{url_encode project}/labels", body: { name: name, color: color })
26 end
27
28 # Updates a label.
29 #
30 # @example
31 # Gitlab.edit_label(42, "Backlog", { new_name: 'TODO' })
32 # Gitlab.edit_label(42, "Backlog", { new_name: 'TODO', color: '#DD10AA' })
33 #
34 # @param [Integer, String] project The ID or name of a project.
35 # @param [String] name The name of a label.
36 # @param [Hash] options A customizable set of options.
37 # @option options [String] :new_name The new name of a label.
38 # @option options [String] :color The color of a label.
39 # @return [Gitlab::ObjectifiedHash] Information about updated label.
40 def edit_label(project, name, options={})
41 put("/projects/#{url_encode project}/labels", body: options.merge(name: name))
42 end
43
44 # Deletes a label.
45 #
46 # @example
47 # Gitlab.delete_label(2, 'Backlog')
48 #
49 # @param [Integer, String] project The ID or name of a project.
50 # @param [String] name The name of a label.
51 # @return [Gitlab::ObjectifiedHash] Information about deleted label.
52 def delete_label(project, name)
53 delete("/projects/#{url_encode project}/labels", body: { name: name })
54 end
55 end
56 end
0 class Gitlab::Client
1 # Defines methods related to merge requests.
2 # @see https://docs.gitlab.com/ce/api/merge_requests.html
3 module MergeRequests
4 # Gets a list of project merge requests.
5 #
6 # @example
7 # Gitlab.merge_requests(5)
8 # Gitlab.merge_requests({ per_page: 40 })
9 #
10 # @param [Integer, String] project The ID or name of a project.
11 # @param [Hash] options A customizable set of options.
12 # @option options [Integer] :page The page number.
13 # @option options [Integer] :per_page The number of results per page.
14 # @return [Array<Gitlab::ObjectifiedHash>]
15 def merge_requests(project, options={})
16 get("/projects/#{url_encode project}/merge_requests", query: options)
17 end
18
19 # Gets a single merge request.
20 #
21 # @example
22 # Gitlab.merge_request(5, 36)
23 #
24 # @param [Integer, String] project The ID or name of a project.
25 # @param [Integer] id The ID of a merge request.
26 # @return <Gitlab::ObjectifiedHash]
27 def merge_request(project, id)
28 get("/projects/#{url_encode project}/merge_requests/#{id}")
29 end
30
31 # Creates a merge request.
32 #
33 # @example
34 # Gitlab.create_merge_request(5, 'New merge request',
35 # { source_branch: 'source_branch', target_branch: 'target_branch' })
36 # Gitlab.create_merge_request(5, 'New merge request',
37 # { source_branch: 'source_branch', target_branch: 'target_branch', assignee_id: 42 })
38 #
39 # @param [Integer, String] project The ID or name of a project.
40 # @param [String] title The title of a merge request.
41 # @param [Hash] options A customizable set of options.
42 # @option options [String] :source_branch (required) The source branch name.
43 # @option options [String] :target_branch (required) The target branch name.
44 # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
45 # @option options [Integer] :target_project_id (optional) The target project ID.
46 # @return [Gitlab::ObjectifiedHash] Information about created merge request.
47 def create_merge_request(project, title, options={})
48 body = { title: title }.merge(options)
49 post("/projects/#{url_encode project}/merge_requests", body: body)
50 end
51
52 # Updates a merge request.
53 #
54 # @example
55 # Gitlab.update_merge_request(5, 42, { title: 'New title' })
56 #
57 # @param [Integer, String] project The ID or name of a project.
58 # @param [Integer] id The ID of a merge request.
59 # @param [Hash] options A customizable set of options.
60 # @option options [String] :title The title of a merge request.
61 # @option options [String] :source_branch The source branch name.
62 # @option options [String] :target_branch The target branch name.
63 # @option options [Integer] :assignee_id The ID of a user to assign merge request.
64 # @option options [String] :state_event New state (close|reopen|merge).
65 # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
66 def update_merge_request(project, id, options={})
67 put("/projects/#{url_encode project}/merge_requests/#{id}", body: options)
68 end
69
70 # Accepts a merge request.
71 #
72 # @example
73 # Gitlab.accept_merge_request(5, 42, { merge_commit_message: 'Nice!' })
74 #
75 # @param [Integer, String] project The ID or name of a project.
76 # @param [Integer] id The ID of a merge request.
77 # @param [Hash] options A customizable set of options.
78 # @option options [String] :merge_commit_message Custom merge commit message
79 # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
80 def accept_merge_request(project, id, options={})
81 put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options)
82 end
83
84 # Adds a comment to a merge request.
85 #
86 # @example
87 # Gitlab.create_merge_request_comment(5, 1, "Awesome merge!")
88 # Gitlab.create_merge_request_comment('gitlab', 1, "Awesome merge!")
89 #
90 # @param [Integer, String] project The ID or name of a project.
91 # @param [Integer] id The ID of a merge request.
92 # @param [String] note The content of a comment.
93 # @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
94 def create_merge_request_comment(project, id, note)
95 post("/projects/#{url_encode project}/merge_requests/#{id}/notes", body: { body: note })
96 end
97
98 # Adds a comment to a merge request.
99 #
100 # @example
101 # Gitlab.edit_merge_request_comment(5, 1,2, "Awesome merge!")
102 # Gitlab.edit_merge_request_comment('gitlab', 1, 2, "Awesome merge!")
103 #
104 # @param [Integer, String] project The ID or name of a project.
105 # @param [Integer] id The ID of a merge request.
106 # @param [Integer] id The ID of the merge-request comment
107 # @param [String] note The content of a comment.
108 # @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
109 def edit_merge_request_comment(project, id, note_id , note)
110 put("/projects/#{url_encode project}/merge_requests/#{id}/notes/#{note_id}", body: { body: note })
111 end
112
113 # Deletes a comment from a merge request.
114 #
115 # @example
116 # Gitlab.delete_merge_request_comment(5, 1,2)
117 # Gitlab.delete_merge_request_comment('gitlab', 1, 2)
118 #
119 # @param [Integer, String] project The ID or name of a project.
120 # @param [Integer] id The ID of a merge request.
121 # @param [Integer] id The ID of the merge-request comment
122 # @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
123 def delete_merge_request_comment(project, id, note_id)
124 delete("/projects/#{url_encode project}/merge_requests/#{id}/notes/#{note_id}")
125 end
126
127 # Gets the comments on a merge request.
128 #
129 # @example
130 # Gitlab.merge_request_comments(5, 1)
131 # Gitlab.merge_request_comments(5, 1, { per_page: 10, page: 2 })
132 #
133 # @param [Integer, String] project The ID or name of a project.
134 # @param [Integer] id The ID of a merge request.
135 # @param [Hash] options A customizable set of options.
136 # @option options [Integer] :page The page number.
137 # @option options [Integer] :per_page The number of results per page.
138 # @return [Gitlab::ObjectifiedHash] The merge request's comments.
139 def merge_request_comments(project, id, options={})
140 get("/projects/#{url_encode project}/merge_requests/#{id}/notes", query: options)
141 end
142
143 # Gets the changes of a merge request.
144 #
145 # @example
146 # Gitlab.merge_request_changes(5, 1)
147 #
148 # @param [Integer, String] project The ID or name of a project.
149 # @param [Integer] id The ID of a merge request.
150 # @return [Gitlab::ObjectifiedHash] The merge request's changes.
151 def merge_request_changes(project, id)
152 get("/projects/#{url_encode project}/merge_requests/#{id}/changes")
153 end
154
155 # Gets the commits of a merge request.
156 #
157 # @example
158 # Gitlab.merge_request_commits(5, 1)
159 #
160 # @param [Integer, String] project The ID or name of a project.
161 # @param [Integer] id The ID of a merge request.
162 # @return [Array<Gitlab::ObjectifiedHash>] The merge request's commits.
163 def merge_request_commits(project, id)
164 get("/projects/#{url_encode project}/merge_requests/#{id}/commits")
165 end
166
167 # List issues that will close on merge
168 #
169 # @example
170 # Gitlab.merge_request_closes_issues(5, 1)
171 #
172 # @param [Integer] project The ID of a project
173 # @param [Integer] iid The internal ID of a merge request
174 def merge_request_closes_issues(project_id, merge_request_iid)
175 get("/projects/#{project_id}/merge_requests/#{merge_request_iid}/closes_issues")
176 end
177
178 # Subscribes to a merge request.
179 #
180 # @example
181 # Gitlab.subscribe_to_merge_request(5, 1)
182 # Gitlab.subscribe_to_merge_request('gitlab', 1)
183 #
184 # @param [Integer, String] project The ID or name of a project.
185 # @param [Integer] id The ID of a merge request.
186 # @return [Gitlab::ObjectifiedHash] Information about subscribed merge request.
187 def subscribe_to_merge_request(project, id)
188 post("/projects/#{url_encode project}/merge_requests/#{id}/subscribe")
189 end
190
191 # Unsubscribes from a merge request.
192 #
193 # @example
194 # Gitlab.unsubscribe_from_merge_request(5, 1)
195 # Gitlab.unsubscribe_from_merge_request('gitlab', 1)
196 #
197 # @param [Integer, String] project The ID or name of a project.
198 # @param [Integer] id The ID of a merge request.
199 # @return [Gitlab::ObjectifiedHash] Information about unsubscribed merge request.
200 def unsubscribe_from_merge_request(project, id)
201 post("/projects/#{url_encode project}/merge_requests/#{id}/unsubscribe")
202 end
203 end
204 end
0 class Gitlab::Client
1 # Defines methods related to milestones.
2 # @see https://docs.gitlab.com/ce/api/milestones.html
3 module Milestones
4 # Gets a list of project's milestones.
5 #
6 # @example
7 # Gitlab.milestones(5)
8 #
9 # @param [Integer, String] project The ID or name of a project.
10 # @param [Hash] options A customizable set of options.
11 # @option options [Integer] :page The page number.
12 # @option options [Integer] :per_page The number of results per page.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def milestones(project, options={})
15 get("/projects/#{url_encode project}/milestones", query: options)
16 end
17
18 # Gets a single milestone.
19 #
20 # @example
21 # Gitlab.milestone(5, 36)
22 #
23 # @param [Integer, String] project The ID or name of a project.
24 # @param [Integer] id The ID of a milestone.
25 # @return [Gitlab::ObjectifiedHash]
26 def milestone(project, id)
27 get("/projects/#{url_encode project}/milestones/#{id}")
28 end
29
30 # Gets the issues of a given milestone.
31 #
32 # @example
33 # Gitlab.milestone_issues(5, 2)
34 #
35 # @param [Integer, String] project The ID or name of a project.
36 # @param [Integer, String] milestone The ID of a milestone.
37 # @option options [Integer] :page The page number.
38 # @option options [Integer] :per_page The number of results per page.
39 # @return [Array<Gitlab::ObjectifiedHash>]
40 def milestone_issues(project, milestone, options={})
41 get("/projects/#{url_encode project}/milestones/#{milestone}/issues", query: options)
42 end
43
44 # Gets the merge_requests of a given milestone.
45 #
46 # @example
47 # Gitlab.milestone_merge_requests(5, 2)
48 #
49 # @param [Integer, String] project The ID or name of a project.
50 # @param [Integer, String] milestone The ID of a milestone.
51 # @option options [Integer] :page The page number.
52 # @option options [Integer] :per_page The number of results per page.
53 # @return [Array<Gitlab::ObjectifiedHash>]
54 def milestone_merge_requests(project, milestone, options={})
55 get("/projects/#{url_encode project}/milestones/#{milestone}/merge_requests", query: options)
56 end
57
58 # Creates a new milestone.
59 #
60 # @example
61 # Gitlab.create_milestone(5, 'v1.0')
62 #
63 # @param [Integer, String] project The ID or name of a project.
64 # @param [String] title The title of a milestone.
65 # @param [Hash] options A customizable set of options.
66 # @option options [String] :description The description of a milestone.
67 # @option options [String] :due_date The due date of a milestone.
68 # @return [Gitlab::ObjectifiedHash] Information about created milestone.
69 def create_milestone(project, title, options={})
70 body = { title: title }.merge(options)
71 post("/projects/#{url_encode project}/milestones", body: body)
72 end
73
74 # Updates a milestone.
75 #
76 # @example
77 # Gitlab.edit_milestone(5, 2, { state_event: 'activate' })
78 #
79 # @param [Integer, String] project The ID or name of a project.
80 # @param [Integer] id The ID of a milestone.
81 # @param [Hash] options A customizable set of options.
82 # @option options [String] :title The title of a milestone.
83 # @option options [String] :description The description of a milestone.
84 # @option options [String] :due_date The due date of a milestone.
85 # @option options [String] :state_event The state of a milestone ('close' or 'activate').
86 # @return [Gitlab::ObjectifiedHash] Information about updated milestone.
87 def edit_milestone(project, id, options={})
88 put("/projects/#{url_encode project}/milestones/#{id}", body: options)
89 end
90 end
91 end
0 class Gitlab::Client
1 # Defines methods related to namespaces
2 # @see https://docs.gitlab.com/ce/api/namespaces.html
3 module Namespaces
4 # Gets a list of namespaces.
5 # @see https://docs.gitlab.com/ce/api/namespaces.html#list-namespaces
6 #
7 # @example
8 # Gitlab.namespaces
9 #
10 # @param [Hash] options A customizable set of options.
11 # @options options [Integer] :page The page number.
12 # @options options [Integer] :per_page The number of results per page.
13 # @options opttion [String] :search The string to search for.
14 # @return [Array<Gitlab::ObjectifiedHash>]
15 def namespaces(options={})
16 get("/namespaces", query: options)
17 end
18 end
19 end
0 class Gitlab::Client
1 # Defines methods related to notes.
2 # @see https://docs.gitlab.com/ce/api/notes.html
3 module Notes
4 # Gets a list of projects notes.
5 #
6 # @example
7 # Gitlab.notes(5)
8 #
9 # @param [Integer] project The ID of a project.
10 # @option options [Integer] :page The page number.
11 # @option options [Integer] :per_page The number of results per page.
12 # @return [Array<Gitlab::ObjectifiedHash>]
13 def notes(project, options={})
14 get("/projects/#{url_encode project}/notes", query: options)
15 end
16
17 # Gets a list of notes for a issue.
18 #
19 # @example
20 # Gitlab.issue_notes(5, 10)
21 #
22 # @param [Integer] project The ID of a project.
23 # @param [Integer] issue The ID of an issue.
24 # @option options [Integer] :page The page number.
25 # @option options [Integer] :per_page The number of results per page.
26 # @return [Array<Gitlab::ObjectifiedHash>]
27 def issue_notes(project, issue, options={})
28 get("/projects/#{url_encode project}/issues/#{issue}/notes", query: options)
29 end
30
31 # Gets a list of notes for a snippet.
32 #
33 # @example
34 # Gitlab.snippet_notes(5, 1)
35 #
36 # @param [Integer] project The ID of a project.
37 # @param [Integer] snippet The ID of a snippet.
38 # @option options [Integer] :page The page number.
39 # @option options [Integer] :per_page The number of results per page.
40 # @return [Array<Gitlab::ObjectifiedHash>]
41 def snippet_notes(project, snippet, options={})
42 get("/projects/#{url_encode project}/snippets/#{snippet}/notes", query: options)
43 end
44
45 # Gets a list of notes for a merge request.
46 #
47 # @example
48 # Gitlab.merge_request_notes(5, 1)
49 #
50 # @param [Integer] project The ID of a project.
51 # @param [Integer] merge_request The ID of a merge request.
52 # @option options [Integer] :page The page number.
53 # @option options [Integer] :per_page The number of results per page.
54 # @return [Array<Gitlab::ObjectifiedHash>]
55 def merge_request_notes(project, merge_request, options={})
56 get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options)
57 end
58
59 # Gets a single wall note.
60 #
61 # @example
62 # Gitlab.note(5, 15)
63 #
64 # @param [Integer] project The ID of a project.
65 # @param [Integer] id The ID of a note.
66 # @return [Gitlab::ObjectifiedHash]
67 def note(project, id)
68 get("/projects/#{url_encode project}/notes/#{id}")
69 end
70
71 # Gets a single issue note.
72 #
73 # @example
74 # Gitlab.issue_note(5, 10, 1)
75 #
76 # @param [Integer] project The ID of a project.
77 # @param [Integer] issue The ID of an issue.
78 # @param [Integer] id The ID of a note.
79 # @return [Gitlab::ObjectifiedHash]
80 def issue_note(project, issue, id)
81 get("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
82 end
83
84 # Gets a single snippet note.
85 #
86 # @example
87 # Gitlab.snippet_note(5, 11, 3)
88 #
89 # @param [Integer] project The ID of a project.
90 # @param [Integer] snippet The ID of a snippet.
91 # @param [Integer] id The ID of a note.
92 # @return [Gitlab::ObjectifiedHash]
93 def snippet_note(project, snippet, id)
94 get("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
95 end
96
97 # Gets a single merge_request note.
98 #
99 # @example
100 # Gitlab.merge_request_note(5, 11, 3)
101 #
102 # @param [Integer] project The ID of a project.
103 # @param [Integer] merge_request The ID of a merge_request.
104 # @param [Integer] id The ID of a note.
105 # @return [Gitlab::ObjectifiedHash]
106 def merge_request_note(project, merge_request, id)
107 get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
108 end
109
110 # Creates a new wall note.
111 #
112 # @example
113 # Gitlab.create_note(5, 'This is a wall note!')
114 #
115 # @param [Integer, String] project The ID or name of a project.
116 # @param [String] body The body of a note.
117 # @return [Gitlab::ObjectifiedHash] Information about created note.
118 def create_note(project, body)
119 post("/projects/#{url_encode project}/notes", body: { body: body })
120 end
121
122 # Creates a new issue note.
123 #
124 # @example
125 # Gitlab.create_issue_note(6, 1, 'Adding a note to my issue.')
126 #
127 # @param [Integer, String] project The ID or name of a project.
128 # @param [Integer] issue The ID of an issue.
129 # @param [String] body The body of a note.
130 # @return [Gitlab::ObjectifiedHash] Information about created note.
131 def create_issue_note(project, issue, body)
132 post("/projects/#{url_encode project}/issues/#{issue}/notes", body: { body: body })
133 end
134
135 # Creates a new snippet note.
136 #
137 # @example
138 # Gitlab.create_snippet_note(3, 2, 'Look at this awesome snippet!')
139 #
140 # @param [Integer, String] project The ID or name of a project.
141 # @param [Integer] snippet The ID of a snippet.
142 # @param [String] body The body of a note.
143 # @return [Gitlab::ObjectifiedHash] Information about created note.
144 def create_snippet_note(project, snippet, body)
145 post("/projects/#{url_encode project}/snippets/#{snippet}/notes", body: { body: body })
146 end
147
148 # Creates a new note for a single merge request.
149 #
150 # @example
151 # Gitlab.create_merge_request_note(5, 3, 'This MR is ready for review.')
152 #
153 # @param [Integer] project The ID of a project.
154 # @param [Integer] merge_request The ID of a merge request.
155 # @param [String] body The content of a note.
156 def create_merge_request_note(project, merge_request, body)
157 post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body })
158 end
159 end
160 end
0 class Gitlab::Client
1 # Defines methods related to pipelines.
2 # @see https://docs.gitlab.com/ce/api/pipeline_triggers.html
3 # @see https://docs.gitlab.com/ce/ci/triggers/README.html
4 module PipelineTriggers
5 # Gets a list of the project's pipeline triggers
6 #
7 # @example
8 # Gitlab.triggers(5)
9 #
10 # @param [Integer, String] project The ID or name of a project.
11 # @return [Array<Gitlab::ObjectifiedHash>] The list of triggers.
12 def triggers(project)
13 get("/projects/#{url_encode project}/triggers")
14 end
15
16 # Gets details of project's pipeline trigger.
17 #
18 # @example
19 # Gitlab.trigger(5, 1)
20 #
21 # @param [Integer, String] project The ID or name of a project.
22 # @param [Integer] trigger_id The trigger ID.
23 # @return [Gitlab::ObjectifiedHash] The trigger.
24 def trigger(project, trigger_id)
25 get("/projects/#{url_encode project}/triggers/#{trigger_id}")
26 end
27
28 # Create a pipeline trigger for a project.
29 #
30 # @example
31 # Gitlab.create_trigger(5, description: "my description")
32 #
33 # @param [Integer, String] project The ID or name of a project.
34 # @param [String] description The trigger name
35 # @return [Gitlab::ObjectifiedHash] The created trigger.
36 def create_trigger(project, description)
37 post("/projects/#{url_encode project}/triggers", body: {description: description})
38 end
39
40 # Update a project trigger
41 #
42 # @example
43 # Gitlab.update_trigger(5, 1, description: "my description")
44 #
45 # @param [Integer, String] project The ID or name of a project.
46 # @param [Integer] trigger_id The trigger ID.
47 # @param [Hash] options A customizable set of options.
48 # @option options [String] :description The trigger name.
49 # @return [Gitlab::ObjectifiedHash] The updated trigger.
50 def update_trigger(project, trigger_id, options={})
51 put("/projects/#{url_encode project}/triggers/#{trigger_id}", body: options)
52 end
53
54 # Take ownership of a project trigger
55 #
56 # @example
57 # Gitlab.trigger_take_ownership(5, 1)
58 #
59 # @param [Integer, String] project The ID or name of a project.
60 # @param [Integer] trigger_id The trigger ID.
61 # @return [Gitlab::ObjectifiedHash] The updated trigger.
62 def trigger_take_ownership(project, trigger_id)
63 post("/projects/#{url_encode project}/triggers/#{trigger_id}/take_ownership")
64 end
65
66 # Remove a project's pipeline trigger.
67 #
68 # @example
69 # Gitlab.remove_trigger(5, 1)
70 #
71 # @param [Integer, String] project The ID or name of a project.
72 # @param [Integer] trigger_id The trigger ID.
73 # @return [void] This API call returns an empty response body.
74 def remove_trigger(project, trigger_id)
75 delete("/projects/#{url_encode project}/triggers/#{trigger_id}")
76 end
77 alias_method :delete_trigger, :remove_trigger
78
79 # Run the given project pipeline trigger.
80 #
81 # @example
82 # Gitlab.trigger_build(5, '7b9148c158980bbd9bcea92c17522d', 'master')
83 # Gitlab.trigger_build(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })
84 #
85 # @see https://docs.gitlab.com/ce/ci/triggers/README.html
86 #
87 # @param [Integer, String] project The ID or name of the project.
88 # @param [String] token The token of a trigger.
89 # @param [String] ref Branch or tag name to build.
90 # @param [Hash] variables A set of build variables to use for the build. (optional)
91 # @return [Gitlab::ObjectifiedHash] The trigger.
92 def run_trigger(project, token, ref, variables={})
93 post("/projects/#{url_encode project}/trigger/pipeline", unauthenticated: true, body: {
94 token: token,
95 ref: ref,
96 variables: variables
97 })
98 end
99 end
100 end
0 class Gitlab::Client
1 # Defines methods related to pipelines.
2 # @see https://docs.gitlab.com/ce/api/pipelines.html
3 module Pipelines
4 # Gets a list of project pipelines.
5 #
6 # @example
7 # Gitlab.pipelines(5)
8 # Gitlab.pipelines(5, { per_page: 10, page: 2 })
9 #
10 # @param [Integer, String] project The ID or name of a project.
11 # @param [Hash] options A customizable set of options.
12 # @option options [Integer] :page The page number.
13 # @option options [Integer] :per_page The number of results per page.
14 # @return [Array<Gitlab::ObjectifiedHash>]
15 def pipelines(project, options={})
16 get("/projects/#{url_encode project}/pipelines", query: options)
17 end
18
19 # Gets a single pipeline.
20 #
21 # @example
22 # Gitlab.pipeline(5, 36)
23 #
24 # @param [Integer, String] project The ID or name of a project.
25 # @param [Integer] id The ID of a pipeline.
26 # @return [Gitlab::ObjectifiedHash]
27 def pipeline(project, id)
28 get("/projects/#{url_encode project}/pipelines/#{id}")
29 end
30
31 # Create a pipeline.
32 #
33 # @example
34 # Gitlab.create_pipeline(5, 'master')
35 #
36 # @param [Integer, String] project The ID or name of a project.
37 # @param [String] ref Reference to commit.
38 # @return [Gitlab::ObjectifiedHash] The pipelines changes.
39 def create_pipeline(project, ref)
40 post("/projects/#{url_encode project}/pipeline?ref=#{ref}")
41 end
42
43 # Cancels a pipeline.
44 #
45 # @example
46 # Gitlab.cancel_pipeline(5, 1)
47 #
48 # @param [Integer, String] project The ID or name of a project.
49 # @param [Integer] id The ID of a pipeline.
50 # @return [Gitlab::ObjectifiedHash] The pipelines changes.
51 def cancel_pipeline(project, id)
52 post("/projects/#{url_encode project}/pipelines/#{id}/cancel")
53 end
54
55 # Retry a pipeline.
56 #
57 # @example
58 # Gitlab.retry_pipeline(5, 1)
59 #
60 # @param [Integer, String] project The ID or name of a project.
61 # @param [Integer] id The ID of a pipeline.
62 # @return [Array<Gitlab::ObjectifiedHash>] The pipelines changes.
63 def retry_pipeline(project, id)
64 post("/projects/#{url_encode project}/pipelines/#{id}/retry")
65 end
66 end
67 end
0 class Gitlab::Client
1 # Defines methods related to projects.
2 # @see https://docs.gitlab.com/ce/api/projects.html
3 module Projects
4 # Gets a list of projects owned by the authenticated user.
5 #
6 # @example
7 # Gitlab.projects
8 #
9 # @param [Hash] options A customizable set of options.
10 # @option options [Integer] :page The page number.
11 # @option options [Integer] :per_page The number of results per page.
12 # @option options [String] :scope Scope of projects. 'owned' for list of projects owned by the authenticated user, 'all' to get all projects (admin only)
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def projects(options={})
15 if options[:scope]
16 get("/projects/#{options[:scope]}", query: options)
17 else
18 get("/projects", query: options)
19 end
20 end
21
22 # Search for projects by name.
23 #
24 # @example
25 # Gitlab.project_search('gitlab')
26 # Gitlab.project_search('gitlab', { order_by: 'last_activity_at' })
27 # Gitlab.search_projects('gitlab', { order_by: 'name', sort: 'asc' })
28 #
29 # @param [Hash] options A customizable set of options.
30 # @option options [String] :per_page Number of projects to return per page
31 # @option options [String] :page The page to retrieve
32 # @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
33 # @option options [String] :sort Return requests sorted in asc or desc order
34 # @return [Array<Gitlab::ObjectifiedHash>]
35 def project_search(query, options={})
36 get("/projects/search/#{query}", query: options)
37 end
38 alias_method :search_projects, :project_search
39
40 # Gets information about a project.
41 #
42 # @example
43 # Gitlab.project(3)
44 # Gitlab.project('gitlab')
45 #
46 # @param [Integer, String] id The ID or name of a project.
47 # @return [Gitlab::ObjectifiedHash]
48 def project(id)
49 get("/projects/#{url_encode id}")
50 end
51
52 # Gets a list of project events.
53 #
54 # @example
55 # Gitlab.project_events(42)
56 # Gitlab.project_events('gitlab')
57 #
58 # @param [Integer, String] project The ID or name of a project.
59 # @param [Hash] options A customizable set of options.
60 # @option options [Integer] :page The page number.
61 # @option options [Integer] :per_page The number of results per page.
62 # @return [Array<Gitlab::ObjectifiedHash>]
63 def project_events(project, options={})
64 get("/projects/#{url_encode project}/events", query: options)
65 end
66
67 # Creates a new project.
68 #
69 # @example
70 # Gitlab.create_project('gitlab')
71 # Gitlab.create_project('viking', { description: 'Awesome project' })
72 # Gitlab.create_project('Red', { wall_enabled: false })
73 #
74 # @param [String] name The name of a project.
75 # @param [Hash] options A customizable set of options.
76 # @option options [String] :description The description of a project.
77 # @option options [String] :default_branch The default branch of a project.
78 # @option options [String] :namespace_id The namespace in which to create a project.
79 # @option options [Boolean] :wiki_enabled The wiki integration for a project (0 = false, 1 = true).
80 # @option options [Boolean] :wall_enabled The wall functionality for a project (0 = false, 1 = true).
81 # @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
82 # @option options [Boolean] :snippets_enabled The snippets integration for a project (0 = false, 1 = true).
83 # @option options [Boolean] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
84 # @option options [Boolean] :public The setting for making a project public (0 = false, 1 = true).
85 # @option options [Integer] :user_id The user/owner id of a project.
86 # @return [Gitlab::ObjectifiedHash] Information about created project.
87 def create_project(name, options={})
88 url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : "/projects"
89 post(url, body: { name: name }.merge(options))
90 end
91
92 # Deletes a project.
93 #
94 # @example
95 # Gitlab.delete_project(4)
96 #
97 # @param [Integer, String] id The ID or name of a project.
98 # @return [Gitlab::ObjectifiedHash] Information about deleted project.
99 def delete_project(id)
100 delete("/projects/#{id}")
101 end
102
103 # Gets a list of project team members.
104 #
105 # @example
106 # Gitlab.team_members(42)
107 # Gitlab.team_members('gitlab')
108 #
109 # @param [Integer, String] project The ID or name of a project.
110 # @param [Hash] options A customizable set of options.
111 # @option options [String] :query The search query.
112 # @option options [Integer] :page The page number.
113 # @option options [Integer] :per_page The number of results per page.
114 # @return [Array<Gitlab::ObjectifiedHash>]
115 def team_members(project, options={})
116 get("/projects/#{url_encode project}/members", query: options)
117 end
118
119 # Gets a project team member.
120 #
121 # @example
122 # Gitlab.team_member('gitlab', 2)
123 #
124 # @param [Integer, String] project The ID or name of a project.
125 # @param [Integer] id The ID of a project team member.
126 # @return [Gitlab::ObjectifiedHash]
127 def team_member(project, id)
128 get("/projects/#{url_encode project}/members/#{id}")
129 end
130
131 # Adds a user to project team.
132 #
133 # @example
134 # Gitlab.add_team_member('gitlab', 2, 40)
135 #
136 # @param [Integer, String] project The ID or name of a project.
137 # @param [Integer] id The ID of a user.
138 # @param [Integer] access_level The access level to project.
139 # @param [Hash] options A customizable set of options.
140 # @return [Gitlab::ObjectifiedHash] Information about added team member.
141 def add_team_member(project, id, access_level)
142 post("/projects/#{url_encode project}/members", body: { user_id: id, access_level: access_level })
143 end
144
145 # Updates a team member's project access level.
146 #
147 # @example
148 # Gitlab.edit_team_member('gitlab', 3, 20)
149 #
150 # @param [Integer, String] project The ID or name of a project.
151 # @param [Integer] id The ID of a user.
152 # @param [Integer] access_level The access level to project.
153 # @param [Hash] options A customizable set of options.
154 # @return [Array<Gitlab::ObjectifiedHash>] Information about updated team member.
155 def edit_team_member(project, id, access_level)
156 put("/projects/#{url_encode project}/members/#{id}", body: { access_level: access_level })
157 end
158
159 # Removes a user from project team.
160 #
161 # @example
162 # Gitlab.remove_team_member('gitlab', 2)
163 #
164 # @param [Integer, String] project The ID or name of a project.
165 # @param [Integer] id The ID of a user.
166 # @param [Hash] options A customizable set of options.
167 # @return [Gitlab::ObjectifiedHash] Information about removed team member.
168 def remove_team_member(project, id)
169 delete("/projects/#{url_encode project}/members/#{id}")
170 end
171
172 # Gets a list of project hooks.
173 #
174 # @example
175 # Gitlab.project_hooks(42)
176 # Gitlab.project_hooks('gitlab')
177 #
178 # @param [Integer, String] project The ID or name of a project.
179 # @param [Hash] options A customizable set of options.
180 # @option options [Integer] :page The page number.
181 # @option options [Integer] :per_page The number of results per page.
182 # @return [Array<Gitlab::ObjectifiedHash>]
183 def project_hooks(project, options={})
184 get("/projects/#{url_encode project}/hooks", query: options)
185 end
186
187 # Gets a project hook.
188 #
189 # @example
190 # Gitlab.project_hook(42, 5)
191 # Gitlab.project_hook('gitlab', 5)
192 #
193 # @param [Integer, String] project The ID or name of a project.
194 # @param [Integer] id The ID of a hook.
195 # @return [Gitlab::ObjectifiedHash]
196 def project_hook(project, id)
197 get("/projects/#{url_encode project}/hooks/#{id}")
198 end
199
200 # Adds a new hook to the project.
201 #
202 # @example
203 # Gitlab.add_project_hook(42, 'https://api.example.net/v1/webhooks/ci')
204 #
205 # @param [Integer, String] project The ID or name of a project.
206 # @param [String] url The hook URL.
207 # @param [Hash] options A customizable set of options.
208 # @param option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true)
209 # @param option [Boolean] :issues_events Trigger hook on issues events (0 = false, 1 = true)
210 # @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
211 # @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
212 # @return [Gitlab::ObjectifiedHash] Information about added hook.
213 def add_project_hook(project, url, options={})
214 body = { url: url }.merge(options)
215 post("/projects/#{url_encode project}/hooks", body: body)
216 end
217
218 # Updates a project hook URL.
219 #
220 # @example
221 # Gitlab.edit_project_hook(42, 1, 'https://api.example.net/v1/webhooks/ci')
222 #
223 # @param [Integer, String] project The ID or name of a project.
224 # @param [Integer] id The ID of the hook.
225 # @param [String] url The hook URL.
226 # @param [Hash] options A customizable set of options.
227 # @param option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true)
228 # @param option [Boolean] :issues_events Trigger hook on issues events (0 = false, 1 = true)
229 # @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
230 # @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
231 # @return [Gitlab::ObjectifiedHash] Information about updated hook.
232 def edit_project_hook(project, id, url, options={})
233 body = { url: url }.merge(options)
234 put("/projects/#{url_encode project}/hooks/#{id}", body: body)
235 end
236
237 # Deletes a hook from project.
238 #
239 # @example
240 # Gitlab.delete_project_hook('gitlab', 4)
241 #
242 # @param [Integer, String] project The ID or name of a project.
243 # @param [String] id The ID of the hook.
244 # @return [Gitlab::ObjectifiedHash] Information about deleted hook.
245 def delete_project_hook(project, id)
246 delete("/projects/#{url_encode project}/hooks/#{id}")
247 end
248
249 # Gets a project push rule.
250 # @see https://docs.gitlab.com/ee/api/projects.html#show-project-push-rules
251 #
252 # @example
253 # Gitlab.push_rule(42)
254 #
255 # @param [Integer] id The ID of a project.
256 # @return [Gitlab::ObjectifiedHash]
257 def push_rule(id)
258 get("/projects/#{id}/push_rule")
259 end
260
261 # Adds a project push rule.
262 # @see https://docs.gitlab.com/ee/api/projects.html#add-project-push-rule
263 #
264 # @example
265 # Gitlab.add_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })
266 #
267 # @param [Integer] id The ID of a project.
268 # @param [Hash] options A customizable set of options.
269 # @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
270 # @param option [String] :commit_message_regex Commit message regex
271 # @return [Gitlab::ObjectifiedHash] Information about added push rule.
272 def add_push_rule(id, options={})
273 post("/projects/#{id}/push_rule", body: options)
274 end
275
276 # Updates a project push rule.
277 # @see https://docs.gitlab.com/ee/api/projects.html#edit-project-push-rule
278 #
279 # @example
280 # Gitlab.edit_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })
281 #
282 # @param [Integer] id The ID of a project.
283 # @param [Hash] options A customizable set of options.
284 # @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
285 # @param option [String] :commit_message_regex Commit message regex
286 # @return [Gitlab::ObjectifiedHash] Information about updated push rule.
287 def edit_push_rule(id, options={})
288 put("/projects/#{id}/push_rule", body: options)
289 end
290
291 # Deletes a push rule from a project.
292 # @see https://docs.gitlab.com/ee/api/projects.html#delete-project-push-rule
293 #
294 # @example
295 # Gitlab.delete_push_rule(42)
296 #
297 # @param [Integer] id The ID of a project.
298 # @return [Gitlab::ObjectifiedHash] Information about deleted push rule.
299 def delete_push_rule(id, options={})
300 delete("/projects/#{id}/push_rule")
301 end
302
303 # Mark this project as forked from the other
304 #
305 # @example
306 # Gitlab.make_forked(42, 24)
307 #
308 # @param [Integer, String] project The ID or name of a project.
309 # @param [Integer] id The ID of the project it is forked from.
310 # @return [Gitlab::ObjectifiedHash] Information about the forked project.
311 def make_forked_from(project, id)
312 post("/projects/#{url_encode project}/fork/#{id}")
313 end
314
315 # Remove a forked_from relationship for a project.
316 #
317 # @example
318 # Gitlab.remove_forked(42)
319 #
320 # @param [Integer, String] project The ID or name of a project.
321 # @param [Integer] project The ID of the project it is forked from
322 # @return [Gitlab::ObjectifiedHash] Information about the forked project.
323 def remove_forked(project)
324 delete("/projects/#{url_encode project}/fork")
325 end
326
327 # Gets a project deploy keys.
328 #
329 # @example
330 # Gitlab.deploy_keys(42)
331 #
332 # @param [Integer, String] project The ID or name of a project.
333 # @param [Hash] options A customizable set of options.
334 # @option options [Integer] :page The page number.
335 # @option options [Integer] :per_page The number of results per page.
336 # @return [Array<Gitlab::ObjectifiedHash>]
337 def deploy_keys(project, options={})
338 get("/projects/#{url_encode project}/deploy_keys", query: options)
339 end
340
341 # Gets a single project deploy key.
342 #
343 # @example
344 # Gitlab.deploy_key(42, 1)
345 #
346 # @param [Integer, String] project The ID or name of a project.
347 # @param [Integer] id The ID of a deploy key.
348 # @return [Gitlab::ObjectifiedHash]
349 def deploy_key(project, id)
350 get("/projects/#{url_encode project}/deploy_keys/#{id}")
351 end
352
353 # Creates a new deploy key.
354 #
355 # @example
356 # Gitlab.create_deploy_key(42, 'My Key', 'Key contents')
357 #
358 # @param [Integer, String] project The ID or name of a project.
359 # @param [String] title The title of a deploy key.
360 # @param [String] key The content of a deploy key.
361 # @return [Gitlab::ObjectifiedHash] Information about created deploy key.
362 def create_deploy_key(project, title, key)
363 post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key })
364 end
365
366 # Enables a deploy key at the project.
367 #
368 # @example
369 # Gitlab.enable_deploy_key(42, 66)
370 #
371 # @param [Integer, String] project The ID or name of a project.
372 # @param [Integer] key The ID of a deploy key.
373 # @return [Gitlab::ObjectifiedHash] Information about the enabled deploy key.
374 def enable_deploy_key(project, key)
375 post("/projects/#{url_encode project}/deploy_keys/#{key}/enable", body: { id: project, key_id: key })
376 end
377
378 # Disables a deploy key at the project.
379 #
380 # @example
381 # Gitlab.disable_deploy_key(42, 66)
382 #
383 # @param [Integer, String] project The ID or name of a project.
384 # @param [Integer] key The ID of a deploy key.
385 # @return [Gitlab::ObjectifiedHash] Information about the disabled deploy key.
386 def disable_deploy_key(project, key)
387 post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key })
388 end
389
390 # Deletes a deploy key from project.
391 #
392 # @example
393 # Gitlab.delete_deploy_key(42, 1)
394 #
395 # @param [Integer, String] project The ID or name of a project.
396 # @param [Integer] id The ID of a deploy key.
397 # @return [Gitlab::ObjectifiedHash] Information about deleted deploy key.
398 def delete_deploy_key(project, id)
399 delete("/projects/#{url_encode project}/deploy_keys/#{id}")
400 end
401
402 # Forks a project into the user namespace.
403 #
404 # @example
405 # Gitlab.create_fork(42)
406 # Gitlab.create_fork(42, { sudo: 'another_username' })
407 #
408 # @param [Integer, String] project The ID or name of a project.
409 # @param [Hash] options A customizable set of options.
410 # @option options [String] :sudo The username the project will be forked for
411 # @return [Gitlab::ObjectifiedHash] Information about the forked project.
412 def create_fork(id, options={})
413 post("/projects/#{id}/fork", body: options)
414 end
415
416 # Updates an existing project.
417 #
418 # @example
419 # Gitlab.edit_project(42)
420 # Gitlab.edit_project(42, { name: 'project_name' })
421 #
422 # @param [Integer, String] project The ID or name of a project.
423 # @param [Hash] options A customizable set of options.
424 # @option options [String] :name The name of a project
425 # @option options [String] :path The name of a project
426 # @option options [String] :description The name of a project
427 # @return [Gitlab::ObjectifiedHash] Information about the edited project.
428 def edit_project(id, options={})
429 put("/projects/#{id}", query: options)
430 end
431
432 # Share project with group.
433 #
434 # @example
435 # Gitlab.share_project_with_group('gitlab', 2, 40)
436 #
437 # @param [Integer, String] project The ID or name of a project.
438 # @param [Integer] id The ID of a group.
439 # @param [Integer] group_access The access level to project.
440 def share_project_with_group(project, id, group_access)
441 post("/projects/#{url_encode project}/share", body: { group_id: id, group_access: group_access })
442 end
443
444 # Stars a project.
445 # @see https://docs.gitlab.com/ce/api/projects.html#star-a-project
446 #
447 # @example
448 # Gitlab.star_project(42)
449 # Gitlab.star_project('gitlab-org/gitlab-ce')
450 #
451 # @param [Integer, String] id The ID or name of a project.
452 # @return [Gitlab::ObjectifiedHash] Information about starred project.
453 def star_project(id)
454 post("/projects/#{id}/star")
455 end
456
457 # Unstars a project.
458 # @see https://docs.gitlab.com/ce/api/projects.html#unstar-a-project
459 #
460 # @example
461 # Gitlab.unstar_project(42)
462 # Gitlab.unstar_project('gitlab-org/gitlab-ce')
463 #
464 # @param [Integer, String] id The ID or name of a project.
465 # @return [Gitlab::ObjectifiedHash] Information about unstarred project.
466 def unstar_project(id)
467 delete("/projects/#{id}/star")
468 end
469 end
470 end
0 class Gitlab::Client
1 # Defines methods related to repositories.
2 # @see https://docs.gitlab.com/ce/api/repositories.html
3 module Repositories
4 # Get file tree project (root level).
5 #
6 # @example
7 # Gitlab.tree(42)
8 # Gitlab.tree(42, { path: 'Gemfile' })
9 #
10 # @param [Integer, String] project The ID or name of a project.
11 # @param [Hash] options A customizable set of options.
12 # @option options [String] :path The path inside repository.
13 # @option options [String] :ref_name The name of a repository branch or tag.
14 # @return [Gitlab::ObjectifiedHash]
15 def tree(project, options={})
16 get("/projects/#{url_encode project}/repository/tree", query: options)
17 end
18 alias_method :repo_tree, :tree
19
20 # Get project repository archive
21 #
22 # @example
23 # Gitlab.repo_archive(42)
24 # Gitlab.repo_archive(42, 'deadbeef')
25 #
26 # @param [Integer, String] project The ID or name of a project.
27 # @param [String] ref The commit sha, branch, or tag to download.
28 # @return [Gitlab::FileResponse]
29 def repo_archive(project, ref = 'master')
30 get("/projects/#{url_encode project}/repository/archive",
31 format: nil,
32 headers: { Accept: 'application/octet-stream' },
33 query: { sha: ref },
34 parser: proc { |body, _|
35 if body.encoding == Encoding::ASCII_8BIT # binary response
36 ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
37 else # error with json response
38 ::Gitlab::Request.parse(body)
39 end
40 })
41 end
42
43 # Compares branches, tags or commits.
44 #
45 # @example
46 # Gitlab.compare(42, 'master', 'feature/branch')
47 # Gitlab.repo_compare(42, 'master', 'feature/branch')
48 #
49 # @param [Integer] project The ID of a project.
50 # @param [String] from The commit SHA or branch name of from branch.
51 # @param [String] to The commit SHA or branch name of to branch.
52 # @return [Gitlab::ObjectifiedHash]
53 def compare(project, from, to)
54 get("/projects/#{url_encode project}/repository/compare", query: { from: from, to: to })
55 end
56 alias_method :repo_compare, :compare
57 end
58 end
0 require 'base64'
1
2 class Gitlab::Client
3 # Defines methods related to repository files.
4 # @see https://docs.gitlab.com/ce/api/repository_files.html
5 module RepositoryFiles
6 # Get the contents of a file
7 #
8 # @example
9 # Gitlab.file_contents(42, 'Gemfile')
10 # Gitlab.repo_file_contents(3, 'Gemfile', 'ed899a2f4b50b4370feeea94676502b42383c746')
11 #
12 # @param [Integer, String] project The ID or name of a project.
13 # @param [String] filepath The relative path of the file in the repository
14 # @param [String] ref The name of a repository branch or tag or if not given the default branch.
15 # @return [String]
16 def file_contents(project, filepath, ref='master')
17 ref = URI.encode(ref, /\W/)
18 get "/projects/#{url_encode project}/repository/files/#{url_encode filepath}/raw",
19 query: { ref: ref},
20 format: nil,
21 headers: { Accept: 'text/plain' },
22 parser: ::Gitlab::Request::Parser
23 end
24 alias_method :repo_file_contents, :file_contents
25
26 # Gets a repository file.
27 #
28 # @example
29 # Gitlab.get_file(42, "README.md", "master")
30 #
31 # @param [Integer, String] project The ID or name of a project.
32 # @param [String] file_path The full path of the file.
33 # @param [String] ref The name of branch, tag or commit.
34 # @return [Gitlab::ObjectifiedHash]
35 def get_file(project, file_path, ref)
36 get("/projects/#{url_encode project}/repository/files/#{url_encode file_path}", query: {
37 ref: ref
38 })
39 end
40
41 # Creates a new repository file.
42 #
43 # @example
44 # Gitlab.create_file(42, "path", "branch", "content", "commit message")
45 #
46 # @param [Integer, String] project The ID or name of a project.
47 # @param [String] full path to new file.
48 # @param [String] the name of the branch.
49 # @param [String] file content.
50 # @param [String] commit message.
51 # @return [Gitlab::ObjectifiedHash]
52 def create_file(project, path, branch, content, commit_message)
53 post("/projects/#{url_encode project}/repository/files", body: {
54 file_path: path,
55 branch_name: branch,
56 commit_message: commit_message
57 }.merge(encoded_content_attributes(content)))
58 end
59
60 # Edits an existing repository file.
61 #
62 # @example
63 # Gitlab.edit_file(42, "path", "branch", "content", "commit message")
64 #
65 # @param [Integer, String] project The ID or name of a project.
66 # @param [String] full path to new file.
67 # @param [String] the name of the branch.
68 # @param [String] file content.
69 # @param [String] commit message.
70 # @return [Gitlab::ObjectifiedHash]
71 def edit_file(project, path, branch, content, commit_message)
72 put("/projects/#{url_encode project}/repository/files", body: {
73 file_path: path,
74 branch_name: branch,
75 commit_message: commit_message
76 }.merge(encoded_content_attributes(content)))
77 end
78
79 # Removes an existing repository file.
80 #
81 # @example
82 # Gitlab.remove_file(42, "path", "branch", "commit message")
83 #
84 # @param [Integer, String] project The ID or name of a project.
85 # @param [String] full path to new file.
86 # @param [String] the name of the branch.
87 # @param [String] commit message.
88 # @return [Gitlab::ObjectifiedHash]
89 def remove_file(project, path, branch, commit_message)
90 delete("/projects/#{url_encode project}/repository/files", body: {
91 file_path: path,
92 branch_name: branch,
93 commit_message: commit_message
94 })
95 end
96
97 private
98
99 def encoded_content_attributes(content)
100 {
101 encoding: 'base64',
102 content: Base64.encode64(content)
103 }
104 end
105 end
106 end
0 class Gitlab::Client
1 # Defines methods related to runners.
2 # @see https://docs.gitlab.com/ce/api/runners.html
3 module Runners
4
5 # Get a list of specific runners available to the user.
6 # @see https://docs.gitlab.com/ce/api/runners.html#list-owned-runners
7 #
8 # @example
9 # Gitlab.runners
10 # Gitlab.runners(:active)
11 # Gitlab.runners(:paused)
12 #
13 # @param [Hash] options A customizable set of options.
14 # @option options [String] :scope The scope of specific runners to show, one of: active, paused, online; showing all runners if none provided
15 # @return [Array<Gitlab::ObjectifiedHash>]
16 def runners(options = {})
17 get("/runners", query: options)
18 end
19
20 # Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
21 # @see https://docs.gitlab.com/ce/api/runners.html#list-all-runners
22 #
23 # @example
24 # Gitlab.all_runners
25 #
26 # @param [Hash] options A customizable set of options.
27 # @option options [String] :scope The scope of runners to show, one of: specific, shared, active, paused, online; showing all runners if none provided
28 # @return [Array<Gitlab::ObjectifiedHash>]
29 def all_runners(options = {})
30 get("/runners/all", query: options)
31 end
32
33 # Get details of a runner..
34 # @see https://docs.gitlab.com/ce/api/runners.html#get-runners-details
35 #
36 # @example
37 # Gitlab.runner(42)
38 #
39 # @param [Integer, String] id The ID of a runner
40 # @return <Gitlab::ObjectifiedHash>
41 def runner(id)
42 get("/runners/#{id}")
43 end
44
45 # Update details of a runner.
46 # @see https://docs.gitlab.com/ce/api/runners.html#update-runners-details
47 #
48 # @example
49 # Gitlab.update_runner(42, { description: 'Awesome runner' })
50 # Gitlab.update_runner(42, { active: false })
51 # Gitlab.update_runner(42, { tag_list: [ 'awesome', 'runner' ] })
52 #
53 # @param [Integer, String] id The ID of a runner
54 # @param [Hash] options A customizable set of options.
55 # @option options [String] :active The state of a runner; can be set to true or false.
56 # @option options [String] :tag_list The list of tags for a runner; put array of tags, that should be finally assigned to a runner
57 # @return <Gitlab::ObjectifiedHash>
58 def update_runner(id, options={})
59 put("/runners/#{id}", query: options)
60 end
61
62 # Remove a runner.
63 # @see https://docs.gitlab.com/ce/api/runners.html#remove-a-runner
64 #
65 # @example
66 # Gitlab.delete_runner(42)
67 #
68 # @param [Integer, String] id The ID of a runner
69 # @return <Gitlab::ObjectifiedHash>
70 def delete_runner(id)
71 delete("/runners/#{id}")
72 end
73
74 # List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings.
75 # @see https://docs.gitlab.com/ce/api/runners.html#list-projects-runners
76 #
77 # @example
78 # Gitlab.project_runners(42)
79 #
80 # @param [Integer, String] id The ID or name of a project.
81 # @return [Array<Gitlab::ObjectifiedHash>]
82 def project_runners(project_id)
83 get("/projects/#{url_encode project_id}/runners")
84 end
85
86 # Enable an available specific runner in the project.
87 # @see https://docs.gitlab.com/ce/api/runners.html#enable-a-runner-in-project
88 #
89 # @example
90 # Gitlab.project_enable_runner(2, 42)
91 #
92 # @param [Integer, String] id The ID or name of a project.
93 # @param [Integer, String] id The ID of a runner.
94 # @return <Gitlab::ObjectifiedHash>
95 def project_enable_runner(project_id, id)
96 body = { runner_id: id }
97 post("/projects/#{url_encode project_id}/runners", body: body)
98 end
99
100 # Disable a specific runner from the project. It works only if the project isn't the only project associated with the specified runner.
101 # @see https://docs.gitlab.com/ce/api/runners.html#disable-a-runner-from-project
102 #
103 # @example
104 # Gitlab.project_disable_runner(2, 42)
105 #
106 # @param [Integer, String] id The ID or name of a project.
107 # @param [Integer, String] runner_id The ID of a runner.
108 # @return <Gitlab::ObjectifiedHash>
109 def project_disable_runner(id, runner_id)
110 delete("/projects/#{url_encode id}/runners/#{runner_id}")
111 end
112
113 end
114 end
0 class Gitlab::Client
1 # Third party services connected to a project.
2 # @see https://docs.gitlab.com/ce/api/services.html
3 module Services
4 # Create/Edit service
5 # Full service params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/services.md
6 #
7 # @example
8 # Gitlab.change_service(42, :redmine, { new_issue_url: 'https://example.com/projects/test_project/issues/new',
9 # project_url: 'https://example.com/projects/test_project/issues',
10 # issues_url: 'https://example.com/issues/:id' })
11 #
12 # @param [Integer, String] project The ID or name of a project.
13 # @param [String] service A service code name.
14 # @param [Hash] params A service parameters.
15 # @return [Boolean]
16 def change_service(project, service, params)
17 put("/projects/#{url_encode project}/services/#{correct_service_name(service)}", body: params)
18 end
19
20 # Delete service
21 #
22 # @example
23 # Gitlab.delete_service(42, :redmine)
24 #
25 # @param [Integer, String] project The ID or name of a project.
26 # @param [String] service A service code name.
27 # @return [Boolean]
28 def delete_service(project, service)
29 delete("/projects/#{url_encode project}/services/#{correct_service_name(service)}")
30 end
31
32 # Get service
33 #
34 # @example
35 # Gitlab.service(42, :redmine)
36 #
37 # @param [Integer, String] project The ID or name of a project.
38 # @param [String] service A service code name.
39 # @return [Gitlab::ObjectifiedHash]
40 def service(project, service)
41 get("/projects/#{url_encode project}/services/#{correct_service_name(service)}")
42 end
43
44 private
45 def correct_service_name(service)
46 service.to_s.gsub('_', '-')
47 end
48 end
49 end
0 class Gitlab::Client
1 # Defines methods related to snippets.
2 # @see https://docs.gitlab.com/ce/api/project_snippets.html
3 module Snippets
4 # Gets a list of project's snippets.
5 #
6 # @example
7 # Gitlab.snippets(42)
8 #
9 # @param [Integer, String] project The ID or name of a project.
10 # @param [Hash] options A customizable set of options.
11 # @option options [Integer] :page The page number.
12 # @option options [Integer] :per_page The number of results per page.
13 # @return [Gitlab::ObjectifiedHash]
14 def snippets(project, options={})
15 get("/projects/#{url_encode project}/snippets", query: options)
16 end
17
18 # Gets information about a snippet.
19 #
20 # @example
21 # Gitlab.snippet(2, 14)
22 #
23 # @param [Integer, String] project The ID or name of a project.
24 # @param [Integer] id The ID of a snippet.
25 # @return [Gitlab::ObjectifiedHash]
26 def snippet(project, id)
27 get("/projects/#{url_encode project}/snippets/#{id}")
28 end
29
30 # Creates a new snippet.
31 #
32 # @example
33 # Gitlab.create_snippet(42, { title: 'REST', file_name: 'api.rb', code: 'some code' })
34 #
35 # @param [Integer, String] project The ID or name of a project.
36 # @param [Hash] options A customizable set of options.
37 # @option options [String] :title (required) The title of a snippet.
38 # @option options [String] :file_name (required) The name of a snippet file.
39 # @option options [String] :code (required) The content of a snippet.
40 # @option options [String] :lifetime (optional) The expiration date of a snippet.
41 # @return [Gitlab::ObjectifiedHash] Information about created snippet.
42 def create_snippet(project, options={})
43 post("/projects/#{url_encode project}/snippets", body: options)
44 end
45
46 # Updates a snippet.
47 #
48 # @example
49 # Gitlab.edit_snippet(42, 34, { file_name: 'README.txt' })
50 #
51 # @param [Integer, String] project The ID or name of a project.
52 # @param [Integer] id The ID of a snippet.
53 # @param [Hash] options A customizable set of options.
54 # @option options [String] :title The title of a snippet.
55 # @option options [String] :file_name The name of a snippet file.
56 # @option options [String] :code The content of a snippet.
57 # @option options [String] :lifetime The expiration date of a snippet.
58 # @return [Gitlab::ObjectifiedHash] Information about updated snippet.
59 def edit_snippet(project, id, options={})
60 put("/projects/#{url_encode project}/snippets/#{id}", body: options)
61 end
62
63 # Deletes a snippet.
64 #
65 # @example
66 # Gitlab.delete_snippet(2, 14)
67 #
68 # @param [Integer, String] project The ID or name of a project.
69 # @param [Integer] id The ID of a snippet.
70 # @return [Gitlab::ObjectifiedHash] Information about deleted snippet.
71 def delete_snippet(project, id)
72 delete("/projects/#{url_encode project}/snippets/#{id}")
73 end
74
75 # Returns raw project snippet content as plain text.
76 #
77 # @example
78 # Gitlab.snippet_content(2, 14)
79 #
80 # @param [Integer, String] project The ID or name of a project.
81 # @param [Integer] id The ID of a snippet.
82 # @return [Gitlab::ObjectifiedHash] Information about deleted snippet.
83 def snippet_content(project, id)
84 get("/projects/#{url_encode project}/snippets/#{id}/raw",
85 format: nil,
86 headers: { Accept: 'text/plain' },
87 parser: ::Gitlab::Request::Parser)
88 end
89 end
90 end
0 class Gitlab::Client
1 # Defines methods related to system hooks.
2 # @see https://docs.gitlab.com/ce/api/system_hooks.html
3 module SystemHooks
4 # Gets a list of system hooks.
5 #
6 # @example
7 # Gitlab.hooks
8 # Gitlab.system_hooks
9 #
10 # @param [Hash] options A customizable set of options.
11 # @option options [Integer] :page The page number.
12 # @option options [Integer] :per_page The number of results per page.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def hooks(options={})
15 get("/hooks", query: options)
16 end
17 alias_method :system_hooks, :hooks
18
19 # Adds a new system hook.
20 #
21 # @example
22 # Gitlab.add_hook('http://example.com/hook')
23 # Gitlab.add_system_hook('https://api.example.net/v1/hook')
24 #
25 # @param [String] url The hook URL.
26 # @return [Gitlab::ObjectifiedHash]
27 def add_hook(url)
28 post("/hooks", body: { url: url })
29 end
30 alias_method :add_system_hook, :add_hook
31
32 # Tests a system hook.
33 #
34 # @example
35 # Gitlab.hook(3)
36 # Gitlab.system_hook(12)
37 #
38 # @param [Integer] id The ID of a system hook.
39 # @return [Array<Gitlab::ObjectifiedHash>]
40 def hook(id)
41 get("/hooks/#{id}")
42 end
43 alias_method :system_hook, :hook
44
45 # Deletes a new system hook.
46 #
47 # @example
48 # Gitlab.delete_hook(3)
49 # Gitlab.delete_system_hook(12)
50 #
51 # @param [Integer] id The ID of a system hook.
52 # @return [Gitlab::ObjectifiedHash]
53 def delete_hook(id)
54 delete("/hooks/#{id}")
55 end
56 alias_method :delete_system_hook, :delete_hook
57 end
58 end
0 class Gitlab::Client
1 # Defines methods related to tags.
2 # @see https://docs.gitlab.com/ce/api/tags.html
3 module Tags
4 # Gets a list of project repository tags.
5 #
6 # @example
7 # Gitlab.tags(42)
8 #
9 # @param [Integer, String] project The ID or name of a project.
10 # @param [Hash] options A customizable set of options.
11 # @option options [Integer] :page The page number.
12 # @option options [Integer] :per_page The number of results per page.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def tags(project, options={})
15 get("/projects/#{url_encode project}/repository/tags", query: options)
16 end
17 alias_method :repo_tags, :tags
18
19 # Creates a new project repository tag.
20 #
21 # @example
22 # Gitlab.create_tag(42, 'new_tag', 'master')
23 # Gitlab.create_tag(42, 'v1.0', 'master', 'Release 1.0')
24 #
25 # @param [Integer, String] project The ID or name of a project.
26 # @param [String] tag_name The name of the new tag.
27 # @param [String] ref The ref (commit sha, branch name, or another tag) the tag will point to.
28 # @param [String] message Optional message for tag, creates annotated tag if specified.
29 # @param [String] description Optional release notes for tag.
30 # @return [Gitlab::ObjectifiedHash]
31 def create_tag(project, tag_name, ref, message='', description=nil)
32 post("/projects/#{url_encode project}/repository/tags", body: { tag_name: tag_name, ref: ref, message: message, description: description })
33 end
34 alias_method :repo_create_tag, :create_tag
35
36 # Gets information about a repository tag.
37 #
38 # @example
39 # Gitlab.tag(3, 'api')
40 # Gitlab.repo_tag(5, 'master')
41 #
42 # @param [Integer, String] project The ID or name of a project.
43 # @param [String] tag The name of the tag.
44 # @return [Gitlab::ObjectifiedHash]
45 def tag(project, tag)
46 get("/projects/#{url_encode project}/repository/tags/#{tag}")
47 end
48 alias_method :repo_tag, :tag
49
50 # Deletes a repository tag. Requires Gitlab >= 6.8.x
51 #
52 # @example
53 # Gitlab.delete_tag(3, 'api')
54 # Gitlab.repo_delete_tag(5, 'master')
55 #
56 # @param [Integer, String] project The ID or name of a project.
57 # @param [String] tag The name of the tag to delete
58 # @return [Gitlab::ObjectifiedHash]
59 def delete_tag(project, tag)
60 delete("/projects/#{url_encode project}/repository/tags/#{tag}")
61 end
62 alias_method :repo_delete_tag, :delete_tag
63
64 # Adds release notes to an existing repository tag. Requires Gitlab >= 8.2.0
65 #
66 # @example
67 # Gitlab.create_release(3, '1.0.0', 'This is ready for production')
68 # Gitlab.repo_create_release(5, '1.0.0', 'This is ready for production')
69 #
70 # @param [Integer, String] project The ID or name of a project.
71 # @param [String] tag The name of the new tag.
72 # @param [String] description Release notes with markdown support
73 # @return [Gitlab::ObjectifiedHash]
74 def create_release(project, tag, description)
75 post("/projects/#{url_encode project}/repository/tags/#{tag}/release", body: { description: description })
76 end
77 alias_method :repo_create_release, :create_release
78
79 # Updates the release notes of a given release. Requires Gitlab >= 8.2.0
80 #
81 # @example
82 # Gitlab.update_release(3, '1.0.0', 'This is even more ready for production')
83 # Gitlab.repo_update_release(5, '1.0.0', 'This is even more ready for production')
84 #
85 # @param [Integer, String] project The ID or name of a project.
86 # @param [String] tag The name of the new tag.
87 # @param [String] description Release notes with markdown support
88 # @return [Gitlab::ObjectifiedHash]
89 def update_release(project, tag, description)
90 put("/projects/#{url_encode project}/repository/tags/#{tag}/release", body: { description: description })
91 end
92 alias_method :repo_update_release, :update_release
93
94 end
95 end
0 class Gitlab::Client
1 # Defines methods related to users.
2 # @see https://docs.gitlab.com/ce/api/users.html
3 # @see https://docs.gitlab.com/ce/api/session.html
4 module Users
5 # Gets a list of users.
6 #
7 # @example
8 # Gitlab.users
9 #
10 # @param [Hash] options A customizable set of options.
11 # @option options [Integer] :page The page number.
12 # @option options [Integer] :per_page The number of results per page.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def users(options={})
15 get("/users", query: options)
16 end
17
18 # Gets information about a user.
19 # Will return information about an authorized user if no ID passed.
20 #
21 # @example
22 # Gitlab.user
23 # Gitlab.user(2)
24 #
25 # @param [Integer] id The ID of a user.
26 # @return [Gitlab::ObjectifiedHash]
27 def user(id=nil)
28 id.to_i.zero? ? get("/user") : get("/users/#{id}")
29 end
30
31 # Creates a new user.
32 # Requires authentication from an admin account.
33 #
34 # @example
35 # Gitlab.create_user('joe@foo.org', 'secret', 'joe', { name: 'Joe Smith' })
36 # or
37 # Gitlab.create_user('joe@foo.org', 'secret')
38 #
39 # @param [String] email The email of a user.
40 # @param [String] password The password of a user.
41 # @param [String] username The username of a user.
42 # @param [Hash] options A customizable set of options.
43 # @option options [String] :name The name of a user. Defaults to email.
44 # @option options [String] :skype The skype of a user.
45 # @option options [String] :linkedin The linkedin of a user.
46 # @option options [String] :twitter The twitter of a user.
47 # @option options [Integer] :projects_limit The limit of projects for a user.
48 # @return [Gitlab::ObjectifiedHash] Information about created user.
49 def create_user(*args)
50 options = Hash === args.last ? args.pop : {}
51 if args[2]
52 body = { email: args[0], password: args[1], username: args[2] }
53 else
54 body = { email: args[0], password: args[1], name: args[0] }
55 end
56 body.merge!(options)
57 post('/users', body: body)
58 end
59
60 # Updates a user.
61 #
62 # @example
63 # Gitlab.edit_user(15, { email: 'joe.smith@foo.org', projects_limit: 20 })
64 #
65 # @param [Integer] id The ID of a user.
66 # @param [Hash] options A customizable set of options.
67 # @option options [String] :email The email of a user.
68 # @option options [String] :password The password of a user.
69 # @option options [String] :name The name of a user. Defaults to email.
70 # @option options [String] :skype The skype of a user.
71 # @option options [String] :linkedin The linkedin of a user.
72 # @option options [String] :twitter The twitter of a user.
73 # @option options [Integer] :projects_limit The limit of projects for a user.
74 # @return [Gitlab::ObjectifiedHash] Information about created user.
75 def edit_user(user_id, options={})
76 put("/users/#{user_id}", body: options)
77 end
78
79 # Deletes a user.
80 #
81 # @example
82 # Gitlab.delete_user(1)
83 #
84 # @param [Integer] id The ID of a user.
85 # @return [Gitlab::ObjectifiedHash] Information about deleted user.
86 def delete_user(user_id)
87 delete("/users/#{user_id}")
88 end
89
90 # Blocks the specified user. Available only for admin.
91 #
92 # @example
93 # Gitlab.block_user(15)
94 #
95 # @param [Integer] user_id The Id of user
96 # @return [Boolean] success or not
97 def block_user(user_id)
98 post("/users/#{user_id}/block")
99 end
100
101 # Unblocks the specified user. Available only for admin.
102 #
103 # @example
104 # Gitlab.unblock_user(15)
105 #
106 # @param [Integer] user_id The Id of user
107 # @return [Boolean] success or not
108 def unblock_user(user_id)
109 post("/users/#{user_id}/unblock")
110 end
111
112 # Creates a new user session.
113 #
114 # @example
115 # Gitlab.session('jack@example.com', 'secret12345')
116 #
117 # @param [String] email The email of a user.
118 # @param [String] password The password of a user.
119 # @return [Gitlab::ObjectifiedHash]
120 # @note This method doesn't require private_token to be set.
121 def session(email, password)
122 post("/session", body: { email: email, password: password }, unauthenticated: true)
123 end
124
125 # Gets a list of user's SSH keys.
126 #
127 # @example
128 # Gitlab.ssh_keys
129 # Gitlab.ssh_keys({ user_id: 2 })
130 #
131 # @param [Hash] options A customizable set of options.
132 # @option options [Integer] :page The page number.
133 # @option options [Integer] :per_page The number of results per page.
134 # @option options [Integer] :user_id The ID of the user to retrieve the keys for.
135 # @return [Array<Gitlab::ObjectifiedHash>]
136 def ssh_keys(options={})
137 user_id = options.delete :user_id
138 if user_id.to_i.zero?
139 get("/user/keys", query: options)
140 else
141 get("/users/#{user_id}/keys", query: options)
142 end
143 end
144
145 # Gets information about SSH key.
146 #
147 # @example
148 # Gitlab.ssh_key(1)
149 #
150 # @param [Integer] id The ID of a user's SSH key.
151 # @return [Gitlab::ObjectifiedHash]
152 def ssh_key(id)
153 get("/user/keys/#{id}")
154 end
155
156 # Creates a new SSH key.
157 #
158 # @example
159 # Gitlab.create_ssh_key('key title', 'key body')
160 #
161 # @param [String] title The title of an SSH key.
162 # @param [String] key The SSH key body.
163 # @return [Gitlab::ObjectifiedHash] Information about created SSH key.
164 def create_ssh_key(title, key)
165 post("/user/keys", body: { title: title, key: key })
166 end
167
168 # Deletes an SSH key.
169 #
170 # @example
171 # Gitlab.delete_ssh_key(1)
172 #
173 # @param [Integer] id The ID of a user's SSH key.
174 # @return [Gitlab::ObjectifiedHash] Information about deleted SSH key.
175 def delete_ssh_key(id)
176 delete("/user/keys/#{id}")
177 end
178
179 # Gets user emails.
180 # Will return emails an authorized user if no user ID passed.
181 #
182 # @example
183 # Gitlab.emails
184 # Gitlab.emails(2)
185 #
186 # @param [Integer] user_id The ID of a user.
187 # @return [Gitlab::ObjectifiedHash]
188 def emails(user_id=nil)
189 url = user_id.to_i.zero? ? "/user/emails" : "/users/#{user_id}/emails"
190 get(url)
191 end
192
193 # Get a single email.
194 #
195 # @example
196 # Gitlab.email(3)
197 #
198 # @param [Integer] id The ID of a email.
199 # @return [Gitlab::ObjectifiedHash]
200 def email(id)
201 get("/user/emails/#{id}")
202 end
203
204 # Creates a new email
205 # Will create a new email an authorized user if no user ID passed.
206 #
207 # @example
208 # Gitlab.add_email('email@example.com')
209 # Gitlab.add_email('email@example.com', 2)
210 #
211 # @param [String] email Email address
212 # @param [Integer] user_id The ID of a user.
213 # @return [Gitlab::ObjectifiedHash]
214 def add_email(email, user_id=nil)
215 url = user_id.to_i.zero? ? "/user/emails" : "/users/#{user_id}/emails"
216 post(url, body: {email: email})
217 end
218
219 # Delete email
220 # Will delete a email an authorized user if no user ID passed.
221 #
222 # @example
223 # Gitlab.delete_email(2)
224 # Gitlab.delete_email(3, 2)
225 #
226 # @param [Integer] id Email address ID
227 # @param [Integer] user_id The ID of a user.
228 # @return [Boolean]
229 def delete_email(id, user_id=nil)
230 url = user_id.to_i.zero? ? "/user/emails/#{id}" : "/users/#{user_id}/emails/#{id}"
231 delete(url)
232 end
233
234 # Search for groups by name
235 #
236 # @example
237 # Gitlab.user_search('gitlab')
238 #
239 # @param [String] search A string to search for in user names and paths.
240 # @param [Hash] options A customizable set of options.
241 # @option options [String] :per_page Number of user to return per page
242 # @option options [String] :page The page to retrieve
243 # @return [Array<Gitlab::ObjectifiedHash>]
244 def user_search(search, options={})
245 options[:search] = search
246 get("/users", query: options)
247 end
248 end
249 end
0 module Gitlab
1 # Wrapper for the Gitlab REST API.
2 class Client < API
3 Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
4
5 include Branches
6 include Builds
7 include BuildVariables
8 include Commits
9 include Groups
10 include Issues
11 include Keys
12 include Labels
13 include MergeRequests
14 include Milestones
15 include Namespaces
16 include Notes
17 include Pipelines
18 include PipelineTriggers
19 include Projects
20 include Repositories
21 include RepositoryFiles
22 include Runners
23 include Services
24 include Snippets
25 include SystemHooks
26 include Tags
27 include Users
28 include Jobs
29
30 # Text representation of the client, masking private token.
31 #
32 # @return [String]
33 def inspect
34 inspected = super
35
36 if @private_token
37 inspected = inspected.sub! @private_token, only_show_last_four_chars(@private_token)
38 end
39
40 inspected
41 end
42
43 def url_encode(s)
44 ERB::Util.url_encode(s)
45 end
46
47 private
48
49 def only_show_last_four_chars(token)
50 "#{'*'*(token.size - 4)}#{token[-4..-1]}"
51 end
52 end
53 end
0 require 'gitlab/cli_helpers'
1 module Gitlab
2 # Defines constants and methods related to configuration.
3 module Configuration
4 # An array of valid keys in the options hash when configuring a Gitlab::API.
5 VALID_OPTIONS_KEYS = [:endpoint, :private_token, :user_agent, :sudo, :httparty].freeze
6
7 # The user agent that will be sent to the API endpoint if none is set.
8 DEFAULT_USER_AGENT = "Gitlab Ruby Gem #{Gitlab::VERSION}".freeze
9
10 # @private
11 attr_accessor(*VALID_OPTIONS_KEYS)
12 # @private
13 alias_method :auth_token=, :private_token=
14
15 # Sets all configuration options to their default values
16 # when this module is extended.
17 def self.extended(base)
18 base.reset
19 end
20
21 # Convenience method to allow configuration options to be set in a block.
22 def configure
23 yield self
24 end
25
26 # Creates a hash of options and their values.
27 def options
28 VALID_OPTIONS_KEYS.inject({}) do |option, key|
29 option.merge!(key => send(key))
30 end
31 end
32
33 # Resets all configuration options to the defaults.
34 def reset
35 self.endpoint = ENV['GITLAB_API_ENDPOINT']
36 self.private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] || ENV['GITLAB_API_AUTH_TOKEN']
37 self.httparty = get_httparty_config(ENV['GITLAB_API_HTTPARTY_OPTIONS'])
38 self.sudo = nil
39 self.user_agent = DEFAULT_USER_AGENT
40 end
41
42 private
43
44 # Allows HTTParty config to be specified in ENV using YAML hash.
45 def get_httparty_config(options)
46 return options if options.nil?
47
48 httparty = Gitlab::CLI::Helpers.yaml_load(options)
49
50 raise ArgumentError, "HTTParty config should be a Hash." unless httparty.is_a? Hash
51 Gitlab::CLI::Helpers.symbolize_keys httparty
52 end
53 end
54 end
0 module Gitlab
1 module Error
2 # Custom error class for rescuing from all Gitlab errors.
3 class Error < StandardError; end
4
5 # Raised when API endpoint credentials not configured.
6 class MissingCredentials < Error; end
7
8 # Raised when impossible to parse response body.
9 class Parsing < Error; end
10
11 # Custom error class for rescuing from HTTP response errors.
12 class ResponseError < Error
13 def initialize(response)
14 @response = response
15 super(build_error_message)
16 end
17
18 # Status code returned in the http response.
19 #
20 # @return [Integer]
21 def response_status
22 @response.code
23 end
24
25 private
26
27 # Human friendly message.
28 #
29 # @return [String]
30 def build_error_message
31 parsed_response = @response.parsed_response
32 message = parsed_response.message || parsed_response.error
33
34 "Server responded with code #{@response.code}, message: " \
35 "#{handle_message(message)}. " \
36 "Request URI: #{@response.request.base_uri}#{@response.request.path}"
37 end
38
39 # Handle error response message in case of nested hashes
40 def handle_message(message)
41 case message
42 when Gitlab::ObjectifiedHash
43 message.to_h.sort.map do |key, val|
44 "'#{key}' #{(val.is_a?(Hash) ? val.sort.map { |k, v| "(#{k}: #{v.join(' ')})" } : val).join(' ')}"
45 end.join(', ')
46 when Array
47 message.join(' ')
48 else
49 message
50 end
51 end
52 end
53
54 # Raised when API endpoint returns the HTTP status code 400.
55 class BadRequest < ResponseError; end
56
57 # Raised when API endpoint returns the HTTP status code 401.
58 class Unauthorized < ResponseError; end
59
60 # Raised when API endpoint returns the HTTP status code 403.
61 class Forbidden < ResponseError; end
62
63 # Raised when API endpoint returns the HTTP status code 404.
64 class NotFound < ResponseError; end
65
66 # Raised when API endpoint returns the HTTP status code 405.
67 class MethodNotAllowed < ResponseError; end
68
69 # Raised when API endpoint returns the HTTP status code 409.
70 class Conflict < ResponseError; end
71
72 # Raised when API endpoint returns the HTTP status code 422.
73 class Unprocessable < ResponseError; end
74
75 # Raised when API endpoint returns the HTTP status code 500.
76 class InternalServerError < ResponseError; end
77
78 # Raised when API endpoint returns the HTTP status code 502.
79 class BadGateway < ResponseError; end
80
81 # Raised when API endpoint returns the HTTP status code 503.
82 class ServiceUnavailable < ResponseError; end
83 end
84 end
0 module Gitlab
1 # Wrapper class of file response.
2 class FileResponse
3 HEADER_CONTENT_DISPOSITION = 'Content-Disposition'.freeze
4
5 attr_reader :filename
6
7 def initialize(file)
8 @file = file
9 end
10
11 # @return [bool] Always false
12 def empty?
13 false
14 end
15
16 # @return [Hash] A hash consisting of filename and io object
17 def to_hash
18 { filename: @filename, data: @file }
19 end
20 alias_method :to_h, :to_hash
21
22 # @return [String] Formatted string with the class name, object id and filename.
23 def inspect
24 "#<#{self.class}:#{object_id} {filename: #{filename.inspect}}>"
25 end
26
27 def method_missing(name, *args, &block)
28 if @file.respond_to?(name)
29 @file.send(name, *args, &block)
30 else
31 super
32 end
33 end
34
35 def respond_to_missing?(method_name, include_private = false)
36 super || @file.respond_to?(method_name, include_private)
37 end
38
39 # Parse filename from the 'Content Disposition' header.
40 def parse_headers!(headers)
41 @filename = headers[HEADER_CONTENT_DISPOSITION].split("filename=")[1]
42 @filename = @filename[1...-1] if @filename[0] == '"' # Unquote filenames
43 end
44 end
45 end
0 require 'gitlab'
1 require 'gitlab/cli_helpers'
2
3 module Gitlab::Help
4 extend Gitlab::CLI::Helpers
5
6 class << self
7 # Returns the (modified) help from the 'ri' command or returns an error.
8 #
9 # @return [String]
10 def get_help(cmd)
11 cmd_namespace = namespace cmd
12
13 if cmd_namespace
14 ri_output = `#{ri_cmd} -T #{cmd_namespace} 2>&1`.chomp
15
16 if $CHILD_STATUS == 0
17 change_help_output! cmd, ri_output
18 yield ri_output if block_given?
19
20 ri_output
21 else
22 "Ri docs not found for #{cmd}, please install the docs to use 'help'."
23 end
24 else
25 "Unknown command: #{cmd}."
26 end
27 end
28
29 # Finds the location of 'ri' on a system.
30 #
31 # @return [String]
32 def ri_cmd
33 which_ri = `which ri`.chomp
34 if which_ri.empty?
35 fail "'ri' tool not found in $PATH. Please install it to use the help."
36 end
37
38 which_ri
39 end
40
41 # A hash map that contains help topics (Branches, Groups, etc.)
42 # and a list of commands that are defined under a topic (create_branch,
43 # branches, protect_branch, etc.).
44 #
45 # @return [Hash<Array>]
46 def help_map
47 @help_map ||= begin
48 actions.each_with_object({}) do |action, hsh|
49 key = client.method(action).
50 owner.to_s.gsub(/Gitlab::(?:Client::)?/, '')
51 hsh[key] ||= []
52 hsh[key] << action.to_s
53 end
54 end
55 end
56
57 # Table with available commands.
58 #
59 # @return [Terminal::Table]
60 def actions_table(topic=nil)
61 rows = topic ? help_map[topic] : help_map.keys
62 table do |t|
63 t.title = topic || "Help Topics"
64
65 # add_row expects an array and we have strings hence the map.
66 rows.sort.map { |r| [r] }.each_with_index do |row, index|
67 t.add_row row
68 t.add_separator unless rows.size - 1 == index
69 end
70 end
71 end
72
73 # Returns full namespace of a command (e.g. Gitlab::Client::Branches.cmd)
74 def namespace(cmd)
75 method_owners.select { |method| method[:name] === cmd }.
76 map { |method| method[:owner] + '.' + method[:name] }.
77 shift
78 end
79
80 # Massage output from 'ri'.
81 def change_help_output!(cmd, output_str)
82 output_str.gsub!(/#{cmd}\((.*?)\)/m, cmd + ' \1')
83 output_str.gsub!(/\,[\s]*/, ' ')
84
85 # Ensure @option descriptions are on a single line
86 output_str.gsub!(/\n\[/, " \[")
87 output_str.gsub!(/\s(@)/, "\n@")
88 output_str.gsub!(/(\])\n(\:)/, '\1 \2')
89 output_str.gsub!(/(\:.*)(\n)(.*\.)/, '\1 \3')
90 output_str.gsub!(/\{(.+)\}/, '"{\1}"')
91
92 end
93 end # class << self
94 end
0 module Gitlab
1 # Converts hashes to the objects.
2 class ObjectifiedHash
3 # Creates a new ObjectifiedHash object.
4 def initialize(hash)
5 @hash = hash
6 @data = hash.inject({}) do |data, (key, value)|
7 value = ObjectifiedHash.new(value) if value.is_a? Hash
8 data[key.to_s] = value
9 data
10 end
11 end
12
13 # @return [Hash] The original hash.
14 def to_hash
15 @hash
16 end
17 alias_method :to_h, :to_hash
18
19 # @return [String] Formatted string with the class name, object id and original hash.
20 def inspect
21 "#<#{self.class}:#{object_id} {hash: #{@hash.inspect}}"
22 end
23
24 # Delegate to ObjectifiedHash.
25 def method_missing(key)
26 @data.key?(key.to_s) ? @data[key.to_s] : nil
27 end
28
29 def respond_to_missing?(method_name, include_private = false)
30 @hash.keys.map(&:to_sym).include?(method_name.to_sym) || super
31 end
32 end
33 end
0 module Gitlab
1 # Parses link header.
2 #
3 # @private
4 class PageLinks
5 HEADER_LINK = 'Link'.freeze
6 DELIM_LINKS = ','.freeze
7 LINK_REGEX = /<([^>]+)>; rel=\"([^\"]+)\"/
8 METAS = %w(last next first prev)
9
10 attr_accessor(*METAS)
11
12 def initialize(headers)
13 link_header = headers[HEADER_LINK]
14
15 if link_header && link_header =~ /(next|first|last|prev)/
16 extract_links(link_header)
17 end
18 end
19
20 private
21
22 def extract_links(header)
23 header.split(DELIM_LINKS).each do |link|
24 LINK_REGEX.match(link.strip) do |match|
25 url, meta = match[1], match[2]
26 next if !url || !meta || METAS.index(meta).nil?
27 self.send("#{meta}=", url)
28 end
29 end
30 end
31 end
32 end
0 module Gitlab
1 # Wrapper class of paginated response.
2 class PaginatedResponse
3 attr_accessor :client
4
5 def initialize(array)
6 @array = array
7 end
8
9 def ==(other)
10 @array == other
11 end
12
13 def inspect
14 @array.inspect
15 end
16
17 def method_missing(name, *args, &block)
18 if @array.respond_to?(name)
19 @array.send(name, *args, &block)
20 else
21 super
22 end
23 end
24
25 def respond_to_missing?(method_name, include_private = false)
26 super || @array.respond_to?(method_name, include_private)
27 end
28
29 def parse_headers!(headers)
30 @links = PageLinks.new headers
31 end
32
33 def each_page
34 current = self
35 yield current
36 while current.has_next_page?
37 current = current.next_page
38 yield current
39 end
40 end
41
42 def auto_paginate
43 response = block_given? ? nil : []
44 each_page do |page|
45 if block_given?
46 page.each do |item|
47 yield item
48 end
49 else
50 response += page
51 end
52 end
53 response
54 end
55
56 def has_last_page?
57 !(@links.nil? || @links.last.nil?)
58 end
59
60 def last_page
61 return nil if @client.nil? || !has_last_page?
62 path = @links.last.sub(/#{@client.endpoint}/, '')
63 @client.get(path)
64 end
65
66 def has_first_page?
67 !(@links.nil? || @links.first.nil?)
68 end
69
70 def first_page
71 return nil if @client.nil? || !has_first_page?
72 path = @links.first.sub(/#{@client.endpoint}/, '')
73 @client.get(path)
74 end
75
76 def has_next_page?
77 !(@links.nil? || @links.next.nil?)
78 end
79
80 def next_page
81 return nil if @client.nil? || !has_next_page?
82 path = @links.next.sub(/#{@client.endpoint}/, '')
83 @client.get(path)
84 end
85
86 def has_prev_page?
87 !(@links.nil? || @links.prev.nil?)
88 end
89
90 def prev_page
91 return nil if @client.nil? || !has_prev_page?
92 path = @links.prev.sub(/#{@client.endpoint}/, '')
93 @client.get(path)
94 end
95 end
96 end
0 require 'httparty'
1 require 'json'
2
3 module Gitlab
4 # @private
5 class Request
6 include HTTParty
7 format :json
8 headers 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded'
9 parser proc { |body, _| parse(body) }
10
11 attr_accessor :private_token, :endpoint
12
13 # Converts the response body to an ObjectifiedHash.
14 def self.parse(body)
15 body = decode(body)
16
17 if body.is_a? Hash
18 ObjectifiedHash.new body
19 elsif body.is_a? Array
20 PaginatedResponse.new(body.collect! { |e| ObjectifiedHash.new(e) })
21 elsif body
22 true
23 elsif !body
24 false
25 elsif body.nil?
26 false
27 else
28 raise Error::Parsing.new "Couldn't parse a response body"
29 end
30 end
31
32 # Decodes a JSON response into Ruby object.
33 def self.decode(response)
34 JSON.load response
35 rescue JSON::ParserError
36 raise Error::Parsing.new "The response is not a valid JSON"
37 end
38
39 def get(path, options={})
40 set_httparty_config(options)
41 set_authorization_header(options)
42 validate self.class.get(@endpoint + path, options)
43 end
44
45 def post(path, options={})
46 set_httparty_config(options)
47 set_authorization_header(options)
48 validate self.class.post(@endpoint + path, options)
49 end
50
51 def put(path, options={})
52 set_httparty_config(options)
53 set_authorization_header(options)
54 validate self.class.put(@endpoint + path, options)
55 end
56
57 def delete(path, options={})
58 set_httparty_config(options)
59 set_authorization_header(options)
60 validate self.class.delete(@endpoint + path, options)
61 end
62
63 # Checks the response code for common errors.
64 # Returns parsed response for successful requests.
65 def validate(response)
66 error_klass = case response.code
67 when 400 then Error::BadRequest
68 when 401 then Error::Unauthorized
69 when 403 then Error::Forbidden
70 when 404 then Error::NotFound
71 when 405 then Error::MethodNotAllowed
72 when 409 then Error::Conflict
73 when 422 then Error::Unprocessable
74 when 500 then Error::InternalServerError
75 when 502 then Error::BadGateway
76 when 503 then Error::ServiceUnavailable
77 end
78
79 fail error_klass.new(response) if error_klass
80
81 parsed = response.parsed_response
82 parsed.client = self if parsed.respond_to?(:client=)
83 parsed.parse_headers!(response.headers) if parsed.respond_to?(:parse_headers!)
84 parsed
85 end
86
87 # Sets a base_uri and default_params for requests.
88 # @raise [Error::MissingCredentials] if endpoint not set.
89 def set_request_defaults(sudo=nil)
90 self.class.default_params sudo: sudo
91 raise Error::MissingCredentials.new("Please set an endpoint to API") unless @endpoint
92 self.class.default_params.delete(:sudo) if sudo.nil?
93 end
94
95 private
96
97 # Sets a PRIVATE-TOKEN or Authorization header for requests.
98 #
99 # @param [Hash] options A customizable set of options.
100 # @option options [Boolean] :unauthenticated true if the API call does not require user authentication.
101 # @raise [Error::MissingCredentials] if private_token and auth_token are not set.
102 def set_authorization_header(options)
103 unless options[:unauthenticated]
104 raise Error::MissingCredentials.new("Please provide a private_token or auth_token for user") unless @private_token
105 if @private_token.length <= 20
106 options[:headers] = { 'PRIVATE-TOKEN' => @private_token }
107 else
108 options[:headers] = { 'Authorization' => "Bearer #{@private_token}" }
109 end
110 end
111 end
112
113 # Set HTTParty configuration
114 # @see https://github.com/jnunemaker/httparty
115 def set_httparty_config(options)
116 options.merge!(httparty) if httparty
117 end
118 end
119 end
0 require 'gitlab'
1 require 'gitlab/help'
2 require 'gitlab/cli_helpers'
3 require 'gitlab/shell_history'
4 require 'readline'
5 require 'shellwords'
6
7 class Gitlab::Shell
8 extend Gitlab::CLI::Helpers
9
10 class << self
11 attr_reader :arguments, :command
12
13 def start
14 trap('INT') { quit_shell } # capture ctrl-c
15 setup
16
17 while buffer = Readline.readline('gitlab> ')
18 begin
19 parse_input buffer
20
21 @arguments.map! { |arg| symbolize_keys(yaml_load(arg)) }
22
23 case buffer
24 when nil, ''
25 next
26 when 'exit'
27 quit_shell
28 when /^\bhelp\b+/
29 puts help(arguments[0]) { |out| out.gsub!(/Gitlab\./, 'gitlab> ') }
30 else
31 history << buffer
32
33 data = execute command, arguments
34 output_table command, arguments, data
35 end
36 rescue => e
37 puts e.message
38 end
39 end
40
41 quit_shell # save history if user presses ctrl-d
42 end
43
44 def parse_input(buffer)
45 buf = Shellwords.shellwords(buffer)
46
47 @command = buf.shift
48 @arguments = buf.count > 0 ? buf : []
49 end
50
51 def setup
52 history.load
53
54 Readline.completion_proc = completion
55 Readline.completion_append_character = ' '
56 end
57
58 # Gets called when user hits TAB key to do completion
59 def completion
60 proc { |str| actions.map(&:to_s).grep(/^#{Regexp.escape(str)}/) }
61 end
62
63 # Execute a given command with arguements
64 def execute(cmd=command, args=arguments)
65 if actions.include?(cmd.to_sym)
66 confirm_command(cmd)
67 gitlab_helper(cmd, args)
68 else
69 fail "Unknown command: #{cmd}. " \
70 "See the 'help' for a list of valid commands."
71 end
72 end
73
74 def quit_shell
75 history.save
76 exit
77 end
78
79 def history
80 @history ||= History.new
81 end
82 end # class << self
83 end
0 class Gitlab::Shell
1 class History
2 DEFAULT_HISTFILESIZE = 200
3 DEFAULT_FILE_PATH = File.join(Dir.home, '.gitlab_shell_history')
4
5 def initialize(options={})
6 @file_path = options[:file_path] || DEFAULT_FILE_PATH
7 Readline::HISTORY.clear
8 end
9
10 def load
11 read_from_file { |line| Readline::HISTORY << line.chomp }
12 end
13
14 def save
15 lines.each { |line| history_file.puts line if history_file }
16 end
17
18 def push(line)
19 Readline::HISTORY << line
20 end
21 alias_method :<<, :push
22
23 def lines
24 Readline::HISTORY.to_a.last(max_lines)
25 end
26
27 private
28
29 def history_file
30 if defined?(@history_file)
31 @history_file
32 else
33 @history_file = File.open(history_file_path, 'w', 0600).tap do |file|
34 file.sync = true
35 end
36 end
37 rescue Errno::EACCES
38 warn 'History not saved; unable to open your history file for writing.'
39 @history_file = false
40 end
41
42 def history_file_path
43 File.expand_path(@file_path)
44 end
45
46 def read_from_file
47 path = history_file_path
48
49 File.foreach(path) { |line| yield(line) } if File.exist?(path)
50 rescue => error
51 warn "History file not loaded: #{error.message}"
52 end
53
54 def max_lines
55 (ENV['GITLAB_HISTFILESIZE'] || DEFAULT_HISTFILESIZE).to_i
56 end
57 end
58 end
0 module Gitlab
1 VERSION = "4.1.0"
2 end
0 require 'gitlab/version'
1 require 'gitlab/objectified_hash'
2 require 'gitlab/configuration'
3 require 'gitlab/error'
4 require 'gitlab/page_links'
5 require 'gitlab/paginated_response'
6 require 'gitlab/file_response'
7 require 'gitlab/request'
8 require 'gitlab/api'
9 require 'gitlab/client'
10
11 module Gitlab
12 extend Configuration
13
14 # Alias for Gitlab::Client.new
15 #
16 # @return [Gitlab::Client]
17 def self.client(options={})
18 Gitlab::Client.new(options)
19 end
20
21 # Delegate to Gitlab::Client
22 def self.method_missing(method, *args, &block)
23 return super unless client.respond_to?(method)
24 client.send(method, *args, &block)
25 end
26
27 # Delegate to Gitlab::Client
28 def respond_to_missing?(method_name, include_private = false)
29 client.respond_to?(method_name) || super
30 end
31
32 # Delegate to HTTParty.http_proxy
33 def self.http_proxy(address=nil, port=nil, username=nil, password=nil)
34 Gitlab::Request.http_proxy(address, port, username, password)
35 end
36
37 # Returns an unsorted array of available client methods.
38 #
39 # @return [Array<Symbol>]
40 def self.actions
41 hidden = /endpoint|private_token|auth_token|user_agent|sudo|get|post|put|\Adelete\z|validate|set_request_defaults|httparty/
42 (Gitlab::Client.instance_methods - Object.methods).reject { |e| e[hidden] }
43 end
44 end
0 {"name":"api","commit":{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","parents":[{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616"}],"tree":"f8c4b21c036339f92fcc5482aa28a41250553b27","message":"API: expose issues project id","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-07-25T04:22:21-07:00","committed_date":"2012-07-25T04:22:21-07:00"},"protected": true}
0 {
1 "branch_name": "api"
2 }
0 [{"name":"api","commit":{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","parents":[{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616"}],"tree":"f8c4b21c036339f92fcc5482aa28a41250553b27","message":"API: expose issues project id","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-07-25T04:22:21-07:00","committed_date":"2012-07-25T04:22:21-07:00"}},{"name":"dashboard-feed","commit":{"id":"f8f6ff065eccc6ede4d35ed87a09bb962b84ca25","parents":[{"id":"2cf8010792c3075824ee27d0f037aeb178cbbf7e"}],"tree":"e17f2157143d550891d4669c10b7446e4739bc6d","message":"add projects atom feed","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-05-31T23:42:02-07:00","committed_date":"2012-05-31T23:42:02-07:00"}},{"name":"master","commit":{"id":"2cf8010792c3075824ee27d0f037aeb178cbbf7e","parents":[{"id":"af226ae9c9af406c8a0e0bbdf364563495c2f432"},{"id":"e851cb07762aa464aae10e8b4b28de87c1a6f925"}],"tree":"6c6845838039f01723d91f395a1d2fa1dcc82522","message":"Merge pull request #868 from SaitoWu/bugfix/encoding\n\nBugfix/encoding","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-05-30T00:24:43-07:00","committed_date":"2012-05-30T00:24:43-07:00"}},{"name":"preview_notes","commit":{"id":"3749e0d99ac6bfbc65889b1b7a5310e14e7fe89a","parents":[{"id":"2483181f2c3d4ea7d2c68147b19bc07fc3937b0c"}],"tree":"f8c56161b0d6561568f088df9961362eb1ece88b","message":"pass project_id to notes preview path","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-08-09T23:46:27-07:00","committed_date":"2012-08-09T23:46:27-07:00"}},{"name":"refactoring","commit":{"id":"7c7761099cae83f59fe5780340e100be890847b2","parents":[{"id":"058d80b3363dd4fc4417ca4f60f76119188a2470"}],"tree":"d7d4a94c700dc0e84ee943019213d2358a49c413","message":"fix deprecation warnings","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-05-29T07:16:28-07:00","committed_date":"2012-05-29T07:16:28-07:00"}}]
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "Administrator",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "created_at": "2015-12-24T15:51:21.880Z",
12 "download_url": null,
13 "finished_at": "2015-12-24T17:54:31.198Z",
14 "id": 8,
15 "name": "rubocop",
16 "ref": "master",
17 "runner": null,
18 "stage": "test",
19 "started_at": "2015-12-24T17:54:30.733Z",
20 "status": "failed",
21 "tag": false,
22 "user": {
23 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
24 "bio": null,
25 "created_at": "2015-12-21T13:14:24.077Z",
26 "id": 1,
27 "is_admin": true,
28 "linkedin": "",
29 "name": "John Smith",
30 "skype": "",
31 "state": "active",
32 "twitter": "",
33 "username": "root",
34 "web_url": "http://gitlab.dev/u/root",
35 "website_url": ""
36 }
37 }
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "John Smith",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "created_at": "2016-01-11T10:13:33.506Z",
12 "download_url": null,
13 "finished_at": "2016-01-11T10:14:09.526Z",
14 "id": 69,
15 "name": "rubocop",
16 "ref": "master",
17 "runner": null,
18 "stage": "test",
19 "started_at": null,
20 "status": "canceled",
21 "tag": false,
22 "user": null
23 }
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "John Smith",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "download_url": null,
12 "id": 69,
13 "name": "rubocop",
14 "ref": "master",
15 "runner": null,
16 "stage": "test",
17 "created_at": "2016-01-11T10:13:33.506Z",
18 "started_at": "2016-01-11T10:13:33.506Z",
19 "finished_at": "2016-01-11T10:15:10.506Z",
20 "status": "failed",
21 "tag": false,
22 "user": null
23 }
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "John Smith",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "created_at": "2016-01-11T10:13:33.506Z",
12 "download_url": null,
13 "finished_at": null,
14 "id": 69,
15 "name": "rubocop",
16 "ref": "master",
17 "runner": null,
18 "stage": "test",
19 "started_at": null,
20 "status": "pending",
21 "tag": false,
22 "user": null
23 }
0 [
1 {
2 "commit": {
3 "author_email": "admin@example.com",
4 "author_name": "Administrator",
5 "created_at": "2015-12-24T16:51:14.000+01:00",
6 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
7 "message": "Test the CI integration.",
8 "short_id": "0ff3ae19",
9 "title": "Test the CI integration."
10 },
11 "coverage": null,
12 "created_at": "2015-12-24T15:51:21.802Z",
13 "download_url": null,
14 "finished_at": "2015-12-24T17:54:27.895Z",
15 "id": 7,
16 "name": "teaspoon",
17 "ref": "master",
18 "runner": null,
19 "stage": "test",
20 "started_at": "2015-12-24T17:54:27.722Z",
21 "status": "failed",
22 "tag": false,
23 "user": {
24 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
25 "bio": null,
26 "created_at": "2015-12-21T13:14:24.077Z",
27 "id": 1,
28 "is_admin": true,
29 "linkedin": "",
30 "name": "Administrator",
31 "skype": "",
32 "state": "active",
33 "twitter": "",
34 "username": "root",
35 "web_url": "http://gitlab.dev/u/root",
36 "website_url": ""
37 }
38 },
39 {
40 "commit": {
41 "author_email": "admin@example.com",
42 "author_name": "Administrator",
43 "created_at": "2015-12-24T16:51:14.000+01:00",
44 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
45 "message": "Test the CI integration.",
46 "short_id": "0ff3ae19",
47 "title": "Test the CI integration."
48 },
49 "coverage": null,
50 "created_at": "2015-12-24T15:51:21.727Z",
51 "download_url": null,
52 "finished_at": "2015-12-24T17:54:24.921Z",
53 "id": 6,
54 "name": "spinach:other",
55 "ref": "master",
56 "runner": null,
57 "stage": "test",
58 "started_at": "2015-12-24T17:54:24.729Z",
59 "status": "failed",
60 "tag": false,
61 "user": {
62 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
63 "bio": null,
64 "created_at": "2015-12-21T13:14:24.077Z",
65 "id": 1,
66 "is_admin": true,
67 "linkedin": "",
68 "name": "Administrator",
69 "skype": "",
70 "state": "active",
71 "twitter": "",
72 "username": "root",
73 "web_url": "http://gitlab.dev/u/root",
74 "website_url": ""
75 }
76 }
77 ]
0 [
1 {
2 "commit": {
3 "author_email": "admin@example.com",
4 "author_name": "Administrator",
5 "created_at": "2015-12-24T16:51:14.000+01:00",
6 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
7 "message": "Test the CI integration.",
8 "short_id": "0ff3ae19",
9 "title": "Test the CI integration."
10 },
11 "coverage": null,
12 "created_at": "2016-01-11T10:13:33.506Z",
13 "download_url": null,
14 "finished_at": "2016-01-11T10:14:09.526Z",
15 "id": 69,
16 "name": "rubocop",
17 "ref": "master",
18 "runner": null,
19 "stage": "test",
20 "started_at": null,
21 "status": "canceled",
22 "tag": false,
23 "user": null
24 },
25 {
26 "commit": {
27 "author_email": "admin@example.com",
28 "author_name": "Administrator",
29 "created_at": "2015-12-24T16:51:14.000+01:00",
30 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
31 "message": "Test the CI integration.",
32 "short_id": "0ff3ae19",
33 "title": "Test the CI integration."
34 },
35 "coverage": null,
36 "created_at": "2015-12-24T15:51:21.957Z",
37 "download_url": null,
38 "finished_at": "2015-12-24T17:54:33.913Z",
39 "id": 9,
40 "name": "brakeman",
41 "ref": "master",
42 "runner": null,
43 "stage": "test",
44 "started_at": "2015-12-24T17:54:33.727Z",
45 "status": "failed",
46 "tag": false,
47 "user": {
48 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
49 "bio": null,
50 "created_at": "2015-12-21T13:14:24.077Z",
51 "id": 1,
52 "is_admin": true,
53 "linkedin": "",
54 "name": "Administrator",
55 "skype": "",
56 "state": "active",
57 "twitter": "",
58 "username": "root",
59 "web_url": "http://gitlab.dev/u/root",
60 "website_url": ""
61 }
62 }
63 ]
0
1 {
2 "commit": {
3 "id": "12d65c8dd2b2676fa3ac47d955accc085a37a9c1",
4 "short_id": "12d65c8dd2b",
5 "title": "JS fix",
6 "author_name": "Dmitriy Zaporozhets",
7 "author_email": "dmitriy.zaporozhets@gmail.com",
8 "created_at": "2014-02-27T10:27:00+02:00"
9 },
10 "commits": [{
11 "id": "12d65c8dd2b2676fa3ac47d955accc085a37a9c1",
12 "short_id": "12d65c8dd2b",
13 "title": "JS fix",
14 "author_name": "Dmitriy Zaporozhets",
15 "author_email": "dmitriy.zaporozhets@gmail.com",
16 "created_at": "2014-02-27T10:27:00+02:00"
17 }],
18 "diffs": [{
19 "old_path": "files/js/application.js",
20 "new_path": "files/js/application.js",
21 "a_mode": null,
22 "b_mode": "100644",
23 "diff": "--- a/files/js/application.js\n+++ b/files/js/application.js\n@@ -24,8 +24,10 @@\n //= require g.raphael-min\n //= require g.bar-min\n //= require branch-graph\n-//= require highlightjs.min\n-//= require ace/ace\n //= require_tree .\n //= require d3\n //= require underscore\n+\n+function fix() { \n+ alert(\"Fixed\")\n+}",
24 "new_file": false,
25 "renamed_file": false,
26 "deleted_file": false
27 }],
28 "compare_timeout": false,
29 "compare_same_ref": false
30 }
(New empty file)
0 {"message": "409 Already exists"}
0 {"message": "404 Project Not Found"}
0 {"file_name":"README.md", "file_path":"README.md", "size":"19", "encoding":"base64", "content":"VGhpcyBpcyBhICpSRUFETUUqIQ==\n", "ref":"master", "blob_id":"0eba9dff767611060181e0423a1de2941d27efc8", "commit_id":"eb38397cb6ae669219e6bc18ad19981fff18ea29"}
0 {"id": 10, "name": "GitLab-Group", "path": "gitlab-group", "owner_id": 6, "projects": [
1 {
2 "id": 9,
3 "name": "mojito",
4 "description": null,
5 "default_branch": "master",
6 "owner": {
7 "id": 6,
8 "username": "jose",
9 "email": "jose@abc.com",
10 "name": "Jose Jose",
11 "blocked": false,
12 "created_at": "2013-02-06T06:54:06Z"
13 },
14 "path": "mojito",
15 "path_with_namespace": "gitlab-group/mojito",
16 "issues_enabled": true,
17 "merge_requests_enabled": true,
18 "wall_enabled": true,
19 "wiki_enabled": true,
20 "created_at": "2013-02-06T16:59:15Z",
21 "namespace": {
22 "created_at": "2013-02-06T16:58:22Z",
23 "id": 10,
24 "name": "GitLab-Group",
25 "owner_id": 6,
26 "path": "gitlab-group",
27 "updated_at": "2013-02-06T16:58:22Z"
28 }
29 },
30 {
31 "id": 10,
32 "name": "gitlabhq",
33 "description": null,
34 "default_branch": null,
35 "owner": {
36 "id": 6,
37 "username": "randx",
38 "email": "randx@github.com",
39 "name": "Dmitry Z",
40 "blocked": false,
41 "created_at": "2013-02-06T06:54:06Z"
42 },
43 "path": "gitlabhq",
44 "path_with_namespace": "gitlab-group/gitlabhq",
45 "issues_enabled": true,
46 "merge_requests_enabled": true,
47 "wall_enabled": true,
48 "wiki_enabled": true,
49 "created_at": "2013-02-06T17:02:31Z",
50 "namespace": {
51 "created_at": "2013-02-06T16:58:22Z",
52 "id": 10,
53 "name": "GitLab-Group",
54 "owner_id": 6,
55 "path": "gitlab-group",
56 "updated_at": "2013-02-06T16:58:22Z"
57 }
58 }
59 ]}
0 {"id":3,"name":"Gitlab-Group","path":"gitlab-group","owner_id":1}
0 {"id":3,"name":"Gitlab-Group","path":"gitlab-group","owner_id":1,"description":"gitlab group description"}
0 {"id":42,"name":"Gitlab-Group","path":"gitlab-group","created_at":"2016-02-24T20:16:42.906Z","updated_at":"2016-02-24T20:16:42.906Z"}
0 {"id":2,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-09-04T18:15:30Z","access_level":10}
0 {"created_at":"2013-09-04T18:18:15Z","group_access":10,"group_id":3,"id":2,"notification_level":3,"updated_at":"2013-09-04T18:18:15Z","user_id":2}
0 {"id":2,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-09-04T18:15:30Z","access_level":50}
0 [{"id":1,"username":"eraymond","email":"eraymond@local.host","name":"Edward Raymond","state":"active","created_at":"2013-08-30T16:16:22Z","access_level":50},{"id":1,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-08-30T16:16:22Z","access_level":50}]
0 [
1 {
2 "id": 4,
3 "description": null,
4 "default_branch": "master",
5 "public": false,
6 "visibility_level": 0,
7 "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git",
8 "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",
9 "web_url": "http://example.com/diaspora/diaspora-client",
10 "tag_list": [
11 "example",
12 "disapora client"
13 ],
14 "owner": {
15 "id": 3,
16 "name": "Diaspora",
17 "created_at": "2013-09-30T13: 46: 02Z"
18 },
19 "name": "Diaspora Client",
20 "name_with_namespace": "Diaspora / Diaspora Client",
21 "path": "diaspora-client",
22 "path_with_namespace": "diaspora/diaspora-client",
23 "issues_enabled": true,
24 "merge_requests_enabled": true,
25 "builds_enabled": true,
26 "wiki_enabled": true,
27 "snippets_enabled": false,
28 "created_at": "2013-09-30T13: 46: 02Z",
29 "last_activity_at": "2013-09-30T13: 46: 02Z",
30 "creator_id": 3,
31 "namespace": {
32 "created_at": "2013-09-30T13: 46: 02Z",
33 "description": "",
34 "id": 3,
35 "name": "Diaspora",
36 "owner_id": 1,
37 "path": "diaspora",
38 "updated_at": "2013-09-30T13: 46: 02Z"
39 },
40 "archived": false,
41 "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png"
42 }
43 ]
0 [{"id": 5,"name": "Five-Group","path": "five-group","owner_id": 2},{"id": 8,"name": "Eight Group","path": "eight-group","owner_id": 6}
1 ]
0 [{"id": 3,"name": "ThreeGroup","path": "threegroup","owner_id": 1},{"id": 5,"name": "Five-Group","path": "five-group","owner_id": 2},{"id": 8,"name": "Eight Group","path": "eight-group","owner_id": 6}
1 ]
0 {"id":33,"project_id":3,"title":"Beatae possimus nostrum nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.","description":null,"labels":[],"milestone":null,"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}
0 [{"id":1,"project_id":1,"title":"Culpa eius recusandae suscipit autem distinctio dolorum.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":6,"project_id":2,"title":"Ut in dolorum omnis sed sit aliquam.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":12,"project_id":3,"title":"Veniam et tempore quidem eum reprehenderit cupiditate non aut velit eaque.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":21,"project_id":1,"title":"Vitae ea aliquam et quo eligendi sapiente voluptatum labore hic nihil culpa.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":26,"project_id":2,"title":"Quo enim est nihil atque placeat voluptas neque eos voluptas.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":32,"project_id":3,"title":"Deserunt tenetur impedit est beatae voluptas voluptas quaerat quisquam.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}]
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "Administrator",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "created_at": "2015-12-24T15:51:21.880Z",
12 "artifacts_file": null,
13 "finished_at": "2015-12-24T17:54:31.198Z",
14 "id": 8,
15 "name": "rubocop",
16 "pipeline": {
17 "id": 6,
18 "ref": "master",
19 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
20 "status": "pending"
21 },
22 "ref": "master",
23 "runner": null,
24 "stage": "test",
25 "started_at": "2015-12-24T17:54:30.733Z",
26 "status": "failed",
27 "tag": false,
28 "user": {
29 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
30 "bio": null,
31 "created_at": "2015-12-21T13:14:24.077Z",
32 "id": 1,
33 "linkedin": "",
34 "name": "Administrator",
35 "skype": "",
36 "state": "active",
37 "twitter": "",
38 "username": "root",
39 "web_url": "http://gitlab.dev/root",
40 "website_url": ""
41 }
42 }
0 [
1 {
2 "commit": {
3 "author_email": "admin@example.com",
4 "author_name": "Administrator",
5 "created_at": "2015-12-24T16:51:14.000+01:00",
6 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
7 "message": "Test the CI integration.",
8 "short_id": "0ff3ae19",
9 "title": "Test the CI integration."
10 },
11 "coverage": null,
12 "created_at": "2015-12-24T15:51:21.802Z",
13 "artifacts_file": {
14 "filename": "artifacts.zip",
15 "size": 1000
16 },
17 "finished_at": "2015-12-24T17:54:27.895Z",
18 "id": 7,
19 "name": "teaspoon",
20 "pipeline": {
21 "id": 6,
22 "ref": "master",
23 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
24 "status": "pending"
25 },
26 "ref": "master",
27 "runner": null,
28 "stage": "test",
29 "started_at": "2015-12-24T17:54:27.722Z",
30 "status": "failed",
31 "tag": false,
32 "user": {
33 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
34 "bio": null,
35 "created_at": "2015-12-21T13:14:24.077Z",
36 "id": 1,
37 "linkedin": "",
38 "name": "Administrator",
39 "skype": "",
40 "state": "active",
41 "twitter": "",
42 "username": "root",
43 "web_url": "http://gitlab.dev/root",
44 "website_url": ""
45 }
46 },
47 {
48 "commit": {
49 "author_email": "admin@example.com",
50 "author_name": "Administrator",
51 "created_at": "2015-12-24T16:51:14.000+01:00",
52 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
53 "message": "Test the CI integration.",
54 "short_id": "0ff3ae19",
55 "title": "Test the CI integration."
56 },
57 "coverage": null,
58 "created_at": "2015-12-24T15:51:21.727Z",
59 "artifacts_file": null,
60 "finished_at": "2015-12-24T17:54:24.921Z",
61 "id": 6,
62 "name": "spinach:other",
63 "pipeline": {
64 "id": 6,
65 "ref": "master",
66 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
67 "status": "pending"
68 },
69 "ref": "master",
70 "runner": null,
71 "stage": "test",
72 "started_at": "2015-12-24T17:54:24.729Z",
73 "status": "failed",
74 "tag": false,
75 "user": {
76 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
77 "bio": null,
78 "created_at": "2015-12-21T13:14:24.077Z",
79 "id": 1,
80 "linkedin": "",
81 "name": "Administrator",
82 "skype": "",
83 "state": "active",
84 "twitter": "",
85 "username": "root",
86 "web_url": "http://gitlab.dev/root",
87 "website_url": ""
88 }
89 }
90 ]
0 {"id":1,"title":"narkoz@helium","key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkUsh42Nh1yefGd1jbSELn5XsY8p5Oxmau0/1HqHnjuYOaj5X+kHccFDwtmtg9Ox8ua/+WptNsiE8IUwsD3zKgEjajgwq3gMeeFdxfXwM+tEvHOOMV9meRrgRWGYCToPbT6sR7/YMAYa7cPqWSpx/oZhYfz4XtoMv3ZZT1fZMmx3MY3HwXwW8j+obJyN2K4LN0TFi9RPgWWYn0DCyb9OccmABimt3i74WoJ/OT8r6/7swce8+OSe0Q2wBhyTtvxg2vtUcoek8Af+EZaUMBwSEzEsocOCzwQvjF5XUk5o7dJ8nP8W3RE60JWX57t16eQm7lBmumLYfszpn2isd6W7a1 narkoz@helium"}
0 [{"id":1,"title":"narkoz@helium","key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkUsh42Nh1yefGd1jbSELn5XsY8p5Oxmau0/1HqHnjuYOaj5X+kHccFDwtmtg9Ox8ua/+WptNsiE8IUwsD3zKgEjajgwq3gMeeFdxfXwM+tEvHOOMV9meRrgRWGYCToPbT6sR7/YMAYa7cPqWSpx/oZhYfz4XtoMv3ZZT1fZMmx3MY3HwXwW8j+obJyN2K4LN0TFi9RPgWWYn0DCyb9OccmABimt3i74WoJ/OT8r6/7swce8+OSe0Q2wBhyTtvxg2vtUcoek8Af+EZaUMBwSEzEsocOCzwQvjF5XUk5o7dJ8nP8W3RE60JWX57t16eQm7lBmumLYfszpn2isd6W7a1 narkoz@helium"}]
0 {"name": "Backlog", "color": "#DD10AA"}
0 [{"name": "Backlog", "color": "#DD10AA"},{"name": "Documentation", "color": "#1E80DD"}]
0 {"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}
0 {"id":2,"iid":5,"project_id":3,"title":"Uncovered","description":"","state":"opened","created_at":"2015-03-15T23:15:13.292+01:00","updated_at":"2015-03-15T23:15:14.132+01:00","target_branch":"master","source_branch":"uncovered","upvotes":0,"downvotes":0,"author":{"name":"Dominik Sander","username":"dsander","id":1,"state":"active","avatar_url":"https://secure.gravatar.com/avatar/7f01734389dd6730d076ddee04838bd3?s=40\u0026d=identicon"},"assignee":null,"source_project_id":6,"target_project_id":6,"labels":[],"milestone":null,"changes":[{"old_path":"lib/omniauth/builder.rb","new_path":"lib/omniauth/builder.rb","a_mode":"100644","b_mode":"100644","diff":"--- a/lib/omniauth/builder.rb\n+++ b/lib/omniauth/builder.rb\n@@ -7,11 +7,13 @@ module OmniAuth\n else\n @app = app\n super(\u0026block)\n+ two = 1 # woah! uncovered\n @ins \u003c\u003c @app\n end\n end\n \n def rack14?\n+ one = 2 # thats oke!\n Rack.release.split('.')[1].to_i \u003e= 4\n end\n ","new_file":false,"renamed_file":false,"deleted_file":false}]}
0 [{"id":1,"iid":1,"project_id":5,"title":"Merge request 1 issue 1","description":"","state":"opened","created_at":"2017-04-06T08:03:36.163Z","updated_at":"2017-04-06T08:03:57.087Z","labels":[],"milestone":null,"assignee":null,"author":{"name":"John","username":"jdoe","id":1,"state":"active","avatar_url":"","web_url":"https://gitlab.com/jdoe"},"user_notes_count":0,"upvotes":0,"downvotes":0,"due_date":null,"confidential":false,"weight":null,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/issues/1"},{"id":2,"iid":2,"project_id":5,"title":"Merge request 1 issue 2","description":"","state":"opened","created_at":"2017-04-06T08:03:44.023Z","updated_at":"2017-04-06T08:03:44.023Z","labels":[],"milestone":null,"assignee":null,"author":{"name":"John","username":"jdoe","id":426047,"state":"active","avatar_url":"","web_url":"https://gitlab.com/jdoe"},"user_notes_count":0,"upvotes":0,"downvotes":0,"due_date":null,"confidential":false,"weight":null,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/issues/2"}]
0 {"note":"Cool Merge Request!","author":{"id":1,"username":"jsmith","email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-07-11T01:32:18Z"}}
0 [{"note":"this is the 1st comment on the 2merge merge request","author":{"id":11,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}},{"note":"another discussion point on the 2merge request","author":{"id":12,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}}]
0 [{"id":"a2da7552f26d5b46a6a09bb8b7b066e3a102be7d","short_id":"a2da7552","title": "piyo","author_name":"example","author_email":"example@example.com","created_at":"2015-12-19T18:02:31.000+09:00","message":"fuga"},{"id":"3ce509590f37dbce5b877c3e1c78bd3903493170","short_id":"3ce50959","title":"hoge","author_name":"example","author_email":"example@example.com","created_at":"2015-12-19T17:53:46.000+09:00","message":"Hoge"}]
0 [{"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}]
0 {"id":1,"project_id":3,"title":"3.0","description":"","due_date":"2012-10-22","closed":false,"updated_at":"2012-09-17T10:15:31Z","created_at":"2012-09-17T10:15:31Z"}
0 [{"id":1,"project_id":3,"title":"Culpa eius recusandae suscipit autem distinctio dolorum.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":6,"project_id":3,"title":"Ut in dolorum omnis sed sit aliquam.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":12,"project_id":3,"title":"Veniam et tempore quidem eum reprehenderit cupiditate non aut velit eaque.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":21,"project_id":3,"title":"Vitae ea aliquam et quo eligendi sapiente voluptatum labore hic nihil culpa.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":26,"project_id":3,"title":"Quo enim est nihil atque placeat voluptas neque eos voluptas.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":32,"project_id":3,"title":"Deserunt tenetur impedit est beatae voluptas voluptas quaerat quisquam.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}]
0 [{"id":1,"iid":1,"project_id":1,"title":"lorem ipsum","description":"","state":"opened","created_at":"2017-03-24T12:23:53.918Z","updated_at":"2017-03-24T12:23:53.918Z","target_branch":"master","source_branch":"def","upvotes":0,"downvotes":0,"author":{"name":"John Doe","username":"jdoe","id":1,"state":"active","avatar_url":"","web_url":"https://gitlab.com/jdoen"},"assignee":null,"source_project_id":1,"target_project_id":1,"labels":[],"work_in_progress":false,"milestone":{"id":1,"iid":1,"project_id":1,"title":"Test","description":"","state":"active","created_at":"2017-03-24T12:23:00.560Z","updated_at":"2017-03-24T12:23:00.560Z","due_date":null,"start_date":null},"merge_when_pipeline_succeeds":false,"merge_status":"can_be_merged","sha":"aec123d1775790b2347fdd684b5ba613fdeb994b","merge_commit_sha":null,"user_notes_count":0,"approvals_before_merge":null,"should_remove_source_branch":null,"force_remove_source_branch":false,"squash":false,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/merge_requests/2"},{"id":2,"iid":2,"project_id":1,"title":"ipsum lorem","description":"","state":"opened","created_at":"2017-03-24T12:23:24.662Z","updated_at":"2017-03-24T12:23:33.522Z","target_branch":"master","source_branch":"test1","upvotes":0,"downvotes":0,"author":{"name":"Joren","username":"jdoe","id":1,"state":"active","":"","web_url":"https://gitlab.com/jdoe"},"assignee":null,"source_project_id":1,"target_project_id":1,"labels":[],"work_in_progress":false,"milestone":{"id":1,"iid":1,"project_id":1,"title":"Test","description":"","state":"active","created_at":"2017-03-24T12:23:00.560Z","updated_at":"2017-03-24T12:23:00.560Z","due_date":null,"start_date":null},"merge_when_pipeline_succeeds":false,"merge_status":"can_be_merged","sha":"3ee44c9b40deddae596f838b97523c6f010fd80d","merge_commit_sha":null,"user_notes_count":0,"approvals_before_merge":null,"should_remove_source_branch":null,"force_remove_source_branch":true,"squash":false,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/merge_requests/1"}]
0 [{"id":1,"project_id":3,"title":"3.0","description":"","due_date":"2012-10-22","closed":false,"updated_at":"2012-09-17T10:15:31Z","created_at":"2012-09-17T10:15:31Z"}]
0 [{"id": 1, "path": "john", "kind": "user"}]
0 {"id":1201,"body":"The solution is rather tricky","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"created_at":"2012-11-27T19:16:44Z"}
0 [{"id":1201,"body":"The solution is rather tricky","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"created_at":"2012-11-27T19:16:44Z"},{"id":1207,"body":"I know, right?","author":{"id":1,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"created_at":"2012-11-27T19:58:21Z"}]
0 {
1 "id": 46,
2 "status": "success",
3 "ref": "master",
4 "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
5 "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
6 "tag": false,
7 "yaml_errors": null,
8 "user": {
9 "name": "Administrator",
10 "username": "root",
11 "id": 1,
12 "state": "active",
13 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
14 "web_url": "http://localhost:3000/root"
15 },
16 "created_at": "2016-08-11T11:28:34.085Z",
17 "updated_at": "2016-08-11T11:32:35.169Z",
18 "started_at": null,
19 "finished_at": "2016-08-11T11:32:35.145Z",
20 "committed_at": null,
21 "duration": null
22 }
0 {
1 "id": 46,
2 "status": "canceled",
3 "ref": "master",
4 "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
5 "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
6 "tag": false,
7 "yaml_errors": null,
8 "user": {
9 "name": "Administrator",
10 "username": "root",
11 "id": 1,
12 "state": "active",
13 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
14 "web_url": "http://localhost:3000/root"
15 },
16 "created_at": "2016-08-11T11:28:34.085Z",
17 "updated_at": "2016-08-11T11:32:35.169Z",
18 "started_at": null,
19 "finished_at": "2016-08-11T11:32:35.145Z",
20 "committed_at": null,
21 "duration": null
22 }
0 {
1 "id": 61,
2 "sha": "384c444e840a515b23f21915ee5766b87068a70d",
3 "ref": "master",
4 "status": "pending",
5 "before_sha": "0000000000000000000000000000000000000000",
6 "tag": false,
7 "yaml_errors": null,
8 "user": {
9 "name": "Administrator",
10 "username": "root",
11 "id": 1,
12 "state": "active",
13 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
14 "web_url": "http://localhost:3000/root"
15 },
16 "created_at": "2016-11-04T09:36:13.747Z",
17 "updated_at": "2016-11-04T09:36:13.977Z",
18 "started_at": null,
19 "finished_at": null,
20 "committed_at": null,
21 "duration": null
22 }
0 [
1 {
2 "commit": {
3 "author_email": "admin@example.com",
4 "author_name": "Administrator",
5 "created_at": "2015-12-24T16:51:14.000+01:00",
6 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
7 "message": "Test the CI integration.",
8 "short_id": "0ff3ae19",
9 "title": "Test the CI integration."
10 },
11 "coverage": null,
12 "created_at": "2015-12-24T15:51:21.802Z",
13 "artifacts_file": {
14 "filename": "artifacts.zip",
15 "size": 1000
16 },
17 "finished_at": "2015-12-24T17:54:27.895Z",
18 "id": 7,
19 "name": "teaspoon",
20 "pipeline": {
21 "id": 6,
22 "ref": "master",
23 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
24 "status": "pending"
25 },
26 "ref": "master",
27 "runner": null,
28 "stage": "test",
29 "started_at": "2015-12-24T17:54:27.722Z",
30 "status": "failed",
31 "tag": false,
32 "user": {
33 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
34 "bio": null,
35 "created_at": "2015-12-21T13:14:24.077Z",
36 "id": 1,
37 "linkedin": "",
38 "name": "Administrator",
39 "skype": "",
40 "state": "active",
41 "twitter": "",
42 "username": "root",
43 "web_url": "http://gitlab.dev/root",
44 "website_url": ""
45 }
46 },
47 {
48 "commit": {
49 "author_email": "admin@example.com",
50 "author_name": "Administrator",
51 "created_at": "2015-12-24T16:51:14.000+01:00",
52 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
53 "message": "Test the CI integration.",
54 "short_id": "0ff3ae19",
55 "title": "Test the CI integration."
56 },
57 "coverage": null,
58 "created_at": "2015-12-24T15:51:21.727Z",
59 "artifacts_file": null,
60 "finished_at": "2015-12-24T17:54:24.921Z",
61 "id": 6,
62 "name": "spinach:other",
63 "pipeline": {
64 "id": 6,
65 "ref": "master",
66 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
67 "status": "pending"
68 },
69 "ref": "master",
70 "runner": null,
71 "stage": "test",
72 "started_at": "2015-12-24T17:54:24.729Z",
73 "status": "failed",
74 "tag": false,
75 "user": {
76 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
77 "bio": null,
78 "created_at": "2015-12-21T13:14:24.077Z",
79 "id": 1,
80 "linkedin": "",
81 "name": "Administrator",
82 "skype": "",
83 "state": "active",
84 "twitter": "",
85 "username": "root",
86 "web_url": "http://gitlab.dev/root",
87 "website_url": ""
88 }
89 }
90 ]
0 {
1 "id": 46,
2 "status": "pending",
3 "ref": "master",
4 "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
5 "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
6 "tag": false,
7 "yaml_errors": null,
8 "user": {
9 "name": "Administrator",
10 "username": "root",
11 "id": 1,
12 "state": "active",
13 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
14 "web_url": "http://localhost:3000/root"
15 },
16 "created_at": "2016-08-11T11:28:34.085Z",
17 "updated_at": "2016-08-11T11:32:35.169Z",
18 "started_at": null,
19 "finished_at": "2016-08-11T11:32:35.145Z",
20 "committed_at": null,
21 "duration": null
22 }
0 [
1 {
2 "id": 47,
3 "status": "pending",
4 "ref": "new-pipeline",
5 "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
6 "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
7 "tag": false,
8 "yaml_errors": null,
9 "user": {
10 "name": "Administrator",
11 "username": "root",
12 "id": 1,
13 "state": "active",
14 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
15 "web_url": "http://localhost:3000/root"
16 },
17 "created_at": "2016-08-16T10:23:19.007Z",
18 "updated_at": "2016-08-16T10:23:19.216Z",
19 "started_at": null,
20 "finished_at": null,
21 "committed_at": null,
22 "duration": null
23 },
24 {
25 "id": 48,
26 "status": "pending",
27 "ref": "new-pipeline",
28 "sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
29 "before_sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
30 "tag": false,
31 "yaml_errors": null,
32 "user": {
33 "name": "Administrator",
34 "username": "root",
35 "id": 1,
36 "state": "active",
37 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
38 "web_url": "http://localhost:3000/root"
39 },
40 "created_at": "2016-08-16T10:23:21.184Z",
41 "updated_at": "2016-08-16T10:23:21.314Z",
42 "started_at": null,
43 "finished_at": null,
44 "committed_at": null,
45 "duration": null
46 }
47 ]
0 {"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"},"public":false,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:58Z"}
0 {
1 "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
2 "short_id": "6104942438c",
3 "title": "Sanitize for network graph",
4 "author_name": "randx",
5 "author_email": "dmitriy.zaporozhets@gmail.com",
6 "created_at": "2012-09-20T09:06:12+03:00",
7 "committed_date": "2012-09-20T09:06:12+03:00",
8 "authored_date": "2012-09-20T09:06:12+03:00",
9 "parent_ids": [
10 "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
11 ]
12 }
0 {"note":"Nice code!","author":{"id":1,"username":"jsmith","email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-07-11T01:32:18Z"}}
0 [{"note":"this is the 1st comment on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6","author":{"id":11,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}},{"note":"another discussion point on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6","author":{"id":12,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}}]
0 {
1 "id": "ed899a2f4b50b4370feeea94676502b42383c746",
2 "short_id": "ed899a2f4b5",
3 "title": "some commit message",
4 "author_name": "Dmitriy Zaporozhets",
5 "author_email": "dzaporozhets@sphereconsultinginc.com",
6 "committer_name": "Dmitriy Zaporozhets",
7 "committer_email": "dzaporozhets@sphereconsultinginc.com",
8 "created_at": "2016-09-20T09:26:24.000-07:00",
9 "message": "some commit message",
10 "parent_ids": [
11 "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
12 ],
13 "committed_date": "2016-09-20T09:26:24.000-07:00",
14 "authored_date": "2016-09-20T09:26:24.000-07:00",
15 "stats": {
16 "additions": 2,
17 "deletions": 2,
18 "total": 4
19 },
20 "status": null
21 }
0 {
1 "diff": "--- a/doc/update/5.4-to-6.0.md\n+++ b/doc/update/5.4-to-6.0.md\n@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files",
2 "new_path": "doc/update/5.4-to-6.0.md",
3 "old_path": "doc/update/5.4-to-6.0.md",
4 "a_mode": null,
5 "b_mode": "100644",
6 "new_file": false,
7 "renamed_file": false,
8 "deleted_file": false
9 }
0 [
1 {
2 "id": 496,
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:35:48.693+02:00",
10 "started_at": null,
11 "finished_at": "2015-10-23T23:35:48.716+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/xxxxx?s=40&d=identicon",
18 "web_url": "https://github.com/u/dsander"
19 }
20 },
21 {
22 "id": 493,
23 "sha": "7d938cb8ac15788d71f4b67c035515a160ea76d8",
24 "ref": "decreased-spec",
25 "status": "success",
26 "name": "specs",
27 "target_url": "https://github.com/dsander/omniauth/builds/493",
28 "description": null,
29 "created_at": "2015-10-23T21:39:19.384+02:00",
30 "started_at": "2015-10-23T21:39:21.900+02:00",
31 "finished_at": "2015-10-23T21:39:35.215+02:00",
32 "author": {
33 "name": "Dominik Sander",
34 "username": "dsander",
35 "id": 1,
36 "state": "active",
37 "avatar_url": "https://secure.gravatar.com/avatar/xxxxx?s=40&d=identicon",
38 "web_url": "https://github.com/u/dsander"
39 }
40 }
41 ]
0 [{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","short_id":"f7dd067490f","title":"API: expose issues project id","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-25T04:22:21-07:00"},{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616","short_id":"949b1df930b","title":"API: update docs","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-25T02:35:41-07:00"},{"id":"1b95c8bff351f6718ec31ac1de1e48c57bc95d44","short_id":"1b95c8bff35","title":"API: ability to get project by id","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-25T02:18:30-07:00"},{"id":"92d98f5a0c28bffd7b070cda190b07ab72667d58","short_id":"92d98f5a0c2","title":"Merge pull request #1118 from patthoyts/pt/ldap-missing-password","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-25T01:51:06-07:00"},{"id":"60d3e94874964a626f105d3598e1c122addcf43e","short_id":"60d3e948749","title":"Merge pull request #1122 from patthoyts/pt/missing-log","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-25T01:50:34-07:00"},{"id":"b683a71aa1230f17f9df47661c77dfeae27027de","short_id":"b683a71aa12","title":"Merge pull request #1135 from NARKOZ/api","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-25T01:48:00-07:00"},{"id":"fbb41100db35cf2def2c8b4d896b7015d56bd15b","short_id":"fbb41100db3","title":"update help section with issues API docs","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-24T05:52:43-07:00"},{"id":"eca823c1c7cef45cc18c6ab36d2327650c85bfc3","short_id":"eca823c1c7c","title":"Merge branch 'master' into api","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-24T05:46:36-07:00"},{"id":"024e0348904179a8dea81c01e27a5f014cf57499","short_id":"024e0348904","title":"update API docs","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-24T05:25:01-07:00"},{"id":"7b33d8cbcab3b0ee5789ec607455ab62130db69f","short_id":"7b33d8cbcab","title":"add issues API","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-24T05:19:51-07:00"},{"id":"6035ad7e1fe519d0c6a42731790183889e3ba31d","short_id":"6035ad7e1fe","title":"Create the githost.log file if necessary.","author_name":"Pat Thoyts","author_email":"patthoyts@users.sourceforge.net","created_at":"2012-07-21T07:32:04-07:00"},{"id":"a2d244ec062f3348f6cd1c5218c6097402c5f562","short_id":"a2d244ec062","title":"Handle LDAP missing credentials error with a flash message.","author_name":"Pat Thoyts","author_email":"patthoyts@users.sourceforge.net","created_at":"2012-07-21T01:04:05-07:00"},{"id":"8b7e404b5b6944e9c92cc270b2e5d0005781d49d","short_id":"8b7e404b5b6","title":"Up to 2.7.0","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:53:55-07:00"},{"id":"11721b0dbe82c35789be3e4fa8e14663934b2ff5","short_id":"11721b0dbe8","title":"Help section for system hooks completed","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:47:57-07:00"},{"id":"9c8a1e651716212cf50a623d98e03b8dbdb2c64a","short_id":"9c8a1e65171","title":"Fix system hook example","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:32:42-07:00"},{"id":"4261acda90ff4c61326d80cba026ae76e8551f8f","short_id":"4261acda90f","title":"move SSH keys tab closer to begining","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:27:09-07:00"},{"id":"a69fc5dd23bd502fd36892a80eec21a4c53891f8","short_id":"a69fc5dd23b","title":"Endless event loading for dsahboard","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:23:05-07:00"},{"id":"860fa1163a5fbdfec2bb01ff2d584351554dee29","short_id":"860fa1163a5","title":"Merge pull request #1117 from patthoyts/pt/user-form","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-20T14:23:49-07:00"},{"id":"787e5e94acf5e20280416c9fda105ef5b77576b3","short_id":"787e5e94acf","title":"Fix english on the edit user form.","author_name":"Pat Thoyts","author_email":"patthoyts@users.sourceforge.net","created_at":"2012-07-20T14:18:42-07:00"},{"id":"9267cb04b0b3fdf127899c4b7e636dc27fac06d3","short_id":"9267cb04b0b","title":"Merge branch 'refactoring_controllers' of dev.gitlabhq.com:gitlabhq","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-20T07:24:56-07:00"}]
0 {
1 "id":3,
2 "code":"gitlab",
3 "name":"Gitlab-edit",
4 "description":null,
5 "path":"gitlab",
6 "default_branch":null,
7 "owner":{
8 "id":1,
9 "email":"john@example.com",
10 "name":"John Smith",
11 "blocked":false,
12 "created_at":"2012-09-17T09:41:56Z"
13 },
14 "public":false,
15 "issues_enabled":true,
16 "merge_requests_enabled":true,
17 "wall_enabled":true,
18 "wiki_enabled":true,
19 "created_at":"2012-09-17T09:41:58Z"
20 }
0 [{"title":null,"project_id":2,"action_name":"opened","target_id":null,"target_type":null,"author_id":1,"data":{"before":"ac0c1aa3898d6dea54d7868ea6f9c45fd5e30c59","after":"66350dbb62a221bc619b665aef3e1e7d3b306747","ref":"refs/heads/master","user_id":1,"user_name":"Administrator","project_id":2,"repository":{"name":"gitlab-ci","url":"git@demo.gitlab.com:gitlab/gitlab-ci.git","description":"Continuous integration server for gitlabhq | Coordinator","homepage":"http://demo.gitlab.com/gitlab/gitlab-ci"},"commits":[{"id":"8cf469b039931bab37bbf025e6b69287ea3cfb0e","message":"Modify screenshot\n\nSigned-off-by: Dmitriy Zaporozhets \u003Cdummy@gmail.com\u003E","timestamp":"2014-05-20T10:34:27+00:00","url":"http://demo.gitlab.com/gitlab/gitlab-ci/commit/8cf469b039931bab37bbf025e6b69287ea3cfb0e","author":{"name":"Dummy","email":"dummy@gmail.com"}},{"id":"66350dbb62a221bc619b665aef3e1e7d3b306747","message":"Edit some code\n\nSigned-off-by: Dmitriy Zaporozhets \u003Cdummy@gmail.com\u003E","timestamp":"2014-05-20T10:35:15+00:00","url":"http://demo.gitlab.com/gitlab/gitlab-ci/commit/66350dbb62a221bc619b665aef3e1e7d3b306747","author":{"name":"Dummy","email":"dummy@gmail.com"}}],"total_commits_count":2},"target_title":null,"created_at":"2014-05-20T10:35:26.240Z"},{"title":null,"project_id":2,"action_name":"opened","target_id":2,"target_type":"MergeRequest","author_id":1,"data":null,"target_title":" Morbi et cursus leo. Sed eget vestibulum sapien","created_at":"2014-05-20T10:24:11.917Z"}]
0 {"id":1,"code":"brute","name":"Brute","description":null,"path":"brute","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Owner","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:56Z"}
0 {
1 "id":20,
2 "description":"desc",
3 "default_branch":"master",
4 "tag_list":[
5
6 ],
7 "public":false,
8 "archived":false,
9 "visibility_level":10,
10 "ssh_url_to_repo":"git@git.gitlab.com:root/gitlab.git",
11 "http_url_to_repo":"http://git.gitlab.com/root/gitlab.git",
12 "web_url":"http://git.gitlab.com/root/gitlab",
13 "owner":{
14 "name":"Administrator",
15 "username":"root",
16 "id":1,
17 "state":"active",
18 "avatar_url":"http://git.gitlab.com/uploads/user/avatar/1/12586377.jpeg"
19 },
20 "name":"gitlab",
21 "name_with_namespace":"Administrator / gitlab",
22 "path":"gitlab",
23 "path_with_namespace":"root/gitlab",
24 "issues_enabled":true,
25 "merge_requests_enabled":true,
26 "wiki_enabled":true,
27 "snippets_enabled":false,
28 "created_at":"2015-06-08T01:29:17.190Z",
29 "last_activity_at":"2015-06-08T01:29:17.190Z",
30 "creator_id":1,
31 "namespace":{
32 "id":1,
33 "name":"root",
34 "path":"root",
35 "owner_id":1,
36 "created_at":"2015-05-28T19:23:40.445Z",
37 "updated_at":"2015-05-28T19:23:40.445Z",
38 "description":"",
39 "avatar":null
40 },
41 "forked_from_project":{
42 "id":3,
43 "name":"Gitlab",
44 "name_with_namespace":"Root / gitlab",
45 "path":"gitlab",
46 "path_with_namespace":"root/gitlab"
47 },
48 "avatar_url":null
49 }
0 {"created_at":"2013-07-03T13:51:48Z","forked_from_project_id":24,"forked_to_project_id":42,"id":1,"updated_at":"2013-07-03T13:51:48Z"}
0 {
1 "id":20,
2 "description":"desc",
3 "default_branch":"master",
4 "tag_list":[
5
6 ],
7 "public":false,
8 "archived":false,
9 "visibility_level":10,
10 "ssh_url_to_repo":"git@git.gitlab.com:root/gitlab.git",
11 "http_url_to_repo":"http://git.gitlab.com/root/gitlab.git",
12 "web_url":"http://git.gitlab.com/root/gitlab",
13 "owner":{
14 "name":"Jack Smith",
15 "username":"jack.smith",
16 "id":2,
17 "state":"active",
18 "avatar_url":"http://git.gitlab.com/uploads/user/avatar/1/12586377.jpeg"
19 },
20 "name":"gitlab",
21 "name_with_namespace":"Jack Smith / gitlab",
22 "path":"gitlab",
23 "path_with_namespace":"jack.smith/gitlab",
24 "issues_enabled":true,
25 "merge_requests_enabled":true,
26 "wiki_enabled":true,
27 "snippets_enabled":false,
28 "created_at":"2015-06-08T01:29:17.190Z",
29 "last_activity_at":"2015-06-08T01:29:17.190Z",
30 "creator_id":1,
31 "namespace":{
32 "id":1,
33 "name":"jack.smith",
34 "path":"jack.smith",
35 "owner_id":2,
36 "created_at":"2015-05-28T19:23:40.445Z",
37 "updated_at":"2015-05-28T19:23:40.445Z",
38 "description":"",
39 "avatar":null
40 },
41 "forked_from_project":{
42 "id":3,
43 "name":"Gitlab",
44 "name_with_namespace":"Root / gitlab",
45 "path":"gitlab",
46 "path_with_namespace":"root/gitlab"
47 },
48 "avatar_url":null
49 }
0 {"id":1,"url":"https://api.example.net/v1/webhooks/ci"}
0 [{"id":1,"url":"https://api.example.net/v1/webhooks/ci"}]
0 [{"id":36,"project_id":3,"title":"Eos ut modi et laudantium quasi porro voluptas sed.","description":null,"labels":[],"milestone":null,"assignee":{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":35,"project_id":3,"title":"Ducimus illo in iure voluptatem dolores labore.","description":null,"labels":[],"milestone":null,"assignee":{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":34,"project_id":3,"title":"Rem tempora voluptatum atque eum sit nihil neque.","description":null,"labels":[],"milestone":null,"assignee":{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":33,"project_id":3,"title":"Beatae possimus nostrum nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.","description":null,"labels":[],"milestone":null,"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":32,"project_id":3,"title":"Deserunt tenetur impedit est beatae voluptas voluptas quaerat quisquam.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":16,"project_id":3,"title":"Numquam earum aut laudantium reprehenderit voluptatem aut.","description":null,"labels":[],"milestone":null,"assignee":{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":15,"project_id":3,"title":"Qui veritatis voluptas fuga voluptate voluptas cupiditate.","description":null,"labels":[],"milestone":null,"assignee":{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":14,"project_id":3,"title":"In assumenda et ipsa qui debitis voluptatem incidunt.","description":null,"labels":[],"milestone":null,"assignee":{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":13,"project_id":3,"title":"Illo eveniet consequatur enim iste provident facilis rerum voluptatem et architecto aut.","description":null,"labels":[],"milestone":null,"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":12,"project_id":3,"title":"Veniam et tempore quidem eum reprehenderit cupiditate non aut velit eaque.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}]
0 {
1 "id": 2,
2 "title": "Key Title",
3 "key": "ssh-rsa ...",
4 "created_at": "2013-09-22T18:34:32Z"
5 }
0 [{
1 "id": 2,
2 "title": "Key Title",
3 "key": "ssh-rsa ...",
4 "created_at": "2013-09-22T18:34:32Z"
5 }]
0 {
1 "active": true,
2 "description": "test-2016-02-01",
3 "id": 9,
4 "is_shared": false,
5 "name": null
6 }
0 [
1 {
2 "active": true,
3 "description": "test-2-20150125",
4 "id": 8,
5 "is_shared": false,
6 "name": null
7 },
8 {
9 "active": true,
10 "description": "development_runner",
11 "id": 5,
12 "is_shared": true,
13 "name": null
14 }
15 ]
0 [{"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 {
1 "id": 3,
2 "description": null,
3 "default_branch": "master",
4 "public": false,
5 "visibility_level": 10,
6 "ssh_url_to_repo":"git@git.gitlab.com:root/gitlab.git",
7 "http_url_to_repo":"http://git.gitlab.com/root/gitlab.git",
8 "web_url":"http://git.gitlab.com/root/gitlab",
9 "tag_list": [
10
11 ],
12 "name": "GitLab Community Edition",
13 "name_with_namespace": "GitLab / GitLab Community Edition",
14 "path": "gitlab-ce",
15 "path_with_namespace": "gitlab/gitlab-ce",
16 "issues_enabled": true,
17 "open_issues_count": 1,
18 "merge_requests_enabled": true,
19 "builds_enabled": true,
20 "wiki_enabled": true,
21 "snippets_enabled": false,
22 "container_registry_enabled": false,
23 "created_at": "2013-09-30T13:46:02Z",
24 "last_activity_at": "2013-09-30T13:46:02Z",
25 "creator_id": 3,
26 "namespace": {
27 "created_at": "2013-09-30T13:46:02Z",
28 "description": "",
29 "id": 3,
30 "name": "GitLab",
31 "owner_id": 1,
32 "path": "gitlab",
33 "updated_at": "2013-09-30T13:46:02Z"
34 },
35 "archived": true,
36 "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
37 "shared_runners_enabled": true,
38 "forks_count": 0,
39 "star_count": 1,
40 "public_builds": true,
41 "shared_with_groups": [],
42 "only_allow_merge_if_build_succeeds": false
43 }
0 {"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 {"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 [{"name":"v2.8.2","commit":{"id":"a502f67c0b358cc6b391df0c5dca48375c21fcad","parents":[{"id":"4381084af341684240b1a671d368511afcf5774a"}],"tree":"1612068bdd20de5d14b3096cfa4c621e2051ed4c","message":"Up to 2.8.2","author":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-08-24T02:03:48-07:00","committed_date":"2012-08-24T02:03:48-07:00"}},{"name":"v2.8.1","commit":{"id":"ed2b53cd1c34c421b23208eeb502a141a6829f9d","parents":[{"id":"7ab587a47791e371f5c109c14097a5d1d7776ea5"}],"tree":"b7393b0b33b777583b285e85b423c4e5ab7f859f","message":"Up to 2.8.1","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-08-22T23:17:18-07:00","committed_date":"2012-08-22T23:17:18-07:00"}},{"name":"v2.8.0pre","commit":{"id":"b2c6ba97a25d299e83c51493d7bc770c13b8ed1a","parents":[{"id":"05da3801f53f06fdc529b4f3820af1380039f245"},{"id":"66399d558da45fb9cd3ea972a47a4f7bb12bfc8d"}],"tree":"36ad53f35bce1fe3f2a4a5f840e7b1bdbfed9c82","message":"Merge pull request #1230 from tsigo/hooray_apostrophes\n\nCorrect usage of \"Can't\"","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-08-16T14:11:08-07:00","committed_date":"2012-08-16T14:11:08-07:00"}},{"name":"v2.8.0","commit":{"id":"5c7ed6fa26b47ac71ff6ba04720d85df6d74b200","parents":[{"id":"d1daeba1736ba145fe525ce08a91f29495a3abf1"}],"tree":"4fc230ff2dbc0e75f27321eac2976aba5a6d323d","message":"Up to 2.8","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-08-21T15:15:26-07:00","committed_date":"2012-08-21T15:15:26-07:00"}},{"name":"v2.7.0pre","commit":{"id":"72a571724d84d112f98a5543c971e9b3b9da1383","parents":[{"id":"3ac840ff06e0ee5b349c52b5a8c02e803a17eec3"},{"id":"990b9217d9a55e26a53d4143d4a3c89123384327"}],"tree":"64b104df5d956e21e0749dc8e70849d1989de36f","message":"Merge pull request #1096 from moregeek/show-flash-note-when-destroying-a-project\n\nshow flash notice after deletion of a project","author":{"name":"Valeriy Sizov","email":"vsv2711@gmail.com"},"committer":{"name":"Valeriy Sizov","email":"vsv2711@gmail.com"},"authored_date":"2012-07-18T05:35:42-07:00","committed_date":"2012-07-18T05:35:42-07:00"}},{"name":"v2.7.0","commit":{"id":"8b7e404b5b6944e9c92cc270b2e5d0005781d49d","parents":[{"id":"11721b0dbe82c35789be3e4fa8e14663934b2ff5"}],"tree":"89fe8c5ff58daaedea07a910cffb14b04ebcc828","message":"Up to 2.7.0","author":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-07-21T00:53:55-07:00","committed_date":"2012-07-21T00:53:55-07:00"}},{"name":"v2.6.3","commit":{"id":"666cdb22792dd955a286b9993d6235b4cdd68b4b","parents":[{"id":"d92446df1fdba87101c92c90b1c34eb2f1eebef4"}],"tree":"888173aa4c12a4920d318c35b950095d3505673d","message":"up to 2.6.3","author":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-06-26T09:20:47-07:00","committed_date":"2012-06-26T09:21:28-07:00"}},{"name":"v2.6.2","commit":{"id":"39fecb554f172a0c8ea00316e612e1d37efc7200","parents":[{"id":"68389588d664100590b1a6ca7eedd50860b7e9bc"}],"tree":"53accb25e0b9d038d550cf387753bde15fe4ad19","message":"Up to 2.6.2","author":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-06-22T13:50:58-07:00","committed_date":"2012-06-22T13:50:58-07:00"}},{"name":"v2.6.1","commit":{"id":"d92a22c9e627268eca697bbd9b660d8c335df953","parents":[{"id":"193804516b8b0783c850981456e947f888ff51bb"}],"tree":"4ac1b5225f597ab55372cb5e950b121d6f55e386","message":"Up to 2.6.1","author":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-06-22T12:49:03-07:00","committed_date":"2012-06-22T12:49:03-07:00"}},{"name":"v2.6.0","commit":{"id":"b32465712becfbcf83d63b1e6eff7d1483fdabea","parents":[{"id":"1903f6ade027df0f10ef96b9439495eeda07482c"}],"tree":"ffbc05fd0f1771c1602c956df9556260048c7167","message":"Up to 2.6","author":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"randx","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-06-21T10:25:23-07:00","committed_date":"2012-06-21T10:25:23-07:00"}},{"name":"v2.5.0","commit":{"id":"cc8369144db2147d2956e8dd7d314e9a7dfd4fbb","parents":[{"id":"1b2068eaa91e5002d01a220c65da21dad8ccb071"}],"tree":"666a442e00689911169e8cc336c5ce60d014854c","message":"Prevent app crash in case if encoding failed","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-05-22T04:57:04-07:00","committed_date":"2012-05-22T04:57:04-07:00"}},{"name":"v2.4.2","commit":{"id":"f18339c26d673c5f8b4c19776036fd42a0de30aa","parents":[{"id":"c937d06c3c98e9ffce8ec1132203eaff6bf7b231"},{"id":"35e602f19c83585d64aa2043ed26eeb8cd7b40e2"}],"tree":"5101f0cd8e395fee1996764298a202437757e85b","message":"Merge branch 'master' of github.com:gitlabhq/gitlabhq","author":{"name":"Zevs","email":"vsv2711@gmail.com"},"committer":{"name":"Zevs","email":"vsv2711@gmail.com"},"authored_date":"2012-04-29T14:24:59-07:00","committed_date":"2012-04-29T14:24:59-07:00"}},{"name":"v2.4.1","commit":{"id":"d97a9aa4a44ff9f452144fad348fd9d7e3b48260","parents":[{"id":"21f3da23589d50038728393f0badc6255b5762ca"}],"tree":"905c33874b064778199f806749d5688e33d64be3","message":"fixed email markdown","author":{"name":"gitlabhq","email":"m@gitlabhq.com"},"committer":{"name":"gitlabhq","email":"m@gitlabhq.com"},"authored_date":"2012-04-23T05:32:56-07:00","committed_date":"2012-04-23T05:32:56-07:00"}},{"name":"v2.4.0pre","commit":{"id":"1845429268364e75bffdeb1075de8f1606e157ec","parents":[{"id":"45b18365d5f409f196a02a4e6e2b77b8ebef909b"}],"tree":"423c70246fa7ffd8804b26628fea34bdb2b22846","message":"Use try for commit prev_commit_id detection","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-04-19T13:35:35-07:00","committed_date":"2012-04-19T13:35:35-07:00"}},{"name":"v2.4.0","commit":{"id":"204c66461ed519eb0078be7e8ac8a6cb56834753","parents":[{"id":"511d07c47c9bf3a18bfa276d452c899369432a22"}],"tree":"9416c777cccf87d348f5705078e82f3f97485e19","message":"corrected exception for automerge","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-04-22T06:49:45-07:00","committed_date":"2012-04-22T06:49:45-07:00"}},{"name":"v2.3.1","commit":{"id":"fa8219e0a753e642a6f1dbdfc010d01ae8a949ee","parents":[{"id":"81da8e46f24913ccf42d3e2644962cbcbc0f9c2e"}],"tree":"5debfcd6d17f9d582aace6ac9b80db27d5c1fe36","message":"better MR list, dashboard pollished","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-03-22T13:57:04-07:00","committed_date":"2012-03-22T13:57:04-07:00"}},{"name":"v2.3.0pre","commit":{"id":"cadf12c60cc27c5b0b8273c1de4b190a0e88bd7d","parents":[{"id":"724ea16c348bc61cf7cb3dbe362c6f30cff1b2c7"}],"tree":"6f4c22761fd2dee405d3fbf38f9dd835bb3c8694","message":"Merged activities & projects pages","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-03-19T15:05:35-07:00","committed_date":"2012-03-19T15:05:35-07:00"}},{"name":"v2.3.0","commit":{"id":"b57faf9282d7df6cdd62953d474652a0ae2e6896","parents":[{"id":"cadf12c60cc27c5b0b8273c1de4b190a0e88bd7d"}],"tree":"f0d5b826df373191b4681452fc2ae4c5970cef4a","message":"Push events polished","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-03-20T14:59:35-07:00","committed_date":"2012-03-20T14:59:35-07:00"}},{"name":"v2.2.0pre","commit":{"id":"6a445b42003007cbb6c06f477c4d7a0b175688c1","parents":[{"id":"22f4c1908d0fc2dbce02e74ed03bf65f028d78d6"}],"tree":"9c60577833f6ca717acdebfa66140124c88e8471","message":"fixed forgot password form","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-02-20T10:37:37-08:00","committed_date":"2012-02-20T10:37:37-08:00"}},{"name":"v2.2.0","commit":{"id":"9e6d0710e927aa8ea834b8a9ae9f277be617ac7d","parents":[{"id":"8c40aab120dbc5507ab9cc8d7ad8e2519d6e9f25"},{"id":"6ea87c47f0f8a24ae031c3fff17bc913889ecd00"}],"tree":"86c831ab21236f21ffa5b97c752369612ce41b39","message":"Merge pull request #443 from CedricGatay/fix/incorrectLineNumberingInDiff\n\nIncorrect line numbering in diff","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-02-22T07:14:54-08:00","committed_date":"2012-02-22T07:14:54-08:00"}},{"name":"v2.1.0","commit":{"id":"98d6492582d232ed86525aa31ccbf280f4cbdaef","parents":[{"id":"611c5a87ab0c083a43785323b09cc47f554c3ba4"}],"tree":"1689b3cad580a18fd9b429ee0b33dac21c9f5a48","message":"removed broken migration","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-01-22T10:52:06-08:00","committed_date":"2012-01-22T10:52:06-08:00"}},{"name":"v2.0.0","commit":{"id":"9a2a8612769d472503b367fa35e99f6fb2876704","parents":[{"id":"2f7b67161952fc9ab322eba6878511b5f2dd5cf1"}],"tree":"26cdb4e66b5e664fe4bcd57d011c54c9c9c26ded","message":"Design tab for profile. Colorscheme as db value","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2011-12-20T12:47:09-08:00","committed_date":"2011-12-20T12:47:09-08:00"}},{"name":"v1.2.2","commit":{"id":"139a332293b9d8c4e5436619036e093483d8347f","parents":[{"id":"ade12da9488bea19d12505c371ead35686a1436e"}],"tree":"365d57f4df5c5dcac69b666cf6d2bfd8ef058008","message":"updated readme","author":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"authored_date":"2011-11-25T14:30:51-08:00","committed_date":"2011-11-25T14:30:51-08:00"}},{"name":"v1.2.1","commit":{"id":"7ebba27db21719c0035bab65fea92a4780051c73","parents":[{"id":"b56024100d40457a998f83adae3cdc830c997cda"},{"id":"a4fbe13fce87cb6ff2a27a2574ae25bf1dad145c"}],"tree":"b121a7576af1503a96954ce9a94598a68579e053","message":"Merge branch 'master' of dev.gitlabhq.com:gitlabhq","author":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"authored_date":"2011-11-22T13:15:09-08:00","committed_date":"2011-11-22T13:15:09-08:00"}},{"name":"v1.2.0pre","commit":{"id":"86829cae50857b5edf74b935380c6f68a19c2282","parents":[{"id":"a6b99319381c2d62ec4b92d64805e8de8965859e"}],"tree":"6aab9d13000584fa96fb3cb34d94f3b122bd1143","message":"fixed min height for menu","author":{"name":"gitlabhq","email":"m@gitlabhq.com"},"committer":{"name":"gitlabhq","email":"m@gitlabhq.com"},"authored_date":"2011-11-22T06:03:27-08:00","committed_date":"2011-11-22T06:03:27-08:00"}},{"name":"v1.2.0","commit":{"id":"b56024100d40457a998f83adae3cdc830c997cda","parents":[{"id":"4451b8df8ad6d4b6d79fbce77687c6c2fd37d0a9"}],"tree":"f402cbb6d54526a32b30968c98410bae97b27c8d","message":"lil style fixes","author":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"authored_date":"2011-11-22T09:57:25-08:00","committed_date":"2011-11-22T09:57:25-08:00"}},{"name":"v1.1.0pre","commit":{"id":"6b030fd41d697e327d2935b406cba70b6a460504","parents":[{"id":"3a2b273316fb29d63b489906f85d9b5329377258"}],"tree":"63b1fdb2a0f135f7074f6a94da14543b8450dd71","message":"1.1pre1","author":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"authored_date":"2011-10-21T10:04:41-07:00","committed_date":"2011-10-21T10:04:41-07:00"}},{"name":"v1.1.0","commit":{"id":"ba8048d71019b5aaa1f92ee5c3415bfddaa9babb","parents":[{"id":"6b030fd41d697e327d2935b406cba70b6a460504"}],"tree":"4db2b5f4f9b374dd1be3579459bc5947c225c9ba","message":"v1.1.0","author":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"authored_date":"2011-10-22T06:07:26-07:00","committed_date":"2011-10-22T06:07:26-07:00"}},{"name":"v1.0.2","commit":{"id":"3a2b273316fb29d63b489906f85d9b5329377258","parents":[{"id":"757ea634665e475bf69c1ec962040a0511ee8aeb"},{"id":"c374eb80ff9fb71d37faffc15714bf98b632d3e5"}],"tree":"e0d8170e61a9468a7bb5d4e63305171ec1efa6bf","message":"Merge pull request #40 from vslinko/patch-1\n\nIncrease max key length. Some keys has comment after key string.","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2011-10-18T23:30:06-07:00","committed_date":"2011-10-18T23:30:06-07:00"}},{"name":"v1.0.1","commit":{"id":"7b5799a97998b68416f1b6233ce427135c99165a","parents":[{"id":"0541b3f3c5dcd291d144c83d9731c75ee811b4e0"},{"id":"7b67480c76db8b9a9ccdc80015cc500dc6d26892"}],"tree":"e052185e9dd72a1b1a04d59a5f9efbf3c0369601","message":"Merge branch '1x' of github.com:gitlabhq/gitlabhq into 1x","author":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dzaporozhets@sphereconsultinginc.com"},"authored_date":"2011-10-14T15:16:44-07:00","committed_date":"2011-10-14T15:16:44-07:00"}}]
0 {
1 "id": 3,
2 "description": null,
3 "default_branch": "master",
4 "public": false,
5 "visibility_level": 10,
6 "ssh_url_to_repo":"git@git.gitlab.com:root/gitlab.git",
7 "http_url_to_repo":"http://git.gitlab.com/root/gitlab.git",
8 "web_url":"http://git.gitlab.com/root/gitlab",
9 "tag_list": [
10
11 ],
12 "name": "GitLab Community Edition",
13 "name_with_namespace": "GitLab / GitLab Community Edition",
14 "path": "gitlab-ce",
15 "path_with_namespace": "gitlab/gitlab-ce",
16 "issues_enabled": true,
17 "open_issues_count": 1,
18 "merge_requests_enabled": true,
19 "builds_enabled": true,
20 "wiki_enabled": true,
21 "snippets_enabled": false,
22 "container_registry_enabled": false,
23 "created_at": "2013-09-30T13:46:02Z",
24 "last_activity_at": "2013-09-30T13:46:02Z",
25 "creator_id": 3,
26 "namespace": {
27 "created_at": "2013-09-30T13:46:02Z",
28 "description": "",
29 "id": 3,
30 "name": "GitLab",
31 "owner_id": 1,
32 "path": "gitlab",
33 "updated_at": "2013-09-30T13:46:02Z"
34 },
35 "archived": true,
36 "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
37 "shared_runners_enabled": true,
38 "forks_count": 0,
39 "star_count": 0,
40 "public_builds": true,
41 "shared_with_groups": [],
42 "only_allow_merge_if_build_succeeds": false
43 }
0 {
1 "id": 498,
2 "sha": "7d938cb8ac15788d71f4b67c035515a160ea76d8",
3 "ref": "decreased-spec",
4 "status": "failed",
5 "name": "test",
6 "target_url": null,
7 "description": null,
8 "created_at": "2015-10-23T23:56:49.499+02:00",
9 "started_at": null,
10 "finished_at": "2015-10-23T23:56:49.534+02:00",
11 "author": {
12 "name": "Dominik Sander",
13 "username": "dsander",
14 "id": 1,
15 "state": "active",
16 "avatar_url": "https://secure.gravatar.com/avatar/xxx?s=40&d=identicon",
17 "web_url": "https://github.com/u/dsander"
18 }
19 }
0 [{"id":1,"code":"brute","name":"Brute","description":null,"path":"brute","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:56Z"},{"id":2,"code":"mozart","name":"Mozart","description":null,"path":"mozart","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:57Z"},{"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 {"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 source 'https://rubygems.org'
1 gem 'rails', '4.1.2'
0 {"tag_name":"0.0.1","description":"Amazing release. Wow"}
0 {"tag_name":"0.0.1","description":"Amazing release. Wow"}
0 {"file_path":"path","branch_name":"branch","encoding":"base64","content":"Y29udGVudA==","commit_message":"commit message"}
0 {"id":8,"variables":{"a":"10"}}
0 {
1 "active": true,
2 "architecture": null,
3 "description": "test-1-20150125",
4 "id": 6,
5 "is_shared": false,
6 "contacted_at": "2016-01-25T16:39:48.066Z",
7 "name": null,
8 "platform": null,
9 "projects": [
10 {
11 "id": 1,
12 "name": "GitLab Community Edition",
13 "name_with_namespace": "GitLab.org / GitLab Community Edition",
14 "path": "gitlab-ce",
15 "path_with_namespace": "gitlab-org/gitlab-ce"
16 }
17 ],
18 "token": "205086a8e3b9a2b818ffac9b89d102",
19 "revision": null,
20 "tag_list": [
21 "ruby",
22 "mysql"
23 ],
24 "version": null
25 }
0 {
1 "active": true,
2 "description": "test-1-20150125-test",
3 "id": 6,
4 "is_shared": false,
5 "name": null
6 }
0 {
1 "active": true,
2 "architecture": null,
3 "description": "abcefg",
4 "id": 6,
5 "is_shared": false,
6 "contacted_at": "2016-01-25T16:39:48.066Z",
7 "name": null,
8 "platform": null,
9 "projects": [
10 {
11 "id": 1,
12 "name": "GitLab Community Edition",
13 "name_with_namespace": "GitLab.org / GitLab Community Edition",
14 "path": "gitlab-ce",
15 "path_with_namespace": "gitlab-org/gitlab-ce"
16 }
17 ],
18 "token": "205086a8e3b9a2b818ffac9b89d102",
19 "revision": null,
20 "tag_list": [
21 "ruby",
22 "mysql"
23 ],
24 "version": null
25 }
0 [
1 {
2 "active": true,
3 "description": "test-1-20150125",
4 "id": 6,
5 "is_shared": false,
6 "name": null
7 },
8 {
9 "active": true,
10 "description": "test-2-20150125",
11 "id": 8,
12 "is_shared": false,
13 "name": null
14 }
15 ]
0 [
1 {
2 "active": true,
3 "description": "shared-runner-1",
4 "id": 1,
5 "is_shared": true,
6 "name": null
7 },
8 {
9 "active": true,
10 "description": "shared-runner-2",
11 "id": 3,
12 "is_shared": true,
13 "name": null
14 },
15 {
16 "active": true,
17 "description": "test-1-20150125",
18 "id": 6,
19 "is_shared": false,
20 "name": null
21 },
22 {
23 "active": true,
24 "description": "test-2-20150125",
25 "id": 8,
26 "is_shared": false,
27 "name": null
28 }
29 ]
0 {"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 {"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z","private_token":"qEsq1pt6HJPaNciie3MG"}
0 party on, dudes
1 be excellent to each other
0 {"id":1,"title":"Rails Console ActionMailer","file_name":"mailer_test.rb","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"expires_at":"2012-09-24T00:00:00Z","updated_at":"2012-09-17T09:51:42Z","created_at":"2012-09-17T09:51:42Z"}
0 #!/usr/bin/env ruby
1
2 puts "Cool snippet!"
0 [{"id":1,"title":"Rails Console ActionMailer","file_name":"mailer_test.rb","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"expires_at":"2012-09-24T00:00:00Z","updated_at":"2012-09-17T09:51:42Z","created_at":"2012-09-17T09:51:42Z"}]
0 {"id": 3, "url": "http://example.com/hook", "created_at": "2013-10-02T10:15:31Z"}
0 [{"id": 3, "url": "http://example.com/hook", "created_at": "2013-10-02T10:15:31Z"}]
0 {"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 {"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 {"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 {"tag_name":"0.0.1"}
0 [{"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 {"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z","access_level":40}
0 [{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z","access_level":40},{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":20},{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":40},{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":40},{"id":6,"email":"faye.watsica@rohanwalter.com","name":"Ambrose Hansen","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":40},{"id":7,"email":"maida@walshtorp.name","name":"Alana Hahn","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":20}]
0 [{"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 {
1 "id": 10,
2 "description": "my trigger",
3 "created_at": "2016-01-07T09:53:58.235Z",
4 "deleted_at": null,
5 "last_used": null,
6 "token": "6d056f63e50fe6f8c5f8f4aa10edb7",
7 "updated_at": "2016-01-07T09:53:58.235Z",
8 "owner": null
9 }
0 [
1 {
2 "id": 10,
3 "description": "my trigger",
4 "created_at": "2016-01-07T09:53:58.235Z",
5 "deleted_at": null,
6 "last_used": null,
7 "token": "6d056f63e50fe6f8c5f8f4aa10edb7",
8 "updated_at": "2016-01-07T09:53:58.235Z",
9 "owner": null
10 }
11 ]
0 {"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 {"id":1,"email":"email@example.com"}
0 [{"id":1,"email":"email@example.com"},{"id":3,"email":"email2@example.com"}]
0 [{"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"}]
0 [{"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 {
1 "key": "VARIABLE",
2 "value": "the value"
3 }
0 [
1 {
2 "key": "TEST_VARIABLE_1",
3 "value": "TEST_1"
4 },
5 {
6 "key": "TEST_VARIABLE_2",
7 "value": "TEST_2"
8 }
9 ]
0 require 'spec_helper'
1
2 describe Gitlab::CLI::Helpers do
3 describe ".method_owners" do
4 before do
5 @methods = Gitlab::CLI::Helpers.method_owners
6 end
7 it "should return Array of Hashes containing method names and owners" do
8 expect(@methods).to be_a Array
9 expect(@methods.all? { |m| m.is_a? Hash }).to be true
10 expect(@methods.all? { |m| m.keys.sort === [:name, :owner] }).to be true
11 end
12 end
13
14 describe ".valid_command?" do
15 it "should return true when command is valid" do
16 expect(Gitlab::CLI::Helpers.valid_command? 'merge_requests').to be_truthy
17 end
18 it "should return false when command is NOT valid" do
19 expect(Gitlab::CLI::Helpers.valid_command? 'mmmmmerge_requests').to be_falsy
20 end
21 end
22
23 describe ".symbolize_keys" do
24 context "when input is a Hash" do
25 it "should return a Hash with symbols for keys" do
26 hash = { 'key1' => 'val1', 'key2' => 'val2' }
27 symbolized_hash = Gitlab::CLI::Helpers.symbolize_keys(hash)
28 expect(symbolized_hash).to eq(key1: 'val1', key2: 'val2')
29 end
30 end
31 context "when input is NOT a Hash" do
32 it "should return input untouched" do
33 array = [1, 2, 3]
34 new_array = Gitlab::CLI::Helpers.symbolize_keys(array)
35 expect(new_array).to eq([1, 2, 3])
36 end
37 end
38 end
39
40 describe ".yaml_load" do
41 context "when argument is a YAML string" do
42 it "should return Ruby objects" do
43 argument = "{foo: bar, sna: fu}"
44 output = Gitlab::CLI::Helpers.yaml_load argument
45 expect(output).to eq('foo' => 'bar', 'sna' => 'fu')
46 end
47 end
48
49 context "when input is NOT valid YAML" do
50 it "should raise" do
51 ruby_array = [1, 2, 3, 4]
52 expect { Gitlab::CLI::Helpers.yaml_load ruby_array }.to raise_error TypeError
53 end
54 end
55 end
56 end
0 require 'spec_helper'
1 require 'json'
2
3 describe Gitlab::CLI do
4 describe ".run" do
5 context "when command is version" do
6 it "should show gem version" do
7 output = capture_output { Gitlab::CLI.run('-v') }
8 expect(output).to eq("Gitlab Ruby Gem #{Gitlab::VERSION}\n")
9 end
10 end
11
12 context "when command is info" do
13 it "should show environment info" do
14 output = capture_output { Gitlab::CLI.run('info') }
15 expect(output).to include("Gitlab endpoint is")
16 expect(output).to include("Gitlab private token is")
17 expect(output).to include("Ruby Version is")
18 expect(output).to include("Gitlab Ruby Gem")
19 end
20 end
21
22 context "when command is help" do
23 it "should show available actions" do
24 output = capture_output { Gitlab::CLI.run('help') }
25 expect(output).to include('Help Topics')
26 expect(output).to include('MergeRequests')
27 end
28 end
29
30 context "when command is user" do
31 before do
32 stub_get("/user", "user")
33 @output = capture_output { Gitlab::CLI.run('user') }
34 end
35
36 it "should show executed command" do
37 expect(@output).to include('Gitlab.user')
38 end
39
40 it "should show user data" do
41 expect(@output).to include('name')
42 expect(@output).to include('John Smith')
43 end
44 end
45
46 context "when command is users" do
47 before do
48 stub_get("/users", "users")
49 @output = capture_output { Gitlab::CLI.run('users') }
50 end
51
52 it "should show executed command" do
53 expect(@output).to include('Gitlab.users')
54 end
55
56 it "should show users data" do
57 expect(@output).to include('name')
58 expect(@output).to include('John Smith')
59 expect(@output).to include('Jack Smith')
60 end
61 end
62 end
63
64 describe ".start" do
65 context "when command with excluded fields" do
66 before do
67 stub_get("/user", "user")
68 args = ['user', '--except=id,email,name']
69 @output = capture_output { Gitlab::CLI.start(args) }
70 end
71
72 it "should show user data with excluded fields" do
73 expect(@output).to_not include('John Smith')
74 expect(@output).to include('bio')
75 expect(@output).to include('created_at')
76 end
77 end
78
79 context "when command with json output" do
80 before do
81 stub_get("/user", "user")
82 args = ['user', '--json']
83 @output = capture_output { Gitlab::CLI.start(args) }
84 end
85
86 it "should render output as json" do
87 expect(JSON.parse(@output)['result']).to eq(JSON.parse(File.read(File.dirname(__FILE__) + '/../fixtures/user.json')))
88 expect(JSON.parse(@output)['cmd']).to eq('Gitlab.user')
89 end
90 end
91
92 context "when command with required fields" do
93 before do
94 stub_get("/user", "user")
95 args = ['user', '--only=id,email,name']
96 @output = capture_output { Gitlab::CLI.start(args) }
97 end
98
99 it "should show user data with required fields" do
100 expect(@output).to include('id')
101 expect(@output).to include('name')
102 expect(@output).to include('email')
103 expect(@output).to include('John Smith')
104 expect(@output).to_not include('bio')
105 expect(@output).to_not include('created_at')
106 end
107 end
108
109 context "fetch project with namespace/repo" do
110 it "should encode delimiter" do
111 stub_get("/projects/gitlab-org%2Fgitlab-ce", "project")
112 args = ['project', 'gitlab-org/gitlab-ce']
113 @output = capture_output { Gitlab::CLI.start(args) }
114 expect(@output).to include('id')
115 end
116 end
117 end
118 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 it { should respond_to :repo_branches }
4 it { should respond_to :repo_branch }
5 it { should respond_to :repo_protect_branch }
6 it { should respond_to :repo_unprotect_branch }
7
8 describe ".branches" do
9 before do
10 stub_get("/projects/3/repository/branches", "branches")
11 @branches = Gitlab.branches(3)
12 end
13
14 it "should get the correct resource" do
15 expect(a_get("/projects/3/repository/branches")).to have_been_made
16 end
17
18 it "should return a paginated response of repository branches" do
19 expect(@branches).to be_a Gitlab::PaginatedResponse
20 expect(@branches.first.name).to eq("api")
21 end
22 end
23
24 describe ".branch" do
25 before do
26 stub_get("/projects/3/repository/branches/api", "branch")
27 @branch = Gitlab.branch(3, "api")
28 end
29
30 it "should get the correct resource" do
31 expect(a_get("/projects/3/repository/branches/api")).to have_been_made
32 end
33
34 it "should return information about a repository branch" do
35 expect(@branch.name).to eq("api")
36 end
37 end
38
39 describe ".protect_branch" do
40 before do
41 stub_put("/projects/3/repository/branches/api/protect", "branch")
42 @branch = Gitlab.protect_branch(3, "api")
43 end
44
45 it "should get the correct resource" do
46 expect(a_put("/projects/3/repository/branches/api/protect")).to have_been_made
47 end
48
49 it "should return information about a protected repository branch" do
50 expect(@branch.name).to eq("api")
51 end
52 end
53
54 describe ".unprotect_branch" do
55 before do
56 stub_put("/projects/3/repository/branches/api/unprotect", "branch")
57 @branch = Gitlab.unprotect_branch(3, "api")
58 end
59
60 it "should get the correct resource" do
61 expect(a_put("/projects/3/repository/branches/api/unprotect")).to have_been_made
62 end
63
64 it "should return information about an unprotected repository branch" do
65 expect(@branch.name).to eq("api")
66 end
67 end
68
69 describe ".create_branch" do
70 before do
71 stub_post("/projects/3/repository/branches", "branch")
72 @branch = Gitlab.create_branch(3, "api", "master")
73 end
74
75 it "should get the correct resource" do
76 expect(a_post("/projects/3/repository/branches")).to have_been_made
77 end
78
79 it "should return information about a new repository branch" do
80 expect(@branch.name).to eq("api")
81 end
82 end
83
84 describe ".delete_branch" do
85 before do
86 stub_delete("/projects/3/repository/branches/api", "branch_delete")
87 @branch = Gitlab.delete_branch(3, "api")
88 end
89
90 it "should get the correct resource" do
91 expect(a_delete("/projects/3/repository/branches/api")).to have_been_made
92 end
93
94 it "should return information about the deleted repository branch" do
95 expect(@branch.branch_name).to eq("api")
96 end
97 end
98 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".variables" do
4 before do
5 stub_get("/projects/3/variables", "variables")
6 @variables = Gitlab.variables(3)
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/projects/3/variables")).to have_been_made
11 end
12
13 it "should return an array of project's variables" do
14 expect(@variables).to be_a Gitlab::PaginatedResponse
15 expect(@variables.first.key).to eq("TEST_VARIABLE_1")
16 expect(@variables.first.value).to eq("TEST_1")
17 end
18 end
19
20 describe ".variable" do
21 before do
22 stub_get("/projects/3/variables/VARIABLE", "variable")
23 @variable = Gitlab.variable(3, "VARIABLE")
24 end
25
26 it "should get the correct resource" do
27 expect(a_get("/projects/3/variables/VARIABLE")).to have_been_made
28 end
29
30 it "should return information about a variable" do
31 expect(@variable.key).to eq("VARIABLE")
32 expect(@variable.value).to eq("the value")
33 end
34 end
35
36 describe ".create_variable" do
37 before do
38 stub_post("/projects/3/variables", "variable")
39 @variable = Gitlab.create_variable(3, "NEW_VARIABLE", "new value")
40 end
41
42 it "should get the correct resource" do
43 body = { key: "NEW_VARIABLE", value: "new value" }
44 expect(a_post("/projects/3/variables").with(body: body)).to have_been_made
45 end
46
47 it "should return information about a new variable" do
48 expect(@variable.key).to eq("VARIABLE")
49 expect(@variable.value).to eq("the value")
50 end
51 end
52
53 describe ".update_variable" do
54 before do
55 stub_put("/projects/3/variables/UPD_VARIABLE", "variable")
56 @variable = Gitlab.update_variable(3, "UPD_VARIABLE", "updated value")
57 end
58
59 it "should put the correct resource" do
60 body = { value: "updated value" }
61 expect(a_put("/projects/3/variables/UPD_VARIABLE").with(body: body)).to have_been_made
62 end
63
64 it "should return information about an updated variable" do
65 expect(@variable.key).to eq("VARIABLE")
66 expect(@variable.value).to eq("the value")
67 end
68 end
69
70 describe ".remove_variable" do
71 before do
72 stub_delete("/projects/3/variables/DEL_VARIABLE", "variable")
73 @variable = Gitlab.remove_variable(3, "DEL_VARIABLE")
74 end
75
76 it "should get the correct resource" do
77 expect(a_delete("/projects/3/variables/DEL_VARIABLE")).to have_been_made
78 end
79
80 it "should return information about a deleted variable" do
81 expect(@variable.key).to eq("VARIABLE")
82 expect(@variable.value).to eq("the value")
83 end
84 end
85 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".builds" do
4 before do
5 stub_get("/projects/3/builds", "builds")
6 @builds = Gitlab.builds(3)
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/projects/3/builds")).to have_been_made
11 end
12
13 it "should return a paginated response of project's builds" do
14 expect(@builds).to be_a Gitlab::PaginatedResponse
15 end
16 end
17
18 describe ".build" do
19 before do
20 stub_get("/projects/3/builds/8", "build")
21 @build = Gitlab.build(3, 8)
22 end
23
24 it "should get the correct resource" do
25 expect(a_get("/projects/3/builds/8")).to have_been_made
26 end
27
28 it "should return a single build" do
29 expect(@build).to be_a Gitlab::ObjectifiedHash
30 end
31
32 it "should return information about a build" do
33 expect(@build.id).to eq(8)
34 expect(@build.user.name).to eq("John Smith")
35 end
36 end
37
38 describe ".build_artifacts" do
39 context "when successful request" do
40 before do
41 fixture = load_fixture('build_artifacts')
42 fixture.set_encoding(Encoding::ASCII_8BIT)
43 stub_request(:get, "#{Gitlab.endpoint}/projects/3/builds/8/artifacts").
44 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
45 to_return(body: fixture.read, headers: { 'Content-Disposition' => "attachment; filename=artifacts.zip" })
46 @build_artifacts = Gitlab.build_artifacts(3, 8)
47 end
48
49 it "should get the correct resource" do
50 expect(a_get("/projects/3/builds/8/artifacts")).to have_been_made
51 end
52
53 it "should return a FileResponse" do
54 expect(@build_artifacts).to be_a Gitlab::FileResponse
55 end
56
57 it "should return a file with filename" do
58 expect(@build_artifacts.filename).to eq "artifacts.zip"
59 end
60 end
61
62 context "when bad request" do
63 it "should throw an exception" do
64 stub_get("/projects/3/builds/8/artifacts", "error_project_not_found", 404)
65 expect{ Gitlab.build_artifacts(3, 8) }.to raise_error(Gitlab::Error::NotFound, "Server responded with code 404, message: 404 Project Not Found. Request URI: #{Gitlab.endpoint}/projects/3/builds/8/artifacts")
66 end
67 end
68 end
69
70 describe ".builds_commits" do
71 before do
72 stub_get("/projects/3/repository/commits/0ff3ae198f8601a285adcf5c0fff204ee6fba5fd/builds", "builds_commits")
73 @builds_commits = Gitlab.commit_builds(3, "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd")
74 end
75
76 it "should get the correct resource" do
77 expect(a_get("/projects/3/repository/commits/0ff3ae198f8601a285adcf5c0fff204ee6fba5fd/builds")).to have_been_made
78 end
79
80 it "should return a paginated response of commit builds" do
81 expect(@builds_commits).to be_a Gitlab::PaginatedResponse
82 end
83
84 it "should return information about the builds" do
85 expect(@builds_commits.count).to eq(2)
86 end
87 end
88
89
90
91 describe ".build_cancel" do
92 before do
93 stub_post("/projects/3/builds/8/cancel", "build_cancel")
94 @build_cancel = Gitlab.build_cancel(3, 8)
95 end
96
97 it "should get the correct resource" do
98 expect(a_post("/projects/3/builds/8/cancel")).to have_been_made
99 end
100
101 it "should return a single build" do
102 expect(@build_cancel).to be_a Gitlab::ObjectifiedHash
103 end
104
105 it "should return information about a build" do
106 expect(@build_cancel.commit.author_name).to eq("John Smith")
107 end
108 end
109
110 describe ".build_retry" do
111 before do
112 stub_post("/projects/3/builds/69/retry", "build_retry")
113 @build_retry = Gitlab.build_retry(3, 69)
114 end
115
116 it "should get the correct resource" do
117 expect(a_post("/projects/3/builds/69/retry")).to have_been_made
118 end
119
120 it "should return a single build" do
121 expect(@build_retry).to be_a Gitlab::ObjectifiedHash
122 end
123
124 it "should return information about a build" do
125 expect(@build_retry.commit.author_name).to eq("John Smith")
126 end
127 end
128
129 describe ".build_erase" do
130 before do
131 stub_post("/projects/3/builds/69/erase", "build_erase")
132 @build_retry = Gitlab.build_erase(3, 69)
133 end
134
135 it "should get the correct resource" do
136 expect(a_post("/projects/3/builds/69/erase")).to have_been_made
137 end
138
139 it "should return a single build" do
140 expect(@build_retry).to be_a Gitlab::ObjectifiedHash
141 end
142
143 it "should return information about a build" do
144 expect(@build_retry.commit.author_name).to eq("John Smith")
145 end
146 end
147 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe '#inspect' do
4 it 'masks tokens on inspect' do
5 client = described_class.new(private_token: 'ui3gIYf4MMzTx-Oh5cEBx')
6 inspected = client.inspect
7 expect(inspected).to include('****************cEBx')
8 end
9 end
10 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 it { should respond_to :repo_commits }
4 it { should respond_to :repo_commit }
5 it { should respond_to :repo_commit_diff }
6 it { should respond_to :repo_commit_comments }
7 it { should respond_to :repo_create_commit_comment }
8 it { should respond_to :repo_commit_status }
9 it { should respond_to :repo_update_commit_status }
10
11 describe ".commits" do
12 before do
13 stub_get("/projects/3/repository/commits", "project_commits").
14 with(query: { ref_name: "api" })
15 @commits = Gitlab.commits(3, ref_name: "api")
16 end
17
18 it "should get the correct resource" do
19 expect(a_get("/projects/3/repository/commits").
20 with(query: { ref_name: "api" })).to have_been_made
21 end
22
23 it "should return a paginated response of repository commits" do
24 expect(@commits).to be_a Gitlab::PaginatedResponse
25 expect(@commits.first.id).to eq("f7dd067490fe57505f7226c3b54d3127d2f7fd46")
26 end
27 end
28
29 describe ".commit" do
30 before do
31 stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6", "project_commit")
32 @commit = Gitlab.commit(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
33 end
34
35 it "should get the correct resource" do
36 expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6")).
37 to have_been_made
38 end
39
40 it "should return a repository commit" do
41 expect(@commit.id).to eq("6104942438c14ec7bd21c6cd5bd995272b3faff6")
42 end
43 end
44
45 describe ".commit_diff" do
46 before do
47 stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff", "project_commit_diff")
48 @diff = Gitlab.commit_diff(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
49 end
50
51 it "should get the correct resource" do
52 expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff")).
53 to have_been_made
54 end
55
56 it "should return a diff of a commit" do
57 expect(@diff.new_path).to eq("doc/update/5.4-to-6.0.md")
58 end
59 end
60
61 describe ".commit_comments" do
62 before do
63 stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments", "project_commit_comments")
64 @commit_comments = Gitlab.commit_comments(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
65 end
66
67 it "should get the correct resource" do
68 expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments")).
69 to have_been_made
70 end
71
72 it "should return commit's comments" do
73 expect(@commit_comments).to be_a Gitlab::PaginatedResponse
74 expect(@commit_comments.length).to eq(2)
75 expect(@commit_comments[0].note).to eq("this is the 1st comment on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6")
76 expect(@commit_comments[0].author.id).to eq(11)
77 expect(@commit_comments[1].note).to eq("another discussion point on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6")
78 expect(@commit_comments[1].author.id).to eq(12)
79 end
80 end
81
82 describe ".create_commit_comment" do
83 before do
84 stub_post("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments", "project_commit_comment")
85 @merge_request = Gitlab.create_commit_comment(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'Nice code!')
86 end
87
88 it "should return information about the newly created comment" do
89 expect(@merge_request.note).to eq('Nice code!')
90 expect(@merge_request.author.id).to eq(1)
91 end
92 end
93
94 describe ".commit_status" do
95 before do
96 stub_get("/projects/6/repository/commits/7d938cb8ac15788d71f4b67c035515a160ea76d8/statuses", 'project_commit_status').
97 with(query: { all: 'true' })
98 @statuses = Gitlab.commit_status(6, '7d938cb8ac15788d71f4b67c035515a160ea76d8', all: true)
99 end
100
101 it "should get the correct resource" do
102 expect(a_get("/projects/6/repository/commits/7d938cb8ac15788d71f4b67c035515a160ea76d8/statuses").
103 with(query: { all: true }))
104 end
105
106 it "should get statuses of a commit" do
107 expect(@statuses).to be_kind_of Gitlab::PaginatedResponse
108 expect(@statuses.first.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8')
109 expect(@statuses.first.ref).to eq('decreased-spec')
110 expect(@statuses.first.status).to eq('failed')
111 expect(@statuses.last.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8')
112 expect(@statuses.last.status).to eq('success')
113 end
114 end
115
116 describe ".update_commit_status" do
117 before do
118 stub_post("/projects/6/statuses/7d938cb8ac15788d71f4b67c035515a160ea76d8", 'project_update_commit_status').
119 with(query: { name: 'test', ref: 'decreased-spec', state: 'failed' })
120 @status = Gitlab.update_commit_status(6, '7d938cb8ac15788d71f4b67c035515a160ea76d8', 'failed', name: 'test', ref: 'decreased-spec')
121 end
122
123 it "should get the correct resource" do
124 expect(a_post('/projects/6/statuses/7d938cb8ac15788d71f4b67c035515a160ea76d8').
125 with(query: { name: 'test', ref: 'decreased-spec', state: 'failed' }))
126 end
127
128 it "should information about the newly created status" do
129 expect(@status).to be_kind_of Gitlab::ObjectifiedHash
130 expect(@status.id).to eq(498)
131 expect(@status.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8')
132 expect(@status.status).to eq('failed')
133 expect(@status.ref).to eq('decreased-spec')
134 end
135 end
136
137 describe ".create_commit" do
138 let(:actions) do
139 [
140 {
141 action: "create",
142 file_path: "foo/bar",
143 content: "some content"
144 }
145 ]
146 end
147
148 let(:query) do
149 {
150 branch_name: 'dev',
151 commit_message: 'refactors everything',
152 actions: actions,
153 author_email: 'joe@sample.org',
154 author_name: 'Joe Sample'
155 }
156 end
157
158 before do
159 stub_post("/projects/6/repository/commits", 'project_commit_create').with(query: query)
160 @commit = Gitlab.create_commit(6, 'dev', 'refactors everything', actions, {author_email: 'joe@sample.org', author_name: 'Joe Sample'})
161 end
162
163 it "should return id of a created commit" do
164 expect(@commit.id).to eq('ed899a2f4b50b4370feeea94676502b42383c746')
165 end
166 end
167 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".groups" do
4 before do
5 stub_get("/groups", "groups")
6 stub_get("/groups/3", "group")
7 @group = Gitlab.group(3)
8 @groups = Gitlab.groups
9 end
10
11 it "should get the correct resource" do
12 expect(a_get("/groups")).to have_been_made
13 expect(a_get("/groups/3")).to have_been_made
14 end
15
16 it "should return a paginated response of groups" do
17 expect(@groups).to be_a Gitlab::PaginatedResponse
18 expect(@groups.first.path).to eq("threegroup")
19 end
20 end
21
22 describe ".create_group" do
23 context "without description" do
24 before do
25 stub_post("/groups", "group_create")
26 @group = Gitlab.create_group('GitLab-Group', 'gitlab-path')
27 end
28
29 it "should get the correct resource" do
30 expect(a_post("/groups").
31 with(body: { path: 'gitlab-path', name: 'GitLab-Group' })).to have_been_made
32 end
33
34 it "should return information about a created group" do
35 expect(@group.name).to eq("Gitlab-Group")
36 expect(@group.path).to eq("gitlab-group")
37 end
38 end
39
40 context "with description" do
41 before do
42 stub_post("/groups", "group_create_with_description")
43 @group = Gitlab.create_group('GitLab-Group', 'gitlab-path', description: 'gitlab group description')
44 end
45
46 it "should get the correct resource" do
47 expect(a_post("/groups").
48 with(body: { path: 'gitlab-path', name: 'GitLab-Group',
49 description: 'gitlab group description' })).to have_been_made
50 end
51
52 it "should return information about a created group" do
53 expect(@group.name).to eq("Gitlab-Group")
54 expect(@group.path).to eq("gitlab-group")
55 expect(@group.description).to eq("gitlab group description")
56 end
57 end
58 end
59
60 describe ".delete_group" do
61 context "without description" do
62 before do
63 stub_delete("/groups/42", "group_delete")
64 @group = Gitlab.delete_group(42)
65 end
66
67 it "should get the correct resource" do
68 expect(a_delete("/groups/42")).to have_been_made
69 end
70
71 it "should return information about a deleted group" do
72 expect(@group.name).to eq("Gitlab-Group")
73 expect(@group.path).to eq("gitlab-group")
74 end
75 end
76 end
77
78 describe ".transfer_project_to_group" do
79 before do
80 stub_post("/projects", "project")
81 @project = Gitlab.create_project('Gitlab')
82 stub_post("/groups", "group_create")
83 @group = Gitlab.create_group('GitLab-Group', 'gitlab-path')
84
85 stub_post("/groups/#{@group.id}/projects/#{@project.id}", "group_create")
86 @group_transfer = Gitlab.transfer_project_to_group(@group.id, @project.id)
87 end
88
89 it "should post to the correct resource" do
90 expect(a_post("/groups/#{@group.id}/projects/#{@project.id}").with(body: { id: @group.id.to_s, project_id: @project.id.to_s })).to have_been_made
91 end
92
93 it "should return information about the group" do
94 expect(@group_transfer.name).to eq(@group.name)
95 expect(@group_transfer.path).to eq(@group.path)
96 expect(@group_transfer.id).to eq(@group.id)
97 end
98 end
99
100 describe ".group_members" do
101 before do
102 stub_get("/groups/3/members", "group_members")
103 @members = Gitlab.group_members(3)
104 end
105
106 it "should get the correct resource" do
107 expect(a_get("/groups/3/members")).to have_been_made
108 end
109
110 it "should return information about a group members" do
111 expect(@members).to be_a Gitlab::PaginatedResponse
112 expect(@members.size).to eq(2)
113 expect(@members[1].name).to eq("John Smith")
114 end
115 end
116
117 describe ".add_group_member" do
118 before do
119 stub_post("/groups/3/members", "group_member")
120 @member = Gitlab.add_group_member(3, 1, 40)
121 end
122
123 it "should get the correct resource" do
124 expect(a_post("/groups/3/members").
125 with(body: { user_id: '1', access_level: '40' })).to have_been_made
126 end
127
128 it "should return information about the added member" do
129 expect(@member.name).to eq("John Smith")
130 end
131 end
132
133 describe ".edit_group_member" do
134 before do
135 stub_put("/groups/3/members/1", "group_member_edit")
136 @member = Gitlab.edit_group_member(3, 1, 50)
137 end
138
139 it "should get the correct resource" do
140 expect(a_put("/groups/3/members/1")
141 .with(body: { access_level: '50'})).to have_been_made
142 end
143
144 it "should return information about the edited member" do
145 expect(@member.access_level).to eq(50)
146 end
147 end
148
149 describe ".remove_group_member" do
150 before do
151 stub_delete("/groups/3/members/1", "group_member_delete")
152 @group = Gitlab.remove_group_member(3, 1)
153 end
154
155 it "should get the correct resource" do
156 expect(a_delete("/groups/3/members/1")).to have_been_made
157 end
158
159 it "should return information about the group the member was removed from" do
160 expect(@group.group_id).to eq(3)
161 end
162 end
163
164 describe ".group_projects" do
165 before do
166 stub_get("/groups/4/projects", "group_projects")
167 @projects = Gitlab.group_projects(4)
168 end
169
170 it "should get the list of projects" do
171 expect(a_get("/groups/4/projects")).to have_been_made
172 end
173
174 it "should return a list of of projects under a group" do
175 expect(@projects).to be_a Gitlab::PaginatedResponse
176 expect(@projects.size).to eq(1)
177 expect(@projects[0].name).to eq("Diaspora Client")
178 end
179 end
180
181 describe ".group_search" do
182 before do
183 stub_get("/groups?search=Group", "group_search")
184 @groups = Gitlab.group_search('Group')
185 end
186
187 it "should get the correct resource" do
188 expect(a_get("/groups?search=Group")).to have_been_made
189 end
190
191 it "should return an array of groups found" do
192 expect(@groups.first.id).to eq(5)
193 expect(@groups.last.id).to eq(8)
194 end
195 end
196 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".issues" do
4 context "with project ID passed" do
5 before do
6 stub_get("/projects/3/issues", "project_issues")
7 @issues = Gitlab.issues(3)
8 end
9
10 it "should get the correct resource" do
11 expect(a_get("/projects/3/issues")).to have_been_made
12 end
13
14 it "should return a paginated response of project's issues" do
15 expect(@issues).to be_a Gitlab::PaginatedResponse
16 expect(@issues.first.project_id).to eq(3)
17 end
18 end
19
20 context 'with literal project ID passed' do
21 before do
22 stub_get("/projects/gitlab-org%2Fgitlab-ce/issues", "project_issues")
23 @issues = Gitlab.issues('gitlab-org/gitlab-ce')
24 end
25
26 it "should get the correct resource" do
27 expect(a_get("/projects/gitlab-org%2Fgitlab-ce/issues")).to have_been_made
28 end
29
30 it "should return a paginated response of project's issues" do
31 expect(@issues).to be_a Gitlab::PaginatedResponse
32 expect(@issues.first.project_id).to eq(3)
33 end
34 end
35
36 context "without project ID passed" do
37 before do
38 stub_get("/issues", "issues")
39 @issues = Gitlab.issues
40 end
41
42 it "should get the correct resource" do
43 expect(a_get("/issues")).to have_been_made
44 end
45
46 it "should return a paginated response of user's issues" do
47 expect(@issues).to be_a Gitlab::PaginatedResponse
48 expect(@issues.first.closed).to be_falsey
49 expect(@issues.first.author.name).to eq("John Smith")
50 end
51 end
52 end
53
54 describe ".issue" do
55 before do
56 stub_get("/projects/3/issues/33", "issue")
57 @issue = Gitlab.issue(3, 33)
58 end
59
60 it "should get the correct resource" do
61 expect(a_get("/projects/3/issues/33")).to have_been_made
62 end
63
64 it "should return information about an issue" do
65 expect(@issue.project_id).to eq(3)
66 expect(@issue.assignee.name).to eq("Jack Smith")
67 end
68 end
69
70 describe ".create_issue" do
71 before do
72 stub_post("/projects/3/issues", "issue")
73 @issue = Gitlab.create_issue(3, 'title')
74 end
75
76 it "should get the correct resource" do
77 expect(a_post("/projects/3/issues").
78 with(body: { title: 'title' })).to have_been_made
79 end
80
81 it "should return information about a created issue" do
82 expect(@issue.project_id).to eq(3)
83 expect(@issue.assignee.name).to eq("Jack Smith")
84 end
85 end
86
87 describe ".edit_issue" do
88 before do
89 stub_put("/projects/3/issues/33", "issue")
90 @issue = Gitlab.edit_issue(3, 33, title: 'title')
91 end
92
93 it "should get the correct resource" do
94 expect(a_put("/projects/3/issues/33").
95 with(body: { title: 'title' })).to have_been_made
96 end
97
98 it "should return information about an edited issue" do
99 expect(@issue.project_id).to eq(3)
100 expect(@issue.assignee.name).to eq("Jack Smith")
101 end
102 end
103
104 describe ".close_issue" do
105 before do
106 stub_put("/projects/3/issues/33", "issue")
107 @issue = Gitlab.close_issue(3, 33)
108 end
109
110 it "should get the correct resource" do
111 expect(a_put("/projects/3/issues/33").
112 with(body: { state_event: 'close' })).to have_been_made
113 end
114
115 it "should return information about an closed issue" do
116 expect(@issue.project_id).to eq(3)
117 expect(@issue.assignee.name).to eq("Jack Smith")
118 end
119 end
120
121 describe ".reopen_issue" do
122 before do
123 stub_put("/projects/3/issues/33", "issue")
124 @issue = Gitlab.reopen_issue(3, 33)
125 end
126
127 it "should get the correct resource" do
128 expect(a_put("/projects/3/issues/33").
129 with(body: { state_event: 'reopen' })).to have_been_made
130 end
131
132 it "should return information about an reopened issue" do
133 expect(@issue.project_id).to eq(3)
134 expect(@issue.assignee.name).to eq("Jack Smith")
135 end
136 end
137
138 describe ".subscribe_to_issue" do
139 before do
140 stub_post("/projects/3/issues/33/subscribe", "issue")
141 @issue = Gitlab.subscribe_to_issue(3, 33)
142 end
143
144 it "should get the correct resource" do
145 expect(a_post("/projects/3/issues/33/subscribe")).to have_been_made
146 end
147
148 it "should return information about the subscribed issue" do
149 expect(@issue.project_id).to eq(3)
150 expect(@issue.assignee.name).to eq("Jack Smith")
151 end
152 end
153
154 describe ".unsubscribe_from_issue" do
155 before do
156 stub_post("/projects/3/issues/33/unsubscribe", "issue")
157 @issue = Gitlab.unsubscribe_from_issue(3, 33)
158 end
159
160 it "should get the correct resource" do
161 expect(a_post("/projects/3/issues/33/unsubscribe")).to have_been_made
162 end
163
164 it "should return information about the unsubscribed issue" do
165 expect(@issue.project_id).to eq(3)
166 expect(@issue.assignee.name).to eq("Jack Smith")
167 end
168 end
169
170 describe ".delete_issue" do
171 before do
172 stub_delete("/projects/3/issues/33", "issue")
173 @issue = Gitlab.delete_issue(3, 33)
174 end
175
176 it "should get the correct resource" do
177 expect(a_delete("/projects/3/issues/33")).to have_been_made
178 end
179
180 it "should return information about a deleted issue" do
181 expect(@issue.project_id).to eq(3)
182 expect(@issue.id).to eq(33)
183 end
184 end
185 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe '.jobs' do
4 before do
5 stub_get('/projects/1/jobs', 'jobs')
6 @projects = Gitlab.jobs(1)
7 end
8
9 it 'should get the correct resource' do
10 expect(a_get('/projects/1/jobs')).to have_been_made
11 end
12 end
13
14 describe '.jobs - with scopes' do
15 before do
16 stub_get('/projects/1/jobs?scope[]=created&scope[]=running', 'jobs')
17 @projects = Gitlab.jobs(1, scope: %w[created running])
18 end
19
20 it 'should get the correct resource' do
21 expect(a_get('/projects/1/jobs?scope[]=created&scope[]=running')).to have_been_made
22 end
23 end
24
25 describe '.pipeline_jobs' do
26 before do
27 stub_get('/projects/1/pipelines/1/jobs', 'pipeline_jobs')
28 @projects = Gitlab.pipeline_jobs(1, 1)
29 end
30 it 'should get the correct resource' do
31 expect(a_get('/projects/1/pipelines/1/jobs')).to have_been_made
32 end
33 end
34
35 describe '.pipeline_jobs - with scope' do
36 before do
37 stub_get('/projects/1/pipelines/1/jobs?scope[]=running&scope[]=created', 'pipeline_jobs')
38 @projects = Gitlab.pipeline_jobs(1, 1, scope: %w[running created])
39 end
40 it 'should get the correct resource' do
41 expect(a_get('/projects/1/pipelines/1/jobs?scope[]=running&scope[]=created')).to have_been_made
42 end
43 end
44
45 describe '.job' do
46 before do
47 stub_get('/projects/1/jobs/1', 'job')
48 @projects = Gitlab.job(1, 1)
49 end
50 it 'should get the correct resource' do
51 expect(a_get('/projects/1/jobs/1')).to have_been_made
52 end
53 end
54
55 describe '.job_artifacts' do
56 before do
57 stub_get('/projects/1/jobs/1/artifacts', 'job')
58 @projects = Gitlab.job_artifacts(1, 1)
59 end
60 it 'should get the correct resource' do
61 expect(a_get('/projects/1/jobs/1/artifacts')).to have_been_made
62 end
63 end
64
65 describe '.job_artifacts_download' do
66 before do
67 stub_get('/projects/1/jobs/artifacts/master/download?job=Release%20Build', 'job')
68 @projects = Gitlab.job_artifacts_download(1, 'master', 'Release Build')
69 end
70 it 'should get the correct resource' do
71 expect(a_get('/projects/1/jobs/artifacts/master/download?job=Release%20Build')).to have_been_made
72 end
73 end
74
75 describe '.job_trace' do
76 before do
77 stub_get('/projects/1/jobs/1/trace', 'job_trace')
78 @projects = Gitlab.job_trace(1, 1)
79 end
80 it 'should get the correct resource' do
81 expect(a_get('/projects/1/jobs/1/trace')).to have_been_made
82 end
83 end
84
85 describe '.job_cancel' do
86 before do
87 stub_post('/projects/1/jobs/1/cancel', 'job')
88 @projects = Gitlab.job_cancel(1, 1)
89 end
90 it 'should get the correct resource' do
91 expect(a_post('/projects/1/jobs/1/cancel')).to have_been_made
92 end
93 end
94
95 describe '.job_retry' do
96 before do
97 stub_post('/projects/1/jobs/1/retry', 'job')
98 @projects = Gitlab.job_retry(1, 1)
99 end
100 it 'should get the correct resource' do
101 expect(a_post('/projects/1/jobs/1/retry')).to have_been_made
102 end
103 end
104
105 describe '.job_erase' do
106 before do
107 stub_post('/projects/1/jobs/1/erase', 'job')
108 @projects = Gitlab.job_erase(1, 1)
109 end
110 it 'should get the correct resource' do
111 expect(a_post('/projects/1/jobs/1/erase')).to have_been_made
112 end
113 end
114
115 describe '.job_play' do
116 before do
117 stub_post('/projects/1/jobs/1/play', 'job')
118 @projects = Gitlab.job_play(1, 1)
119 end
120 it 'should get the correct resource' do
121 expect(a_post('/projects/1/jobs/1/play')).to have_been_made
122 end
123 end
124
125 describe '.job_artifacts_keep' do
126 before do
127 stub_post('/projects/1/jobs/1/artifacts/keep', 'job')
128 @projects = Gitlab.job_artifacts_keep(1, 1)
129 end
130 it 'should get the correct resource' do
131 expect(a_post('/projects/1/jobs/1/artifacts/keep')).to have_been_made
132 end
133 end
134 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".key" do
4 before do
5 stub_get("/keys/1", "key")
6 @key = Gitlab.key(1)
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/keys/1")).to have_been_made
11 end
12
13 it "should return information about a key" do
14 expect(@key.id).to eq(1)
15 expect(@key.title).to eq("narkoz@helium")
16 end
17 end
18 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".labels" do
4 before do
5 stub_get("/projects/3/labels", "labels")
6 @labels = Gitlab.labels(3)
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/projects/3/labels")).to have_been_made
11 end
12
13 it "should return a paginated response of project's labels" do
14 expect(@labels).to be_a Gitlab::PaginatedResponse
15 expect(@labels.first.name).to eq("Backlog")
16 end
17 end
18
19 describe ".delete" do
20 before do
21 stub_delete("/projects/3/labels", "label")
22 @label = Gitlab.delete_label(3, "Backlog")
23 end
24
25 it "should get the correct resource" do
26 expect(a_delete("/projects/3/labels").
27 with(body: { name: 'Backlog' })).to have_been_made
28 end
29
30 it "should return information about a deleted snippet" do
31 expect(@label.name).to eq("Backlog")
32 end
33 end
34
35 describe ".edit_label" do
36 before do
37 stub_put("/projects/3/labels", "label")
38 @label = Gitlab.edit_label(3, "TODO", new_name: 'Backlog')
39 end
40
41 it "should get the correct resource" do
42 expect(a_put("/projects/3/labels").
43 with(body: { name: 'TODO', new_name: "Backlog" })).to have_been_made
44 end
45
46 it "should return information about an edited label" do
47 expect(@label.name).to eq("Backlog")
48 end
49 end
50
51 describe ".create_label" do
52 before do
53 stub_post("/projects/3/labels", "label")
54 @label = Gitlab.create_label(3, 'Backlog', '#DD10AA')
55 end
56
57 it "should get the correct resource" do
58 expect(a_post("/projects/3/labels").
59 with(body: { name: 'Backlog', color: '#DD10AA' })).to have_been_made
60 end
61
62 it "should return information about a created label" do
63 expect(@label.name).to eq('Backlog')
64 expect(@label.color).to eq('#DD10AA')
65 end
66 end
67 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".merge_requests" do
4 before do
5 stub_get("/projects/3/merge_requests", "merge_requests")
6 @merge_requests = Gitlab.merge_requests(3)
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/projects/3/merge_requests")).to have_been_made
11 end
12
13 it "should return a paginated response of project's merge requests" do
14 expect(@merge_requests).to be_a Gitlab::PaginatedResponse
15 expect(@merge_requests.first.project_id).to eq(3)
16 end
17 end
18
19 describe ".merge_request" do
20 before do
21 stub_get("/projects/3/merge_requests/1", "merge_request")
22 @merge_request = Gitlab.merge_request(3, 1)
23 end
24
25 it "should get the correct resource" do
26 expect(a_get("/projects/3/merge_requests/1")).to have_been_made
27 end
28
29 it "should return information about a merge request" do
30 expect(@merge_request.project_id).to eq(3)
31 expect(@merge_request.assignee.name).to eq("Jack Smith")
32 end
33 end
34
35 describe ".create_merge_request" do
36 before do
37 stub_post("/projects/3/merge_requests", "merge_request")
38 end
39
40 it "should return information about a merge request" do
41 @merge_request = Gitlab.create_merge_request(3, 'New feature',
42 source_branch: 'api',
43 target_branch: 'master'
44 )
45 expect(@merge_request.project_id).to eq(3)
46 expect(@merge_request.assignee.name).to eq("Jack Smith")
47 end
48 end
49
50 describe ".update_merge_request" do
51 before do
52 stub_put("/projects/3/merge_requests/2", "merge_request").
53 with(body: {
54 assignee_id: '1',
55 target_branch: 'master',
56 title: 'A different new feature'
57 })
58 @merge_request = Gitlab.update_merge_request(3, 2,
59 assignee_id: '1',
60 target_branch: 'master',
61 title: 'A different new feature'
62 )
63 end
64
65 it "should get the correct resource" do
66 expect(a_put("/projects/3/merge_requests/2").
67 with(body: {
68 assignee_id: '1',
69 target_branch: 'master',
70 title: 'A different new feature'
71 })).to have_been_made
72 end
73
74 it "should return information about a merge request" do
75 expect(@merge_request.project_id).to eq(3)
76 expect(@merge_request.assignee.name).to eq("Jack Smith")
77 end
78 end
79
80 describe ".accept_merge_request" do
81 before do
82 stub_put("/projects/5/merge_requests/42/merge", "merge_request").
83 with(body: { merge_commit_message: 'Nice!' })
84 @merge_request = Gitlab.accept_merge_request(5, 42, merge_commit_message: 'Nice!')
85 end
86
87 it "should get the correct resource" do
88 expect(a_put("/projects/5/merge_requests/42/merge").
89 with(body: { merge_commit_message: 'Nice!' })).to have_been_made
90 end
91
92 it "should return information about merged merge request" do
93 expect(@merge_request.project_id).to eq(3)
94 expect(@merge_request.assignee.name).to eq("Jack Smith")
95 end
96 end
97
98 describe ".merge_request_comments" do
99 before do
100 stub_get("/projects/3/merge_requests/2/notes", "merge_request_comments")
101 @merge_request = Gitlab.merge_request_comments(3, 2)
102 end
103
104 it "should get the correct resource" do
105 expect(a_get("/projects/3/merge_requests/2/notes")).to have_been_made
106 end
107
108 it "should return merge request's comments" do
109 expect(@merge_request).to be_an Gitlab::PaginatedResponse
110 expect(@merge_request.length).to eq(2)
111 expect(@merge_request[0].note).to eq("this is the 1st comment on the 2merge merge request")
112 expect(@merge_request[0].author.id).to eq(11)
113 expect(@merge_request[1].note).to eq("another discussion point on the 2merge request")
114 expect(@merge_request[1].author.id).to eq(12)
115 end
116 end
117
118 describe ".create_merge_request_comment" do
119 before do
120 stub_post("/projects/3/merge_requests/2/notes", "merge_request_comment")
121 @merge_request = Gitlab.create_merge_request_comment(3, 2, 'Cool Merge Request!')
122 end
123
124 it "should get the correct resource" do
125 expect(a_post("/projects/3/merge_requests/2/notes")).to have_been_made
126 end
127
128 it "should return information about a merge request" do
129 expect(@merge_request.note).to eq('Cool Merge Request!')
130 expect(@merge_request.author.id).to eq(1)
131 end
132 end
133
134 describe ".merge_request_changes" do
135 before do
136 stub_get("/projects/3/merge_requests/2/changes", "merge_request_changes")
137 @mr_changes = Gitlab.merge_request_changes(3, 2)
138 end
139
140 it "should get the correct resource" do
141 expect(a_get("/projects/3/merge_requests/2/changes")).to have_been_made
142 end
143
144 it "should return the merge request changes" do
145 expect(@mr_changes.changes).to be_a Array
146 expect(@mr_changes.changes.first['old_path']).to eq('lib/omniauth/builder.rb')
147 expect(@mr_changes.id).to eq(2)
148 expect(@mr_changes.project_id).to eq(3)
149 expect(@mr_changes.source_branch).to eq('uncovered')
150 expect(@mr_changes.target_branch).to eq('master')
151 end
152 end
153
154 describe ".merge_request_commits" do
155 before do
156 stub_get("/projects/3/merge_requests/2/commits", "merge_request_commits")
157 @mr_commits = Gitlab.merge_request_commits(3, 2)
158 end
159
160 it "should get the correct resource" do
161 expect(a_get("/projects/3/merge_requests/2/commits")).to have_been_made
162 end
163
164 it "should return the merge request commits" do
165 expect(@mr_commits).to be_a Gitlab::PaginatedResponse
166 expect(@mr_commits.size).to eq 2
167 expect(@mr_commits.first.id).to eq "a2da7552f26d5b46a6a09bb8b7b066e3a102be7d"
168 expect(@mr_commits.first.short_id).to eq "a2da7552"
169 expect(@mr_commits.first.title).to eq "piyo"
170 expect(@mr_commits.first.author_name).to eq "example"
171 expect(@mr_commits.first.author_email).to eq "example@example.com"
172 expect(@mr_commits[1].short_id).to eq "3ce50959"
173 expect(@mr_commits[1].title).to eq "hoge"
174 end
175 end
176
177 describe ".merge_request_closes_issues" do
178 before do
179 stub_get("/projects/5/merge_requests/1/closes_issues", "merge_request_closes_issues")
180 @issues = Gitlab.merge_request_closes_issues(5, 1)
181 end
182
183 it "should get the correct resource" do
184 expect(a_get("/projects/5/merge_requests/1/closes_issues")).to have_been_made
185 end
186
187 it "should return a paginated response of the issues the merge_request will close" do
188 expect(@issues).to be_a(Gitlab::PaginatedResponse)
189 expect(@issues.first.title).to eq("Merge request 1 issue 1")
190 expect(@issues.size).to eq(2)
191 end
192 end
193
194 describe ".subscribe_to_merge_request" do
195 before do
196 stub_post("/projects/3/merge_requests/2/subscribe", "merge_request")
197 @merge_request = Gitlab.subscribe_to_merge_request(3, 2)
198 end
199
200 it "should get the correct resource" do
201 expect(a_post("/projects/3/merge_requests/2/subscribe")).to have_been_made
202 end
203
204 it "should return information about a merge request" do
205 expect(@merge_request.project_id).to eq(3)
206 end
207 end
208
209 describe ".unsubscribe_from_merge_request" do
210 before do
211 stub_post("/projects/3/merge_requests/2/unsubscribe", "merge_request")
212 @merge_request = Gitlab.unsubscribe_from_merge_request(3, 2)
213 end
214
215 it "should get the correct resource" do
216 expect(a_post("/projects/3/merge_requests/2/unsubscribe")).to have_been_made
217 end
218
219 it "should return information about a merge request" do
220 expect(@merge_request.project_id).to eq(3)
221 end
222 end
223 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".milestones" do
4 before do
5 stub_get("/projects/3/milestones", "milestones")
6 @milestones = Gitlab.milestones(3)
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/projects/3/milestones")).to have_been_made
11 end
12
13 it "should return a paginated response of project's milestones" do
14 expect(@milestones).to be_a Gitlab::PaginatedResponse
15 expect(@milestones.first.project_id).to eq(3)
16 end
17 end
18
19 describe ".milestone" do
20 before do
21 stub_get("/projects/3/milestones/1", "milestone")
22 @milestone = Gitlab.milestone(3, 1)
23 end
24
25 it "should get the correct resource" do
26 expect(a_get("/projects/3/milestones/1")).to have_been_made
27 end
28
29 it "should return information about a milestone" do
30 expect(@milestone.project_id).to eq(3)
31 end
32 end
33
34 describe ".milestone_issues" do
35 before do
36 stub_get("/projects/3/milestones/1/issues", "milestone_issues")
37 @milestone_issues = Gitlab.milestone_issues(3, 1)
38 end
39
40 it "should get the correct resource" do
41 expect(a_get("/projects/3/milestones/1/issues")).to have_been_made
42 end
43
44 it "should return a paginated response of milestone's issues" do
45 expect(@milestone_issues).to be_a Gitlab::PaginatedResponse
46 expect(@milestone_issues.first.milestone.id).to eq(1)
47 end
48 end
49
50 describe ".milestone_merge_requests" do
51 before do
52 stub_get("/projects/3/milestones/1/merge_requests", "milestone_merge_requests")
53 @milestone_merge_requests = Gitlab.milestone_merge_requests(3, 1)
54 end
55
56 it "should get the correct resource" do
57 expect(a_get("/projects/3/milestones/1/merge_requests")).to have_been_made
58 end
59
60 it "should return a paginated response of milestone's merge_requests" do
61 expect(@milestone_merge_requests).to be_a Gitlab::PaginatedResponse
62 expect(@milestone_merge_requests.first.milestone.id).to eq(1)
63 end
64 end
65
66 describe ".create_milestone" do
67 before do
68 stub_post("/projects/3/milestones", "milestone")
69 @milestone = Gitlab.create_milestone(3, 'title')
70 end
71
72 it "should get the correct resource" do
73 expect(a_post("/projects/3/milestones").
74 with(body: { title: 'title' })).to have_been_made
75 end
76
77 it "should return information about a created milestone" do
78 expect(@milestone.project_id).to eq(3)
79 end
80 end
81
82 describe ".edit_milestone" do
83 before do
84 stub_put("/projects/3/milestones/33", "milestone")
85 @milestone = Gitlab.edit_milestone(3, 33, title: 'title')
86 end
87
88 it "should get the correct resource" do
89 expect(a_put("/projects/3/milestones/33").
90 with(body: { title: 'title' })).to have_been_made
91 end
92
93 it "should return information about an edited milestone" do
94 expect(@milestone.project_id).to eq(3)
95 end
96 end
97 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 it { should respond_to :namespaces }
4
5 describe ".namespaces" do
6 before do
7 stub_get("/namespaces", "namespaces")
8 @namespaces = Gitlab.namespaces
9 end
10
11 it "should get the correct resource" do
12 expect(a_get("/namespaces")).to have_been_made
13 end
14
15 it "should return a paginated response of namespaces" do
16 expect(@namespaces).to be_a Gitlab::PaginatedResponse
17 expect(@namespaces.first.path).to eq("john")
18 expect(@namespaces.first.kind).to eq("user")
19 end
20 end
21 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe "notes" do
4 context "when wall notes" do
5 before do
6 stub_get("/projects/3/notes", "notes")
7 @notes = Gitlab.notes(3)
8 end
9
10 it "should get the correct resource" do
11 expect(a_get("/projects/3/notes")).to have_been_made
12 end
13
14 it "should return a paginated response of notes" do
15 expect(@notes).to be_a Gitlab::PaginatedResponse
16 expect(@notes.first.author.name).to eq("John Smith")
17 end
18 end
19
20 context "when issue notes" do
21 before do
22 stub_get("/projects/3/issues/7/notes", "notes")
23 @notes = Gitlab.issue_notes(3, 7)
24 end
25
26 it "should get the correct resource" do
27 expect(a_get("/projects/3/issues/7/notes")).to have_been_made
28 end
29
30 it "should return a paginated response of notes" do
31 expect(@notes).to be_a Gitlab::PaginatedResponse
32 expect(@notes.first.author.name).to eq("John Smith")
33 end
34 end
35
36 context "when snippet notes" do
37 before do
38 stub_get("/projects/3/snippets/7/notes", "notes")
39 @notes = Gitlab.snippet_notes(3, 7)
40 end
41
42 it "should get the correct resource" do
43 expect(a_get("/projects/3/snippets/7/notes")).to have_been_made
44 end
45
46 it "should return a paginated response of notes" do
47 expect(@notes).to be_a Gitlab::PaginatedResponse
48 expect(@notes.first.author.name).to eq("John Smith")
49 end
50 end
51
52 context "when merge_request notes" do
53 before do
54 stub_get("/projects/3/merge_requests/7/notes", "notes")
55 @notes = Gitlab.merge_request_notes(3, 7)
56 end
57
58 it "should get the correct resource" do
59 expect(a_get("/projects/3/merge_requests/7/notes")).to have_been_made
60 end
61
62 it "should return a paginated response of notes" do
63 expect(@notes).to be_a Gitlab::PaginatedResponse
64 expect(@notes.first.author.name).to eq("John Smith")
65 end
66 end
67 end
68
69 describe "note" do
70 context "when wall note" do
71 before do
72 stub_get("/projects/3/notes/1201", "note")
73 @note = Gitlab.note(3, 1201)
74 end
75
76 it "should get the correct resource" do
77 expect(a_get("/projects/3/notes/1201")).to have_been_made
78 end
79
80 it "should return information about a note" do
81 expect(@note.body).to eq("The solution is rather tricky")
82 expect(@note.author.name).to eq("John Smith")
83 end
84 end
85
86 context "when issue note" do
87 before do
88 stub_get("/projects/3/issues/7/notes/1201", "note")
89 @note = Gitlab.issue_note(3, 7, 1201)
90 end
91
92 it "should get the correct resource" do
93 expect(a_get("/projects/3/issues/7/notes/1201")).to have_been_made
94 end
95
96 it "should return information about a note" do
97 expect(@note.body).to eq("The solution is rather tricky")
98 expect(@note.author.name).to eq("John Smith")
99 end
100 end
101
102 context "when snippet note" do
103 before do
104 stub_get("/projects/3/snippets/7/notes/1201", "note")
105 @note = Gitlab.snippet_note(3, 7, 1201)
106 end
107
108 it "should get the correct resource" do
109 expect(a_get("/projects/3/snippets/7/notes/1201")).to have_been_made
110 end
111
112 it "should return information about a note" do
113 expect(@note.body).to eq("The solution is rather tricky")
114 expect(@note.author.name).to eq("John Smith")
115 end
116 end
117
118 context "when merge request note" do
119 before do
120 stub_get("/projects/3/merge_requests/7/notes/1201", "note")
121 @note = Gitlab.merge_request_note(3, 7, 1201)
122 end
123
124 it "should get the correct resource" do
125 expect(a_get("/projects/3/merge_requests/7/notes/1201")).to have_been_made
126 end
127
128 it "should return information about a note" do
129 expect(@note.body).to eq("The solution is rather tricky")
130 expect(@note.author.name).to eq("John Smith")
131 end
132 end
133 end
134
135 describe "create note" do
136 context "when wall note" do
137 before do
138 stub_post("/projects/3/notes", "note")
139 @note = Gitlab.create_note(3, "The solution is rather tricky")
140 end
141
142 it "should get the correct resource" do
143 expect(a_post("/projects/3/notes").
144 with(body: { body: 'The solution is rather tricky' })).to have_been_made
145 end
146
147 it "should return information about a created note" do
148 expect(@note.body).to eq("The solution is rather tricky")
149 expect(@note.author.name).to eq("John Smith")
150 end
151 end
152
153 context "when issue note" do
154 before do
155 stub_post("/projects/3/issues/7/notes", "note")
156 @note = Gitlab.create_issue_note(3, 7, "The solution is rather tricky")
157 end
158
159 it "should get the correct resource" do
160 expect(a_post("/projects/3/issues/7/notes").
161 with(body: { body: 'The solution is rather tricky' })).to have_been_made
162 end
163
164 it "should return information about a created note" do
165 expect(@note.body).to eq("The solution is rather tricky")
166 expect(@note.author.name).to eq("John Smith")
167 end
168 end
169
170 context "when snippet note" do
171 before do
172 stub_post("/projects/3/snippets/7/notes", "note")
173 @note = Gitlab.create_snippet_note(3, 7, "The solution is rather tricky")
174 end
175
176 it "should get the correct resource" do
177 expect(a_post("/projects/3/snippets/7/notes").
178 with(body: { body: 'The solution is rather tricky' })).to have_been_made
179 end
180
181 it "should return information about a created note" do
182 expect(@note.body).to eq("The solution is rather tricky")
183 expect(@note.author.name).to eq("John Smith")
184 end
185 end
186
187 context "when merge_request note" do
188 before do
189 stub_post("/projects/3/merge_requests/7/notes", "note")
190 @note = Gitlab.create_merge_request_note(3, 7, "The solution is rather tricky")
191 end
192
193 it "should get the correct resource" do
194 expect(a_post("/projects/3/merge_requests/7/notes").
195 with(body: { body: 'The solution is rather tricky' })).to have_been_made
196 end
197
198 it "should return information about a created note" do
199 expect(@note.body).to eq("The solution is rather tricky")
200 expect(@note.author.name).to eq("John Smith")
201 end
202 end
203 end
204 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 it { should respond_to :delete_trigger }
4
5 describe ".triggers" do
6 before do
7 stub_get("/projects/3/triggers", "triggers")
8 @triggers = Gitlab.triggers(3)
9 end
10
11 it "should get the correct resource" do
12 expect(a_get("/projects/3/triggers")).to have_been_made
13 end
14
15 it "should return an array of project's triggers" do
16 expect(@triggers).to be_a Gitlab::PaginatedResponse
17 expect(@triggers.first.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
18 end
19 end
20
21 describe ".trigger" do
22 before do
23 stub_get("/projects/3/triggers/10", "trigger")
24 @trigger = Gitlab.trigger(3, 10)
25 end
26
27 it "should get the correct resource" do
28 expect(a_get("/projects/3/triggers/10")).to have_been_made
29 end
30
31 it "should return information about a trigger" do
32 expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
33 expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
34 end
35 end
36
37 describe ".create_trigger" do
38 before do
39 stub_post("/projects/3/triggers", "trigger")
40 @trigger = Gitlab.create_trigger(3, "my description")
41 end
42
43 it "should get the correct resource" do
44 expect(a_post("/projects/3/triggers").
45 with(body: { description: "my description" })).to have_been_made
46 end
47
48 it "should return information about a new trigger" do
49 expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
50 expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
51 end
52 end
53
54 describe ".update_trigger" do
55 before do
56 stub_put("/projects/3/triggers/1", "trigger")
57 @trigger = Gitlab.update_trigger(3, 1, description: "my description")
58 end
59
60 it "should get the correct resource" do
61 expect(a_put("/projects/3/triggers/1").
62 with(body: { description: "my description" })).to have_been_made
63 end
64
65 it "should return information about the trigger" do
66 expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
67 expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
68 end
69 end
70
71 describe ".trigger_take_ownership" do
72 before do
73 stub_post("/projects/3/triggers/1/take_ownership", "trigger")
74 @trigger = Gitlab.trigger_take_ownership(3, 1)
75 end
76
77 it "should get the correct resource" do
78 expect(a_post("/projects/3/triggers/1/take_ownership")).to have_been_made
79 end
80
81 it "should return information about the trigger" do
82 expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
83 expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
84 end
85 end
86
87 describe ".remove_trigger" do
88 before do
89 stub_delete("/projects/3/triggers/10", "empty")
90 @trigger = Gitlab.remove_trigger(3, 10)
91 end
92
93 it "should get the correct resource" do
94 expect(a_delete("/projects/3/triggers/10")).to have_been_made
95 end
96 end
97
98 describe ".run_trigger" do
99 before do
100 stub_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline").
101 to_return(body: load_fixture("run_trigger"), status: 200)
102 end
103
104 context "when private_token is not set" do
105 before do
106 Gitlab.private_token = nil
107 end
108
109 it "should not raise Error::MissingCredentials" do
110 expect { Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master", {a: 10}) }.to_not raise_error
111 end
112
113 after do
114 Gitlab.private_token = 'secret'
115 end
116 end
117
118 context "without variables" do
119 before do
120 @trigger = Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master")
121 end
122
123 it "should get the correct resource" do
124 expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline").
125 with(body: {
126 token: "7b9148c158980bbd9bcea92c17522d",
127 ref: "master"
128 })).to have_been_made
129 end
130
131 it "should return information about the triggered build" do
132 expect(@trigger.id).to eq(8)
133 end
134 end
135
136 context "with variables" do
137 before do
138 @trigger = Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master", {a: 10})
139 end
140
141 it "should get the correct resource" do
142 expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline").
143 with(body: {
144 token: "7b9148c158980bbd9bcea92c17522d",
145 ref: "master",
146 variables: {a: "10"}
147 })).to have_been_made
148 end
149
150 it "should return information about the triggered build" do
151 expect(@trigger.id).to eq(8)
152 expect(@trigger.variables.a).to eq("10")
153 end
154 end
155 end
156 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".pipelines" do
4 before do
5 stub_get("/projects/3/pipelines", "pipelines")
6 @pipelines = Gitlab.pipelines(3)
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/projects/3/pipelines")).to have_been_made
11 end
12
13 it "should return a paginated response of project's pipelines" do
14 expect(@pipelines).to be_a Gitlab::PaginatedResponse
15 end
16 end
17
18 describe ".pipeline" do
19 before do
20 stub_get("/projects/3/pipelines/46", "pipeline")
21 @pipeline = Gitlab.pipeline(3, 46)
22 end
23
24 it "should get the correct resource" do
25 expect(a_get("/projects/3/pipelines/46")).to have_been_made
26 end
27
28 it "should return a single pipeline" do
29 expect(@pipeline).to be_a Gitlab::ObjectifiedHash
30 end
31
32 it "should return information about a pipeline" do
33 expect(@pipeline.id).to eq(46)
34 expect(@pipeline.user.name).to eq("Administrator")
35 end
36 end
37
38 describe ".create_pipeline" do
39 before do
40 stub_post("/projects/3/pipeline?ref=master", "pipeline_create")
41 @pipeline_create = Gitlab.create_pipeline(3, 'master')
42 end
43
44 it "should get the correct resource" do
45 expect(a_post("/projects/3/pipeline?ref=master")).to have_been_made
46 end
47
48 it "should return a single pipeline" do
49 expect(@pipeline_create).to be_a Gitlab::ObjectifiedHash
50 end
51
52 it "should return information about a pipeline" do
53 expect(@pipeline_create.user.name).to eq("Administrator")
54 end
55 end
56
57 describe ".cancel_pipeline" do
58 before do
59 stub_post("/projects/3/pipelines/46/cancel", "pipeline_cancel")
60 @pipeline_cancel = Gitlab.cancel_pipeline(3, 46)
61 end
62
63 it "should get the correct resource" do
64 expect(a_post("/projects/3/pipelines/46/cancel")).to have_been_made
65 end
66
67 it "should return a single pipeline" do
68 expect(@pipeline_cancel).to be_a Gitlab::ObjectifiedHash
69 end
70
71 it "should return information about a pipeline" do
72 expect(@pipeline_cancel.user.name).to eq("Administrator")
73 end
74 end
75
76 describe ".retry_pipeline" do
77 before do
78 stub_post("/projects/3/pipelines/46/retry", "pipeline_retry")
79 @pipeline_retry = Gitlab.retry_pipeline(3, 46)
80 end
81
82 it "should get the correct resource" do
83 expect(a_post("/projects/3/pipelines/46/retry")).to have_been_made
84 end
85
86 it "should return a single pipeline" do
87 expect(@pipeline_retry).to be_a Gitlab::ObjectifiedHash
88 end
89
90 it "should return information about a pipeline" do
91 expect(@pipeline_retry.user.name).to eq("Administrator")
92 end
93 end
94 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 it { should respond_to :search_projects }
4
5 describe ".projects" do
6 before do
7 stub_get("/projects", "projects")
8 @projects = Gitlab.projects
9 end
10
11 it "should get the correct resource" do
12 expect(a_get("/projects")).to have_been_made
13 end
14
15 it "should return a paginated response of projects" do
16 expect(@projects).to be_a Gitlab::PaginatedResponse
17 expect(@projects.first.name).to eq("Brute")
18 expect(@projects.first.owner.name).to eq("John Smith")
19 end
20 end
21
22 describe ".project_search" do
23 before do
24 stub_get("/projects/search/Gitlab", "project_search")
25 @project_search = Gitlab.project_search("Gitlab")
26 end
27
28 it "should get the correct resource" do
29 expect(a_get("/projects/search/Gitlab")).to have_been_made
30 end
31
32 it "should return a paginated response of projects found" do
33 expect(@project_search).to be_a Gitlab::PaginatedResponse
34 expect(@project_search.first.name).to eq("Gitlab")
35 expect(@project_search.first.owner.name).to eq("John Smith")
36 end
37 end
38
39 describe ".project" do
40 before do
41 stub_get("/projects/3", "project")
42 @project = Gitlab.project(3)
43 end
44
45 it "should get the correct resource" do
46 expect(a_get("/projects/3")).to have_been_made
47 end
48
49 it "should return information about a project" do
50 expect(@project.name).to eq("Gitlab")
51 expect(@project.owner.name).to eq("John Smith")
52 end
53 end
54
55 describe ".project_events" do
56 before do
57 stub_get("/projects/2/events", "project_events")
58 @events = Gitlab.project_events(2)
59 end
60
61 it "should get the correct resource" do
62 expect(a_get("/projects/2/events")).to have_been_made
63 end
64
65 it "should return a paginated response of events" do
66 expect(@events).to be_a Gitlab::PaginatedResponse
67 expect(@events.size).to eq(2)
68 end
69
70 it "should return the action name of the event" do
71 expect(@events.first.action_name).to eq("opened")
72 end
73 end
74
75 describe ".create_project" do
76 before do
77 stub_post("/projects", "project")
78 @project = Gitlab.create_project('Gitlab')
79 end
80
81 it "should get the correct resource" do
82 expect(a_post("/projects")).to have_been_made
83 end
84
85 it "should return information about a created project" do
86 expect(@project.name).to eq("Gitlab")
87 expect(@project.owner.name).to eq("John Smith")
88 end
89 end
90
91 describe ".create_project for user" do
92 before do
93 stub_post("/users", "user")
94 @owner = Gitlab.create_user("john@example.com", "pass", name: 'John Owner')
95 stub_post("/projects/user/#{@owner.id}", "project_for_user")
96 @project = Gitlab.create_project('Brute', user_id: @owner.id)
97 end
98
99 it "should return information about a created project" do
100 expect(@project.name).to eq("Brute")
101 expect(@project.owner.name).to eq("John Owner")
102 end
103 end
104
105 describe ".delete_project" do
106 before do
107 stub_delete("/projects/Gitlab", "project")
108 @project = Gitlab.delete_project('Gitlab')
109 end
110
111 it "should get the correct resource" do
112 expect(a_delete("/projects/Gitlab")).to have_been_made
113 end
114
115 it "should return information about a deleted project" do
116 expect(@project.name).to eq("Gitlab")
117 expect(@project.owner.name).to eq("John Smith")
118 end
119 end
120
121 describe ".create_fork" do
122 context "without sudo option" do
123 before do
124 stub_post("/projects/3/fork", "project_fork")
125 @project = Gitlab.create_fork(3)
126 end
127
128 it "should post to the correct resource" do
129 expect(a_post("/projects/3/fork")).to have_been_made
130 end
131
132 it "should return information about the forked project" do
133 expect(@project.forked_from_project.id).to eq(3)
134 expect(@project.id).to eq(20)
135 end
136 end
137
138 context "with the sudo option" do
139 before do
140 stub_post("/projects/3/fork", "project_forked_for_user")
141 @sudoed_username = 'jack.smith'
142 @project = Gitlab.create_fork(3, sudo: @sudoed_username)
143 end
144
145 it "should post to the correct resource" do
146 expect(a_post("/projects/3/fork")).to have_been_made
147 end
148
149 it "should return information about the forked project" do
150 expect(@project.forked_from_project.id).to eq(3)
151 expect(@project.id).to eq(20)
152 expect(@project.owner.username).to eq(@sudoed_username)
153 end
154 end
155 end
156
157 describe ".team_members" do
158 before do
159 stub_get("/projects/3/members", "team_members")
160 @team_members = Gitlab.team_members(3)
161 end
162
163 it "should get the correct resource" do
164 expect(a_get("/projects/3/members")).to have_been_made
165 end
166
167 it "should return a paginated response of team members" do
168 expect(@team_members).to be_a Gitlab::PaginatedResponse
169 expect(@team_members.first.name).to eq("John Smith")
170 end
171 end
172
173 describe ".team_member" do
174 before do
175 stub_get("/projects/3/members/1", "team_member")
176 @team_member = Gitlab.team_member(3, 1)
177 end
178
179 it "should get the correct resource" do
180 expect(a_get("/projects/3/members/1")).to have_been_made
181 end
182
183 it "should return information about a team member" do
184 expect(@team_member.name).to eq("John Smith")
185 end
186 end
187
188 describe ".add_team_member" do
189 before do
190 stub_post("/projects/3/members", "team_member")
191 @team_member = Gitlab.add_team_member(3, 1, 40)
192 end
193
194 it "should get the correct resource" do
195 expect(a_post("/projects/3/members").
196 with(body: { user_id: '1', access_level: '40' })).to have_been_made
197 end
198
199 it "should return information about an added team member" do
200 expect(@team_member.name).to eq("John Smith")
201 end
202 end
203
204 describe ".edit_team_member" do
205 before do
206 stub_put("/projects/3/members/1", "team_member")
207 @team_member = Gitlab.edit_team_member(3, 1, 40)
208 end
209
210 it "should get the correct resource" do
211 expect(a_put("/projects/3/members/1").
212 with(body: { access_level: '40' })).to have_been_made
213 end
214
215 it "should return information about an edited team member" do
216 expect(@team_member.name).to eq("John Smith")
217 end
218 end
219
220 describe ".remove_team_member" do
221 before do
222 stub_delete("/projects/3/members/1", "team_member")
223 @team_member = Gitlab.remove_team_member(3, 1)
224 end
225
226 it "should get the correct resource" do
227 expect(a_delete("/projects/3/members/1")).to have_been_made
228 end
229
230 it "should return information about a removed team member" do
231 expect(@team_member.name).to eq("John Smith")
232 end
233 end
234
235 describe ".project_hooks" do
236 before do
237 stub_get("/projects/1/hooks", "project_hooks")
238 @hooks = Gitlab.project_hooks(1)
239 end
240
241 it "should get the correct resource" do
242 expect(a_get("/projects/1/hooks")).to have_been_made
243 end
244
245 it "should return a paginated response of hooks" do
246 expect(@hooks).to be_a Gitlab::PaginatedResponse
247 expect(@hooks.first.url).to eq("https://api.example.net/v1/webhooks/ci")
248 end
249 end
250
251 describe ".project_hook" do
252 before do
253 stub_get("/projects/1/hooks/1", "project_hook")
254 @hook = Gitlab.project_hook(1, 1)
255 end
256
257 it "should get the correct resource" do
258 expect(a_get("/projects/1/hooks/1")).to have_been_made
259 end
260
261 it "should return information about a hook" do
262 expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
263 end
264 end
265
266 describe ".add_project_hook" do
267 context "without specified events" do
268 before do
269 stub_post("/projects/1/hooks", "project_hook")
270 @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci")
271 end
272
273 it "should get the correct resource" do
274 body = { url: "https://api.example.net/v1/webhooks/ci" }
275 expect(a_post("/projects/1/hooks").with(body: body)).to have_been_made
276 end
277
278 it "should return information about an added hook" do
279 expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
280 end
281 end
282
283 context "with specified events" do
284 before do
285 stub_post("/projects/1/hooks", "project_hook")
286 @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci", push_events: true, merge_requests_events: true)
287 end
288
289 it "should get the correct resource" do
290 body = { url: "https://api.example.net/v1/webhooks/ci", push_events: "true", merge_requests_events: "true" }
291 expect(a_post("/projects/1/hooks").with(body: body)).to have_been_made
292 end
293
294 it "should return information about an added hook" do
295 expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
296 end
297 end
298 end
299
300 describe ".edit_project_hook" do
301 before do
302 stub_put("/projects/1/hooks/1", "project_hook")
303 @hook = Gitlab.edit_project_hook(1, 1, "https://api.example.net/v1/webhooks/ci")
304 end
305
306 it "should get the correct resource" do
307 body = { url: "https://api.example.net/v1/webhooks/ci" }
308 expect(a_put("/projects/1/hooks/1").with(body: body)).to have_been_made
309 end
310
311 it "should return information about an edited hook" do
312 expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
313 end
314 end
315
316 describe ".edit_project" do
317 before do
318 stub_put("/projects/3", "project_edit").with(query: { name: "Gitlab-edit" })
319 @edited_project = Gitlab.edit_project(3, name: "Gitlab-edit")
320 end
321
322 it "should get the correct resource" do
323 expect(a_put("/projects/3").with(query: { name: "Gitlab-edit" })).to have_been_made
324 end
325
326 it "should return information about an edited project" do
327 expect(@edited_project.name).to eq("Gitlab-edit")
328 end
329 end
330
331 describe ".delete_project_hook" do
332 context "when empty response" do
333 before do
334 stub_request(:delete, "#{Gitlab.endpoint}/projects/1/hooks/1").
335 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
336 to_return(body: '')
337 @hook = Gitlab.delete_project_hook(1, 1)
338 end
339
340 it "should get the correct resource" do
341 expect(a_delete("/projects/1/hooks/1")).to have_been_made
342 end
343
344 it "should return false" do
345 expect(@hook).to be(false)
346 end
347 end
348
349 context "when JSON response" do
350 before do
351 stub_delete("/projects/1/hooks/1", "project_hook")
352 @hook = Gitlab.delete_project_hook(1, 1)
353 end
354
355 it "should get the correct resource" do
356 expect(a_delete("/projects/1/hooks/1")).to have_been_made
357 end
358
359 it "should return information about a deleted hook" do
360 expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
361 end
362 end
363 end
364
365 describe ".push_rule" do
366 before do
367 stub_get("/projects/1/push_rule", "push_rule")
368 @push_rule = Gitlab.push_rule(1)
369 end
370
371 it "should get the correct resource" do
372 expect(a_get("/projects/1/push_rule")).to have_been_made
373 end
374
375 it "should return information about a push rule" do
376 expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
377 end
378 end
379
380 describe ".add_push_rule" do
381 before do
382 stub_post("/projects/1/push_rule", "push_rule")
383 @push_rule = Gitlab.add_push_rule(1, { deny_delete_tag: false, commit_message_regex: "\\b[A-Z]{3}-[0-9]+\\b" })
384 end
385
386 it "should get the correct resource" do
387 expect(a_post("/projects/1/push_rule")).to have_been_made
388 end
389
390 it "should return information about an added push rule" do
391 expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
392 end
393 end
394
395 describe ".edit_push_rule" do
396 before do
397 stub_put("/projects/1/push_rule", "push_rule")
398 @push_rule = Gitlab.edit_push_rule(1, { deny_delete_tag: false, commit_message_regex: "\\b[A-Z]{3}-[0-9]+\\b" })
399 end
400
401 it "should get the correct resource" do
402 expect(a_put("/projects/1/push_rule")).to have_been_made
403 end
404
405 it "should return information about an edited push rule" do
406 expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
407 end
408 end
409
410 describe ".delete_push_rule" do
411 context "when empty response" do
412 before do
413 stub_request(:delete, "#{Gitlab.endpoint}/projects/1/push_rule").
414 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
415 to_return(body: '')
416 @push_rule = Gitlab.delete_push_rule(1)
417 end
418
419 it "should get the correct resource" do
420 expect(a_delete("/projects/1/push_rule")).to have_been_made
421 end
422
423 it "should return false" do
424 expect(@push_rule).to be(false)
425 end
426 end
427
428 context "when JSON response" do
429 before do
430 stub_delete("/projects/1/push_rule", "push_rule")
431 @push_rule = Gitlab.delete_push_rule(1)
432 end
433
434 it "should get the correct resource" do
435 expect(a_delete("/projects/1/push_rule")).to have_been_made
436 end
437
438 it "should return information about a deleted push rule" do
439 expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b")
440 end
441 end
442 end
443
444 describe ".make_forked_from" do
445 before do
446 stub_post("/projects/42/fork/24", "project_fork_link")
447 @forked_project_link = Gitlab.make_forked_from(42, 24)
448 end
449
450 it "should get the correct resource" do
451 expect(a_post("/projects/42/fork/24")).to have_been_made
452 end
453
454 it "should return information about a forked project" do
455 expect(@forked_project_link.forked_from_project_id).to eq(24)
456 expect(@forked_project_link.forked_to_project_id).to eq(42)
457 end
458 end
459
460 describe ".remove_forked" do
461 before do
462 stub_delete("/projects/42/fork", "project_fork_link")
463 @forked_project_link = Gitlab.remove_forked(42)
464 end
465
466 it "should be sent to correct resource" do
467 expect(a_delete("/projects/42/fork")).to have_been_made
468 end
469
470 it "should return information about an unforked project" do
471 expect(@forked_project_link.forked_to_project_id).to eq(42)
472 end
473 end
474
475 describe ".deploy_keys" do
476 before do
477 stub_get("/projects/42/deploy_keys", "project_keys")
478 @deploy_keys = Gitlab.deploy_keys(42)
479 end
480
481 it "should get the correct resource" do
482 expect(a_get("/projects/42/deploy_keys")).to have_been_made
483 end
484
485 it "should return project deploy keys" do
486 expect(@deploy_keys).to be_a Gitlab::PaginatedResponse
487 expect(@deploy_keys.first.id).to eq 2
488 expect(@deploy_keys.first.title).to eq "Key Title"
489 expect(@deploy_keys.first.key).to match(/ssh-rsa/)
490 end
491 end
492
493 describe ".deploy_key" do
494 before do
495 stub_get("/projects/42/deploy_keys/2", "project_key")
496 @deploy_key = Gitlab.deploy_key(42, 2)
497 end
498
499 it "should get the correct resource" do
500 expect(a_get("/projects/42/deploy_keys/2")).to have_been_made
501 end
502
503 it "should return project deploy key" do
504 expect(@deploy_key.id).to eq 2
505 expect(@deploy_key.title).to eq "Key Title"
506 expect(@deploy_key.key).to match(/ssh-rsa/)
507 end
508 end
509
510 describe ".delete_deploy_key" do
511 before do
512 stub_delete("/projects/42/deploy_keys/2", "project_key")
513 @deploy_key = Gitlab.delete_deploy_key(42, 2)
514 end
515
516 it "should get the correct resource" do
517 expect(a_delete("/projects/42/deploy_keys/2")).to have_been_made
518 end
519
520 it "should return information about a deleted key" do
521 expect(@deploy_key.id).to eq(2)
522 end
523 end
524
525 describe ".enable_deploy_key" do
526 before do
527 stub_post("/projects/42/deploy_keys/2/enable", "project_key")
528 @deploy_key = Gitlab.enable_deploy_key(42, 2)
529 end
530
531 it "should get the correct resource" do
532 expect(a_post("/projects/42/deploy_keys/2/enable").
533 with(body: { id: '42', key_id: '2' })).to have_been_made
534 end
535
536 it "should return information about an enabled key" do
537 expect(@deploy_key.id).to eq(2)
538 end
539 end
540
541 describe ".disable_deploy_key" do
542 before do
543 stub_post("/projects/42/deploy_keys/2/disable", "project_key")
544 @deploy_key = Gitlab.disable_deploy_key(42, 2)
545 end
546
547 it "should get the correct resource" do
548 expect(a_post("/projects/42/deploy_keys/2/disable").
549 with(body: { id: '42', key_id: '2' })).to have_been_made
550 end
551
552 it "should return information about a disabled key" do
553 expect(@deploy_key.id).to eq(2)
554 end
555 end
556
557 describe ".share_project_with_group" do
558 before do
559 stub_post("/projects/3/share", "group")
560 @group = Gitlab.share_project_with_group(3, 10, 40)
561 end
562
563 it "should get the correct resource" do
564 expect(a_post("/projects/3/share").
565 with(body: { group_id: '10', group_access: '40' })).to have_been_made
566 end
567
568 it "should return information about an added group" do
569 expect(@group.id).to eq(10)
570 end
571 end
572
573 describe ".star_project" do
574 before do
575 stub_post("/projects/3/star", "project_star")
576 @starred_project = Gitlab.star_project(3)
577 end
578
579 it "should get the correct resource" do
580 expect(a_post("/projects/3/star")).to have_been_made
581 end
582
583 it "should return information about the starred project" do
584 expect(@starred_project.id).to eq(3)
585 end
586 end
587
588 describe ".unstar_project" do
589 before do
590 stub_delete("/projects/3/star", "project_unstar")
591 @unstarred_project = Gitlab.unstar_project(3)
592 end
593
594 it "should get the correct resource" do
595 expect(a_delete("/projects/3/star")).to have_been_made
596 end
597
598 it "should return information about the unstarred project" do
599 expect(@unstarred_project.id).to eq(3)
600 end
601 end
602 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 it { should respond_to :repo_tags }
4 it { should respond_to :repo_create_tag }
5 it { should respond_to :repo_branches }
6 it { should respond_to :repo_branch }
7 it { should respond_to :repo_tree }
8 it { should respond_to :repo_compare }
9
10 describe ".tags" do
11 before do
12 stub_get("/projects/3/repository/tags", "project_tags")
13 @tags = Gitlab.tags(3)
14 end
15
16 it "should get the correct resource" do
17 expect(a_get("/projects/3/repository/tags")).to have_been_made
18 end
19
20 it "should return a paginated response of repository tags" do
21 expect(@tags).to be_a Gitlab::PaginatedResponse
22 expect(@tags.first.name).to eq("v2.8.2")
23 end
24 end
25
26 describe ".create_tag" do
27 context "when lightweight" do
28 before do
29 stub_post("/projects/3/repository/tags", "project_tag_lightweight")
30 @tag = Gitlab.create_tag(3, 'v1.0.0', '2695effb5807a22ff3d138d593fd856244e155e7')
31 end
32
33 it "should get the correct resource" do
34 expect(a_post("/projects/3/repository/tags")).to have_been_made
35 end
36
37 it "should return information about a new repository tag" do
38 expect(@tag.name).to eq("v1.0.0")
39 expect(@tag.message).to eq(nil)
40 end
41 end
42
43 context "when annotated" do
44 before do
45 stub_post("/projects/3/repository/tags", "project_tag_annotated")
46 @tag = Gitlab.create_tag(3, 'v1.1.0', '2695effb5807a22ff3d138d593fd856244e155e7', 'Release 1.1.0')
47 end
48
49 it "should get the correct resource" do
50 expect(a_post("/projects/3/repository/tags")).to have_been_made
51 end
52
53 it "should return information about a new repository tag" do
54 expect(@tag.name).to eq("v1.1.0")
55 expect(@tag.message).to eq("Release 1.1.0")
56 end
57 end
58 end
59
60 describe ".tree" do
61 before do
62 stub_get("/projects/3/repository/tree", "tree")
63 @tree = Gitlab.tree(3)
64 end
65
66 it "should get the correct resource" do
67 expect(a_get("/projects/3/repository/tree")).to have_been_made
68 end
69
70 it "should return a paginated response of repository tree files (root level)" do
71 expect(@tree).to be_a Gitlab::PaginatedResponse
72 expect(@tree.first.name).to eq("app")
73 end
74 end
75
76 describe ".compare" do
77 before do
78 stub_get("/projects/3/repository/compare", "compare_merge_request_diff").
79 with(query: { from: "master", to: "feature" })
80 @diff = Gitlab.compare(3, 'master', 'feature')
81 end
82
83 it "should get the correct resource" do
84 expect(a_get("/projects/3/repository/compare").
85 with(query: { from: "master", to: "feature" })).to have_been_made
86 end
87
88 it "should get diffs of a merge request" do
89 expect(@diff.diffs).to be_kind_of Array
90 expect(@diff.diffs.last["new_path"]).to eq "files/js/application.js"
91 end
92 end
93 end
0 require "spec_helper"
1
2 describe Gitlab::Client do
3 describe ".file_contents" do
4 before do
5 stub_get("/projects/3/repository/files/Gemfile/raw?ref=master", "raw_file")
6 @file_contents = Gitlab.file_contents(3, "Gemfile")
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/projects/3/repository/files/Gemfile/raw?ref=master")).to have_been_made
11 end
12
13 it "should return file contents" do
14 expect(@file_contents).to eq("source 'https://rubygems.org'\ngem 'rails', '4.1.2'\n")
15 end
16 end
17
18 describe ".get_file" do
19 before do
20 stub_get("/projects/3/repository/files/README%2Emd?ref=master", "get_repository_file")
21 @file = Gitlab.get_file(3, 'README.md', 'master')
22 end
23
24 it "should create the correct resource" do
25 expect(a_get("/projects/3/repository/files/README%2Emd?ref=master")).to have_been_made
26 end
27
28 it "should return the base64 encoded file" do
29 expect(@file.file_path).to eq "README.md"
30 expect(@file.ref).to eq "master"
31 expect(@file.content).to eq "VGhpcyBpcyBhICpSRUFETUUqIQ==\n"
32 end
33 end
34
35 describe ".create_file" do
36 let!(:request_stub) { stub_post("/projects/3/repository/files", "repository_file") }
37 let!(:file) { Gitlab.create_file(3, "path", "branch", "content", "commit message") }
38
39 it "should create the correct resource" do
40 expect(request_stub).to have_been_made
41 end
42
43 it "should return information about the new file" do
44 expect(file.file_path).to eq "path"
45 expect(file.branch_name).to eq "branch"
46 end
47 end
48
49 describe ".edit_file" do
50 let!(:request_stub) { stub_put("/projects/3/repository/files", "repository_file") }
51 let!(:file) { Gitlab.edit_file(3, "path", "branch", "content", "commit message") }
52
53 it "should create the correct resource" do
54 expect(request_stub).to have_been_made
55 end
56
57 it "should return information about the new file" do
58 expect(file.file_path).to eq "path"
59 expect(file.branch_name).to eq "branch"
60 end
61 end
62
63 describe ".remove_file" do
64 let!(:request_stub) { stub_delete("/projects/3/repository/files", "repository_file") }
65 let!(:file) { Gitlab.remove_file(3, "path", "branch", "commit message") }
66
67 it "should create the correct resource" do
68 expect(request_stub).to have_been_made
69 end
70
71 it "should return information about the new file" do
72 expect(file.file_path).to eq "path"
73 expect(file.branch_name).to eq "branch"
74 end
75 end
76 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3
4 describe ".runners" do
5 before do
6 stub_get("/runners", "runners")
7 end
8
9 context 'without scope' do
10 before do
11 @runner = Gitlab.runners
12 end
13
14 it "should get the correct resource" do
15 expect(a_get("/runners")).to have_been_made
16 end
17
18 it "should return a paginated response of runners" do
19 expect(@runner).to be_a Gitlab::PaginatedResponse
20 expect(@runner.first.id).to eq(6)
21 expect(@runner.first.description).to eq('test-1-20150125')
22 end
23 end
24
25 context 'with scope' do
26 before do
27 stub_get("/runners?scope=online", "runners")
28 @runner = Gitlab.runners({scope: :online})
29 end
30
31 it "should get the correct resource" do
32 expect(a_get("/runners").with(query: { scope: :online })).to have_been_made
33 end
34
35 it "should return a paginated response of runners" do
36 expect(@runner).to be_a Gitlab::PaginatedResponse
37 expect(@runner.first.id).to eq(6)
38 expect(@runner.first.description).to eq('test-1-20150125')
39 end
40 end
41
42 end
43
44 describe ".all_runners" do
45 before do
46 stub_get("/runners/all", "runners")
47 end
48
49 context 'without scope' do
50 before do
51 @runner = Gitlab.all_runners
52 end
53
54 it "should get the correct resource" do
55 expect(a_get("/runners/all")).to have_been_made
56 end
57
58 it "should return a paginated response of runners" do
59 expect(@runner).to be_a Gitlab::PaginatedResponse
60 expect(@runner.first.id).to eq(6)
61 expect(@runner.first.description).to eq('test-1-20150125')
62 end
63 end
64
65 context 'with scope' do
66 before do
67 stub_get("/runners/all?scope=online", "runners")
68 @runner = Gitlab.all_runners({scope: :online})
69 end
70
71 it "should get the correct resource" do
72 expect(a_get("/runners/all").with(query: { scope: :online })).to have_been_made
73 end
74
75 it "should return a paginated response of runners" do
76 expect(@runner).to be_a Gitlab::PaginatedResponse
77 expect(@runner.first.id).to eq(6)
78 expect(@runner.first.description).to eq('test-1-20150125')
79 end
80 end
81 end
82
83 describe ".runner" do
84 before do
85 stub_get("/runners/6", "runner")
86 @runners = Gitlab.runner(6)
87 end
88
89 it "should get the correct resource" do
90 expect(a_get("/runners/6")).to have_been_made
91 end
92
93 it "should return a response of a runner" do
94 expect(@runners).to be_a Gitlab::ObjectifiedHash
95 expect(@runners.id).to eq(6)
96 expect(@runners.description).to eq('test-1-20150125')
97 end
98 end
99
100 describe ".update_runner" do
101 before do
102 stub_put("/runners/6", "runner_edit").with(query: { description: "abcefg" })
103 @runner = Gitlab.update_runner(6, description: "abcefg" )
104 end
105
106 it "should get the correct resource" do
107 expect(a_put("/runners/6").with(query: { description: "abcefg" })).to have_been_made
108 end
109
110 it "should return an updated response of a runner" do
111 expect(@runner).to be_a Gitlab::ObjectifiedHash
112 expect(@runner.description).to eq('abcefg')
113 end
114 end
115
116 describe ".delete_runner" do
117 before do
118 stub_delete("/runners/6", "runner_delete")
119 @runner = Gitlab.delete_runner(6)
120 end
121
122 it "should get the correct resource" do
123 expect(a_delete("/runners/6")).to have_been_made
124 end
125
126 it "should return a response of the deleted runner" do
127 expect(@runner).to be_a Gitlab::ObjectifiedHash
128 expect(@runner.id).to eq(6)
129 end
130 end
131
132 describe ".project_runners" do
133 before do
134 stub_get("/projects/1/runners", "project_runners")
135 @runners = Gitlab.project_runners(1)
136 end
137
138 it "should get the correct resource" do
139 expect(a_get("/projects/1/runners")).to have_been_made
140 end
141
142 it "should return a paginated response of runners" do
143 expect(@runners).to be_a Gitlab::PaginatedResponse
144 expect(@runners.first.id).to eq(8)
145 expect(@runners.first.description).to eq('test-2-20150125')
146 end
147 end
148
149 describe ".project_enable_runner" do
150 before do
151 stub_post("/projects/1/runners", "runner")
152 @runner = Gitlab.project_enable_runner(1, 6)
153 end
154
155 it "should get the correct resource" do
156 expect(a_post("/projects/1/runners")).to have_been_made
157 end
158
159 it "should return a response of the enabled runner" do
160 expect(@runner).to be_a Gitlab::ObjectifiedHash
161 expect(@runner.id).to eq(6)
162 expect(@runner.description).to eq('test-1-20150125')
163 end
164 end
165
166 describe ".project_disable_runner" do
167 before do
168 stub_delete("/projects/1/runners/6", "runner")
169 @runner = Gitlab.project_disable_runner(1, 6)
170 end
171
172 it "should get the correct resource" do
173 expect(a_delete("/projects/1/runners/6")).to have_been_made
174 end
175
176 it "should return a response of the disabled runner" do
177 expect(@runner).to be_a Gitlab::ObjectifiedHash
178 expect(@runner.id).to eq(6)
179 expect(@runner.description).to eq('test-1-20150125')
180 end
181 end
182
183
184 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".service" do
4 before do
5 stub_get("/projects/3/services/redmine", "service")
6 @service = Gitlab.service(3, :redmine)
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/projects/3/services/redmine")).to have_been_made
11 end
12
13 it "should return a information about a service of project" do
14 expect(@service.id).to eq 38
15 expect(@service.title).to eq("Redmine")
16 expect(@service.properties.project_url).to eq("https://example.com/projects/test_project/issue")
17 end
18 end
19
20 describe ".change_service" do
21 before do
22 stub_put("/projects/3/services/redmine", "service")
23 @service = Gitlab.change_service(3, :redmine, new_issue_url: 'https://example.com/projects/test_project/issues/new',
24 project_url: 'https://example.com/projects/test_project/issues',
25 issues_url: 'https://example.com/issues/:id')
26 end
27
28 it "should get the correct resource" do
29 body = {new_issue_url: 'https://example.com/projects/test_project/issues/new',
30 project_url: 'https://example.com/projects/test_project/issues',
31 issues_url: 'https://example.com/issues/:id'}
32 expect(a_put("/projects/3/services/redmine").with(body: body)).to have_been_made
33 end
34
35 it "should return information about a new service" do
36 expect(@service).to be_truthy
37 end
38 end
39
40 describe ".delete_servoce" do
41 before do
42 stub_delete("/projects/3/services/redmine", "service")
43 @service = Gitlab.delete_service(3, :redmine)
44 end
45
46 it "should get the correct resource" do
47 expect(a_delete("/projects/3/services/redmine")).to have_been_made
48 end
49
50 it "should return information about a deleted service" do
51 expect(@service).to be_truthy
52 end
53 end
54 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".snippets" do
4 before do
5 stub_get("/projects/3/snippets", "snippets")
6 @snippets = Gitlab.snippets(3)
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/projects/3/snippets")).to have_been_made
11 end
12
13 it "should return a paginated response of project's snippets" do
14 expect(@snippets).to be_a Gitlab::PaginatedResponse
15 expect(@snippets.first.file_name).to eq("mailer_test.rb")
16 end
17 end
18
19 describe ".snippet" do
20 before do
21 stub_get("/projects/3/snippets/1", "snippet")
22 @snippet = Gitlab.snippet(3, 1)
23 end
24
25 it "should get the correct resource" do
26 expect(a_get("/projects/3/snippets/1")).to have_been_made
27 end
28
29 it "should return information about a snippet" do
30 expect(@snippet.file_name).to eq("mailer_test.rb")
31 expect(@snippet.author.name).to eq("John Smith")
32 end
33 end
34
35 describe ".create_snippet" do
36 before do
37 stub_post("/projects/3/snippets", "snippet")
38 @snippet = Gitlab.create_snippet(3, title: 'API', file_name: 'api.rb', code: 'code')
39 end
40
41 it "should get the correct resource" do
42 body = { title: 'API', file_name: 'api.rb', code: 'code' }
43 expect(a_post("/projects/3/snippets").with(body: body)).to have_been_made
44 end
45
46 it "should return information about a new snippet" do
47 expect(@snippet.file_name).to eq("mailer_test.rb")
48 expect(@snippet.author.name).to eq("John Smith")
49 end
50 end
51
52 describe ".edit_snippet" do
53 before do
54 stub_put("/projects/3/snippets/1", "snippet")
55 @snippet = Gitlab.edit_snippet(3, 1, file_name: 'mailer_test.rb')
56 end
57
58 it "should get the correct resource" do
59 expect(a_put("/projects/3/snippets/1").
60 with(body: { file_name: 'mailer_test.rb' })).to have_been_made
61 end
62
63 it "should return information about an edited snippet" do
64 expect(@snippet.file_name).to eq("mailer_test.rb")
65 expect(@snippet.author.name).to eq("John Smith")
66 end
67 end
68
69 describe ".delete_snippet" do
70 before do
71 stub_delete("/projects/3/snippets/1", "snippet")
72 @snippet = Gitlab.delete_snippet(3, 1)
73 end
74
75 it "should get the correct resource" do
76 expect(a_delete("/projects/3/snippets/1")).to have_been_made
77 end
78
79 it "should return information about a deleted snippet" do
80 expect(@snippet.file_name).to eq("mailer_test.rb")
81 expect(@snippet.author.name).to eq("John Smith")
82 end
83 end
84
85 describe ".snippet_content" do
86 before do
87 stub_get("/projects/3/snippets/1/raw", "snippet_content")
88 @snippet_content = Gitlab.snippet_content(3, 1)
89 end
90
91 it "should get the correct resource" do
92 expect(a_get("/projects/3/snippets/1/raw")).to have_been_made
93 end
94
95 it "should return raw content of a snippet" do
96 expect(@snippet_content).to eq("#!/usr/bin/env ruby\n\nputs \"Cool snippet!\"\n")
97 end
98 end
99 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 it { should respond_to :system_hooks }
4 it { should respond_to :add_system_hook }
5 it { should respond_to :system_hook }
6 it { should respond_to :delete_system_hook }
7
8 describe ".hooks" do
9 before do
10 stub_get("/hooks", "system_hooks")
11 @hooks = Gitlab.hooks
12 end
13
14 it "should get the correct resource" do
15 expect(a_get("/hooks")).to have_been_made
16 end
17
18 it "should return a paginated response of system hooks" do
19 expect(@hooks).to be_a Gitlab::PaginatedResponse
20 expect(@hooks.first.url).to eq("http://example.com/hook")
21 end
22 end
23
24 describe ".add_hook" do
25 before do
26 stub_post("/hooks", "system_hook")
27 @hook = Gitlab.add_hook("http://example.com/hook")
28 end
29
30 it "should get the correct resource" do
31 expect(a_post("/hooks")).to have_been_made
32 end
33
34 it "should return information about a added system hook" do
35 expect(@hook.url).to eq("http://example.com/hook")
36 end
37 end
38
39 describe ".hook" do
40 before do
41 stub_get("/hooks/3", "system_hook")
42 @hook = Gitlab.hook(3)
43 end
44
45 it "should get the correct resource" do
46 expect(a_get("/hooks/3")).to have_been_made
47 end
48
49 it "should return information about a added system hook" do
50 expect(@hook.url).to eq("http://example.com/hook")
51 end
52 end
53
54 describe ".delete_hook" do
55 before do
56 stub_delete("/hooks/3", "system_hook")
57 @hook = Gitlab.delete_hook(3)
58 end
59
60 it "should get the correct resource" do
61 expect(a_delete("/hooks/3")).to have_been_made
62 end
63
64 it "should return information about a deleted system hook" do
65 expect(@hook.url).to eq("http://example.com/hook")
66 end
67 end
68 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 it { should respond_to :repo_tags }
4 it { should respond_to :repo_tag }
5 it { should respond_to :repo_create_tag }
6 it { should respond_to :repo_delete_tag }
7 it { should respond_to :repo_create_release }
8 it { should respond_to :repo_update_release }
9
10 describe '.tags' do
11 before do
12 stub_get("/projects/3/repository/tags", "tags")
13 @tags = Gitlab.tags(3)
14 end
15
16 it "should get the correct resource" do
17 expect(a_get("/projects/3/repository/tags")).to have_been_made
18 end
19
20 it "should return a paginated response of repository tags" do
21 expect(@tags).to be_a Gitlab::PaginatedResponse
22 expect(@tags.map(&:name)).to eq(%w[0.0.2 0.0.1])
23 end
24 end
25
26 describe ".tag" do
27 before do
28 stub_get("/projects/3/repository/tags/0.0.1", "tag")
29 @tag = Gitlab.tag(3, "0.0.1")
30 end
31
32 it "should get the correct resource" do
33 expect(a_get("/projects/3/repository/tags/0.0.1")).to have_been_made
34 end
35
36 it "should return information about a repository tag" do
37 expect(@tag.name).to eq("0.0.1")
38 end
39 end
40
41 describe ".create_tag" do
42 before do
43 stub_post("/projects/3/repository/tags", "tag_create")
44 @tag = Gitlab.create_tag(3, "0.0.1", "master", 'this tag is annotated', 'and it has release notes')
45 end
46
47 it "should get the correct resource" do
48 expect(a_post("/projects/3/repository/tags")).to have_been_made
49 end
50
51 it "should return information about a new repository tag" do
52 expect(@tag.name).to eq("0.0.1")
53 expect(@tag.message).to eq('this tag is annotated')
54 end
55
56 it "should return detailed information" do
57 expect(@tag.release.description).to eq('and it has release notes')
58 end
59 end
60
61 describe ".delete_tag" do
62 before do
63 stub_delete("/projects/3/repository/tags/0.0.1", "tag_delete")
64 @tag = Gitlab.delete_tag(3, "0.0.1")
65 end
66
67 it "should get the correct resource" do
68 expect(a_delete("/projects/3/repository/tags/0.0.1")).to have_been_made
69 end
70
71 it "should return information about the deleted repository tag" do
72 expect(@tag.tag_name).to eq("0.0.1")
73 end
74 end
75
76 describe ".create_release" do
77 before do
78 stub_post("/projects/3/repository/tags/0.0.1/release", "release_create")
79 @tag = Gitlab.create_release(3, "0.0.1", "Amazing release. Wow")
80 end
81
82 it "should get the correct resource" do
83 expect(a_post("/projects/3/repository/tags/0.0.1/release")).to have_been_made
84 end
85
86 it "should return information about the tag and the release" do
87 expect(@tag.tag_name).to eq("0.0.1")
88 expect(@tag.description).to eq("Amazing release. Wow")
89 end
90 end
91
92 describe ".update_release" do
93 before do
94 stub_put("/projects/3/repository/tags/0.0.1/release", "release_update")
95 @tag = Gitlab.update_release(3, "0.0.1", 'Amazing release. Wow')
96 end
97
98 it "should update the correct resource" do
99 expect(a_put("/projects/3/repository/tags/0.0.1/release")).to have_been_made
100 end
101
102 it "should return information about the tag" do
103 expect(@tag.tag_name).to eq("0.0.1")
104 expect(@tag.description).to eq('Amazing release. Wow')
105 end
106 end
107
108 end
0 require 'spec_helper'
1
2 describe Gitlab::Client do
3 describe ".users" do
4 before do
5 stub_get("/users", "users")
6 @users = Gitlab.users
7 end
8
9 it "should get the correct resource" do
10 expect(a_get("/users")).to have_been_made
11 end
12
13 it "should return a paginated response of users" do
14 expect(@users).to be_a Gitlab::PaginatedResponse
15 expect(@users.first.email).to eq("john@example.com")
16 end
17 end
18
19 describe ".user" do
20 context "with user ID passed" do
21 before do
22 stub_get("/users/1", "user")
23 @user = Gitlab.user(1)
24 end
25
26 it "should get the correct resource" do
27 expect(a_get("/users/1")).to have_been_made
28 end
29
30 it "should return information about a user" do
31 expect(@user.email).to eq("john@example.com")
32 end
33 end
34
35 context "without user ID passed" do
36 before do
37 stub_get("/user", "user")
38 @user = Gitlab.user
39 end
40
41 it "should get the correct resource" do
42 expect(a_get("/user")).to have_been_made
43 end
44
45 it "should return information about an authorized user" do
46 expect(@user.email).to eq("john@example.com")
47 end
48 end
49 end
50
51 describe ".create_user" do
52 context "when successful request" do
53 before do
54 stub_post("/users", "user")
55 @user = Gitlab.create_user("email", "pass")
56 end
57
58 it "should get the correct resource" do
59 body = { email: "email", password: "pass", name: "email" }
60 expect(a_post("/users").with(body: body)).to have_been_made
61 end
62
63 it "should return information about a created user" do
64 expect(@user.email).to eq("john@example.com")
65 end
66 end
67
68 context "when bad request" do
69 it "should throw an exception" do
70 stub_post("/users", "error_already_exists", 409)
71 expect do
72 Gitlab.create_user("email", "pass")
73 end.to raise_error(Gitlab::Error::Conflict, "Server responded with code 409, message: 409 Already exists. Request URI: #{Gitlab.endpoint}/users")
74 end
75 end
76 end
77
78 describe ".create_user_with_userame" do
79 context "when successful request" do
80 before do
81 stub_post("/users", "user")
82 @user = Gitlab.create_user("email", "pass", "username")
83 end
84
85 it "should get the correct resource" do
86 body = { email: "email", password: "pass", username: "username" }
87 expect(a_post("/users").with(body: body)).to have_been_made
88 end
89
90 it "should return information about a created user" do
91 expect(@user.email).to eq("john@example.com")
92 end
93 end
94
95 context "when bad request" do
96 it "should throw an exception" do
97 stub_post("/users", "error_already_exists", 409)
98 expect do
99 Gitlab.create_user("email", "pass", "username")
100 end.to raise_error(Gitlab::Error::Conflict, "Server responded with code 409, message: 409 Already exists. Request URI: #{Gitlab.endpoint}/users")
101 end
102 end
103 end
104
105 describe ".edit_user" do
106 before do
107 @options = { name: "Roberto" }
108 stub_put("/users/1", "user").with(body: @options)
109 @user = Gitlab.edit_user(1, @options)
110 end
111
112 it "should get the correct resource" do
113 expect(a_put("/users/1").with(body: @options)).to have_been_made
114 end
115 end
116
117 describe ".delete_user" do
118 before do
119 stub_delete("/users/1", "user")
120 @user = Gitlab.delete_user(1)
121 end
122
123 it "should get the correct resource" do
124 expect(a_delete("/users/1")).to have_been_made
125 end
126
127 it "should return information about a deleted user" do
128 expect(@user.email).to eq("john@example.com")
129 end
130 end
131
132 describe ".block_user" do
133 before do
134 stub_post("/users/1/block", "user_block_unblock")
135 @result = Gitlab.block_user(1)
136 end
137
138 it "should get the correct resource" do
139 expect(a_post("/users/1/block")).to have_been_made
140 end
141
142 it "should return boolean" do
143 expect(@result).to eq(true)
144 end
145 end
146
147 describe ".unblock_user" do
148 before do
149 stub_post("/users/1/unblock", "user_block_unblock")
150 @result = Gitlab.unblock_user(1)
151 end
152
153 it "should get the correct resource" do
154 expect(a_post("/users/1/unblock")).to have_been_made
155 end
156
157 it "should return boolean" do
158 expect(@result).to eq(true)
159 end
160 end
161
162 describe ".session" do
163 after do
164 Gitlab.endpoint = 'https://api.example.com'
165 Gitlab.private_token = 'secret'
166 end
167
168 before do
169 stub_request(:post, "#{Gitlab.endpoint}/session").
170 to_return(body: load_fixture('session'), status: 200)
171 @session = Gitlab.session("email", "pass")
172 end
173
174 context "when endpoint is not set" do
175 it "should raise Error::MissingCredentials" do
176 Gitlab.endpoint = nil
177 expect do
178 Gitlab.session("email", "pass")
179 end.to raise_error(Gitlab::Error::MissingCredentials, 'Please set an endpoint to API')
180 end
181 end
182
183 context "when private_token is not set" do
184 it "should not raise Error::MissingCredentials" do
185 Gitlab.private_token = nil
186 expect { Gitlab.session("email", "pass") }.to_not raise_error
187 end
188 end
189
190 context "when endpoint is set" do
191 it "should get the correct resource" do
192 expect(a_request(:post, "#{Gitlab.endpoint}/session")).to have_been_made
193 end
194
195 it "should return information about a created session" do
196 expect(@session.email).to eq("john@example.com")
197 expect(@session.private_token).to eq("qEsq1pt6HJPaNciie3MG")
198 end
199 end
200 end
201
202 describe ".ssh_keys" do
203 context "with user ID passed" do
204 before do
205 stub_get("/users/1/keys", "keys")
206 @keys = Gitlab.ssh_keys({ user_id: 1 })
207 end
208
209 it "should get the correct resource" do
210 expect(a_get("/users/1/keys")).to have_been_made
211 end
212
213 it "should return a paginated response of SSH keys" do
214 expect(@keys).to be_a Gitlab::PaginatedResponse
215 expect(@keys.first.title).to eq("narkoz@helium")
216 end
217 end
218
219 context "without user ID passed" do
220 before do
221 stub_get("/user/keys", "keys")
222 @keys = Gitlab.ssh_keys
223 end
224
225 it "should get the correct resource" do
226 expect(a_get("/user/keys")).to have_been_made
227 end
228
229 it "should return a paginated response of SSH keys" do
230 expect(@keys).to be_a Gitlab::PaginatedResponse
231 expect(@keys.first.title).to eq("narkoz@helium")
232 end
233 end
234 end
235
236 describe ".ssh_key" do
237 before do
238 stub_get("/user/keys/1", "key")
239 @key = Gitlab.ssh_key(1)
240 end
241
242 it "should get the correct resource" do
243 expect(a_get("/user/keys/1")).to have_been_made
244 end
245
246 it "should return information about an SSH key" do
247 expect(@key.title).to eq("narkoz@helium")
248 end
249 end
250
251 describe ".create_ssh_key" do
252 before do
253 stub_post("/user/keys", "key")
254 @key = Gitlab.create_ssh_key("title", "body")
255 end
256
257 it "should get the correct resource" do
258 body = { title: "title", key: "body" }
259 expect(a_post("/user/keys").with(body: body)).to have_been_made
260 end
261
262 it "should return information about a created SSH key" do
263 expect(@key.title).to eq("narkoz@helium")
264 end
265 end
266
267 describe ".delete_ssh_key" do
268 before do
269 stub_delete("/user/keys/1", "key")
270 @key = Gitlab.delete_ssh_key(1)
271 end
272
273 it "should get the correct resource" do
274 expect(a_delete("/user/keys/1")).to have_been_made
275 end
276
277 it "should return information about a deleted SSH key" do
278 expect(@key.title).to eq("narkoz@helium")
279 end
280 end
281
282 describe ".emails" do
283 describe "without user ID" do
284 before do
285 stub_get("/user/emails", "user_emails")
286 @emails = Gitlab.emails
287 end
288
289 it "should get the correct resource" do
290 expect(a_get("/user/emails")).to have_been_made
291 end
292
293 it "should return a information about a emails of user" do
294 email = @emails.first
295 expect(email.id).to eq 1
296 expect(email.email).to eq("email@example.com")
297 end
298 end
299
300 describe "with user ID" do
301 before do
302 stub_get("/users/2/emails", "user_emails")
303 @emails = Gitlab.emails(2)
304 end
305
306 it "should get the correct resource" do
307 expect(a_get("/users/2/emails")).to have_been_made
308 end
309
310 it "should return a information about a emails of user" do
311 email = @emails.first
312 expect(email.id).to eq 1
313 expect(email.email).to eq("email@example.com")
314 end
315 end
316 end
317
318 describe ".email" do
319 before do
320 stub_get("/user/emails/2", "user_email")
321 @email = Gitlab.email(2)
322 end
323
324 it "should get the correct resource" do
325 expect(a_get("/user/emails/2")).to have_been_made
326 end
327
328 it "should return a information about a email of user" do
329 expect(@email.id).to eq 1
330 expect(@email.email).to eq("email@example.com")
331 end
332 end
333
334 describe ".add_email" do
335 describe "without user ID" do
336 before do
337 stub_post("/user/emails", "user_email")
338 @email = Gitlab.add_email("email@example.com")
339 end
340
341 it "should get the correct resource" do
342 body = { email: "email@example.com" }
343 expect(a_post("/user/emails").with(body: body)).to have_been_made
344 end
345
346 it "should return information about a new email" do
347 expect(@email.id).to eq(1)
348 expect(@email.email).to eq("email@example.com")
349 end
350 end
351
352 describe "with user ID" do
353 before do
354 stub_post("/users/2/emails", "user_email")
355 @email = Gitlab.add_email("email@example.com", 2)
356 end
357
358 it "should get the correct resource" do
359 body = { email: "email@example.com" }
360 expect(a_post("/users/2/emails").with(body: body)).to have_been_made
361 end
362
363 it "should return information about a new email" do
364 expect(@email.id).to eq(1)
365 expect(@email.email).to eq("email@example.com")
366 end
367 end
368 end
369
370 describe ".delete_email" do
371 describe "without user ID" do
372 before do
373 stub_delete("/user/emails/1", "user_email")
374 @email = Gitlab.delete_email(1)
375 end
376
377 it "should get the correct resource" do
378 expect(a_delete("/user/emails/1")).to have_been_made
379 end
380
381 it "should return information about a deleted email" do
382 expect(@email).to be_truthy
383 end
384 end
385
386 describe "with user ID" do
387 before do
388 stub_delete("/users/2/emails/1", "user_email")
389 @email = Gitlab.delete_email(1, 2)
390 end
391
392 it "should get the correct resource" do
393 expect(a_delete("/users/2/emails/1")).to have_been_made
394 end
395
396 it "should return information about a deleted email" do
397 expect(@email).to be_truthy
398 end
399 end
400 end
401
402 describe ".user_search" do
403 before do
404 stub_get("/users?search=User", "user_search")
405 @users = Gitlab.user_search('User')
406 end
407
408 it "should get the correct resource" do
409 expect(a_get("/users?search=User")).to have_been_made
410 end
411
412 it "should return an array of users found" do
413 expect(@users.first.id).to eq(1)
414 expect(@users.last.id).to eq(2)
415 end
416 end
417 end
0 require "spec_helper"
1
2 describe Gitlab::Error do
3 describe "#handle_message" do
4 require "stringio"
5
6 before do
7 request_object = HTTParty::Request.new(Net::HTTP::Get, '/')
8 response_object = Net::HTTPOK.new('1.1', 200, 'OK')
9 body = StringIO.new("{foo:'bar'}")
10 def body.message; self.string; end
11
12 parsed_response = lambda { body }
13 response_object['last-modified'] = Date.new(2010, 1, 15).to_s
14 response_object['content-length'] = "1024"
15
16 response = HTTParty::Response.new(request_object, response_object, parsed_response, body: body)
17 @error = Gitlab::Error::ResponseError.new(response)
18
19 @array = Array.new(['First message.', 'Second message.'])
20 @obj_h = Gitlab::ObjectifiedHash.new(user: ['not set'],
21 password: ['too short'],
22 embed_entity: { foo: ['bar'], sna: ['fu'] })
23 end
24
25 context "when passed an ObjectifiedHash" do
26 it "should return a joined string of error messages sorted by key" do
27 expect(@error.send(:handle_message, @obj_h)).to eq("'embed_entity' (foo: bar) (sna: fu), 'password' too short, 'user' not set")
28 end
29 end
30
31 context "when passed an Array" do
32 it "should return a joined string of messages" do
33 expect(@error.send(:handle_message, @array)).to eq("First message. Second message.")
34 end
35 end
36
37 context "when passed a String" do
38 it "should return the String untouched" do
39 error = 'this is an error string'
40 expect(@error.send(:handle_message, error)).to eq('this is an error string')
41 end
42 end
43 end
44 end
0 require 'spec_helper'
1
2 describe Gitlab::FileResponse do
3 before do
4 @file_response = Gitlab::FileResponse.new StringIO.new("", 'rb+')
5 end
6
7 context '.empty?' do
8 it "shoudl return false" do
9 expect(@file_response.empty?).to be false
10 end
11 end
12
13 context '.to_hash' do
14 it "should have `filename` key and `data` key" do
15 h = @file_response.to_hash
16 expect(h.has_key?(:filename)).to be_truthy
17 expect(h.has_key?(:data)).to be_truthy
18 end
19 end
20
21 context '.parse_headers!' do
22 it "should parse headers" do
23 @file_response.parse_headers!('Content-Disposition' => 'attachment; filename=artifacts.zip')
24 expect(@file_response.filename).to eq "artifacts.zip"
25 end
26
27 it "should handle quoted filenames" do
28 @file_response.parse_headers!('Content-Disposition' => 'attachment; filename="artifacts.zip"')
29 expect(@file_response.filename).to eq "artifacts.zip"
30 end
31 end
32 end
0 require 'spec_helper'
1
2 describe Gitlab::Help do
3 describe ".ri_cmd" do
4 context "ri command found" do
5 it "should return the path to RI" do
6 allow(Gitlab::Help).to receive(:`).with(/which ri/).and_return('/usr/bin/ri')
7 expect(Gitlab::Help.ri_cmd).to eq('/usr/bin/ri')
8 end
9 end
10
11 context "ri command NOT found" do
12 it "should raise" do
13 allow(Gitlab::Help).to receive(:`).with(/which ri/).and_return('')
14 expect { Gitlab::Help.ri_cmd }.to raise_error RuntimeError
15 end
16 end
17 end
18
19 describe ".change_help_output!" do
20 before do
21 @cmd = "create_branch"
22 @help_output = "Gitlab.#{@cmd}(4, 'new-branch', 'master')"
23 @help_output_with_options = "Gitlab.groups({ per_page: 3 })"
24 end
25 it "should return a String of modified output" do
26 Gitlab::Help.change_help_output! @cmd, @help_output
27 expect(@help_output).to eq("Gitlab.create_branch 4 'new-branch' 'master'")
28 end
29 it "should format options hash and return a String of modified output" do
30 Gitlab::Help.change_help_output! 'groups', @help_output_with_options
31 expect(@help_output_with_options).to eq("Gitlab.groups \"{ per_page: 3 }\"")
32 end
33 end
34
35 describe ".namespace" do
36 before do
37 @cmd = 'create_tag'
38 @namespace = Gitlab::Help.namespace @cmd
39 end
40 it "should return the full namespace for a command" do
41 expect(@namespace).to be_a String
42 expect(@namespace).to eq("Gitlab::Client::Tags.#{@cmd}")
43 end
44 end
45 end
0 require 'spec_helper'
1
2 describe Gitlab::ObjectifiedHash do
3 before do
4 @hash = { a: 1, b: 2, 'string' => 'string', symbol: :symbol }
5 @oh = Gitlab::ObjectifiedHash.new @hash
6 end
7
8 it "should objectify hash" do
9 expect(@oh.a).to eq(@hash[:a])
10 expect(@oh.b).to eq(@hash[:b])
11 end
12
13 describe "#to_hash" do
14 it "should return an original hash" do
15 expect(@oh.to_hash).to eq(@hash)
16 end
17
18 it "should have an alias #to_h" do
19 expect(@oh.respond_to?(:to_h)).to be_truthy
20 end
21 end
22
23 describe "#inspect" do
24 it "should return a formatted string" do
25 pretty_string = "#<#{@oh.class.name}:#{@oh.object_id} {hash: #{@hash}}"
26 expect(@oh.inspect).to eq(pretty_string)
27 end
28 end
29
30 describe "#respond_to" do
31 it "should return true for methods this object responds to through method_missing as sym" do
32 expect(@oh.respond_to?(:a)).to be_truthy
33 end
34
35 it "should return true for methods this object responds to through method_missing as string" do
36 expect(@oh.respond_to?('string')).to be_truthy
37 end
38
39 it "should not care if you use a string or symbol to reference a method" do
40 expect(@oh.respond_to?(:string)).to be_truthy
41 end
42
43 it "should not care if you use a string or symbol to reference a method" do
44 expect(@oh.respond_to?('symbol')).to be_truthy
45 end
46 end
47 end
0 require 'spec_helper'
1
2 describe Gitlab::PageLinks do
3 before do
4 @page_links = Gitlab::PageLinks.new('Link' => "<http://example.com/api/v3/projects?page=1&per_page=5>; rel=\"first\", <http://example.com/api/v3/projects?page=20&per_page=5>; rel=\"last\", <http://example.com/api/v3/projects?page=7&per_page=5>; rel=\"prev\", <http://example.com/api/v3/projects?page=9&per_page=5>; rel=\"next\"")
5 end
6
7 context '.extract_links' do
8 it 'should extract link header appropriately' do
9 expect(@page_links.last).to eql 'http://example.com/api/v3/projects?page=20&per_page=5'
10 expect(@page_links.first).to eql 'http://example.com/api/v3/projects?page=1&per_page=5'
11 expect(@page_links.next).to eql 'http://example.com/api/v3/projects?page=9&per_page=5'
12 expect(@page_links.prev).to eql 'http://example.com/api/v3/projects?page=7&per_page=5'
13 end
14 end
15 end
0 require 'spec_helper'
1
2 describe Gitlab::PaginatedResponse do
3 before do
4 array = [1, 2, 3, 4]
5 @paginated_response = Gitlab::PaginatedResponse.new array
6 end
7
8 it "should respond to *_page and has_*_page methods" do
9 expect(@paginated_response).to respond_to :first_page
10 expect(@paginated_response).to respond_to :last_page
11 expect(@paginated_response).to respond_to :next_page
12 expect(@paginated_response).to respond_to :prev_page
13 expect(@paginated_response).to respond_to :has_first_page?
14 expect(@paginated_response).to respond_to :has_last_page?
15 expect(@paginated_response).to respond_to :has_next_page?
16 expect(@paginated_response).to respond_to :has_prev_page?
17 end
18
19 context '.parse_headers!' do
20 it "should parse headers" do
21 @paginated_response.parse_headers!('Link' => "<http://example.com/api/v3/projects?page=1&per_page=5>; rel=\"first\", <http://example.com/api/v3/projects?page=20&per_page=5>; rel=\"last\"")
22 client = @paginated_response.client = double('client')
23 first_page_response = double('first_page_response')
24 last_page_response = double('last_page_response')
25 allow(client).to receive(:endpoint).and_return("http://example.com/api/v3")
26 allow(client).to receive(:get).with("/projects?page=1&per_page=5").and_return(first_page_response)
27 allow(client).to receive(:get).with("/projects?page=20&per_page=5").and_return(last_page_response)
28 expect(@paginated_response.has_first_page?).to be true
29 expect(@paginated_response.has_last_page?).to be true
30 expect(@paginated_response.has_next_page?).to be false
31 expect(@paginated_response.has_prev_page?).to be false
32 expect(@paginated_response.first_page).to be first_page_response
33 expect(@paginated_response.last_page).to be last_page_response
34 expect(@paginated_response.next_page).to be_nil
35 expect(@paginated_response.prev_page).to be_nil
36 end
37 end
38
39 context '.each_page' do
40 it "should iterate pages" do
41 next_page = double('next_page')
42 allow(@paginated_response).to receive(:has_next_page?).and_return(true)
43 allow(@paginated_response).to receive(:next_page).and_return(next_page)
44 allow(next_page).to receive(:has_next_page?).and_return(false)
45 expect { |b| @paginated_response.each_page(&b) }.to yield_successive_args(@paginated_response, next_page)
46 end
47 end
48
49 context '.auto_paginate' do
50 it "should returns an array if block is not given" do
51 next_page = double('next_page')
52 allow(@paginated_response).to receive(:has_next_page?).and_return(true)
53 allow(@paginated_response).to receive(:next_page).and_return(next_page)
54 allow(next_page).to receive(:has_next_page?).and_return(false)
55 allow(next_page).to receive(:to_ary).and_return([5, 6, 7, 8])
56 expect(@paginated_response.auto_paginate).to contain_exactly(1, 2, 3, 4, 5, 6, 7, 8)
57 end
58 end
59 end
0 require 'spec_helper'
1
2 describe Gitlab::Request do
3 it { should respond_to :get }
4 it { should respond_to :post }
5 it { should respond_to :put }
6 it { should respond_to :delete }
7 before do
8 @request = Gitlab::Request.new
9 end
10
11 describe ".default_options" do
12 it "should have default values" do
13 default_options = Gitlab::Request.default_options
14 expect(default_options).to be_a Hash
15 expect(default_options[:parser]).to be_a Proc
16 expect(default_options[:format]).to eq(:json)
17 expect(default_options[:headers]).to eq('Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded')
18 expect(default_options[:default_params]).to be_nil
19 end
20 end
21
22 describe ".parse" do
23 it "should return ObjectifiedHash" do
24 body = JSON.unparse(a: 1, b: 2)
25 expect(Gitlab::Request.parse(body)).to be_an Gitlab::ObjectifiedHash
26 expect(Gitlab::Request.parse("true")).to be true
27 expect(Gitlab::Request.parse("false")).to be false
28
29 expect { Gitlab::Request.parse("string") }.to raise_error(Gitlab::Error::Parsing)
30 end
31 end
32
33 describe "#set_request_defaults" do
34 context "when endpoint is not set" do
35 it "should raise Error::MissingCredentials" do
36 @request.endpoint = nil
37 expect do
38 @request.set_request_defaults
39 end.to raise_error(Gitlab::Error::MissingCredentials, 'Please set an endpoint to API')
40 end
41 end
42
43 context "when endpoint is set" do
44 before(:each) do
45 @request.endpoint = 'http://rabbit-hole.example.org'
46 end
47
48 it "should set default_params" do
49 @request.set_request_defaults('sudoer')
50 expect(Gitlab::Request.default_params).to eq(sudo: 'sudoer')
51 end
52 end
53 end
54
55 describe "#set_authorization_header" do
56 it "should raise MissingCredentials when auth_token and private_token are not set" do
57 expect do
58 @request.send(:set_authorization_header, {})
59 end.to raise_error(Gitlab::Error::MissingCredentials)
60 end
61
62 it "should set the correct header when given a private_token" do
63 @request.private_token = 'ys9BtunN3rDKbaJCYXaN'
64 expect(@request.send(:set_authorization_header, {})).to eq("PRIVATE-TOKEN" => 'ys9BtunN3rDKbaJCYXaN')
65 end
66
67 it "should set the correct header when setting an auth_token via the private_token config option" do
68 @request.private_token = '3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603'
69 expect(@request.send(:set_authorization_header, {})).to eq("Authorization" => "Bearer 3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603")
70 end
71 end
72 end
0 require 'spec_helper'
1 require 'tempfile'
2
3 describe Gitlab::Shell::History do
4 context 'saving to a file' do
5 before do
6 @file = Tempfile.new('.gitlab_shell_history')
7 @history = Gitlab::Shell::History.new(file_path: @file.path)
8 end
9
10 after { @file.close(true) }
11
12 it 'saves the lines' do
13 @history << 'party on, dudes'
14 @history << 'be excellent to each other'
15 @history.save
16 expect(File.read @file.path).
17 to eq("party on, dudes\nbe excellent to each other\n")
18 end
19
20 it 'has the lines' do
21 @history << 'party on, dudes'
22 @history << 'be excellent to each other'
23 expect(@history.lines).
24 to eq(["party on, dudes", "be excellent to each other"])
25 end
26
27 it 'limits the lines to GITLAB_HISTFILESIZE' do
28 ENV['GITLAB_HISTFILESIZE'] = '2'
29 @history << 'bogus'
30 @history << 'party on, dudes'
31 @history << 'be excellent to each other'
32 @history.save
33 expect(@history.lines).
34 to eq(["party on, dudes", "be excellent to each other"])
35 expect(File.read @file.path).
36 to eq("party on, dudes\nbe excellent to each other\n")
37 end
38 end
39
40 context 'loading a file' do
41 before do
42 @file = load_fixture('shell_history')
43 @history = Gitlab::Shell::History.new(file_path: @file.path)
44 end
45
46 it 'has the lines' do
47 @history.load
48 expect(@history.lines).
49 to eq(["party on, dudes", "be excellent to each other"])
50 end
51 end
52 end
0 require 'spec_helper'
1
2 describe Gitlab::Shell do
3 before do
4 Gitlab::Shell.setup
5 end
6
7 describe ".execute" do
8 context "invalid command" do
9 it "should raise" do
10 expect { Gitlab::Shell.execute 'foobar', [] }.to raise_error(RuntimeError)
11 end
12 end
13 end
14
15 describe ".history" do
16 before do
17 @history = Gitlab::Shell.history
18 end
19
20 it "should return a Gitlab::Shell::History instance" do
21 expect(@history).to be_a Gitlab::Shell::History
22 end
23 it "should respond to :save" do
24 expect(@history).to respond_to :save
25 end
26 it "should respond to :load" do
27 expect(@history).to respond_to :load
28 end
29 it "should respond to :<<" do
30 expect(@history).to respond_to :<<
31 end
32 end
33
34 describe ".setup" do
35 it "should set the Readline completion_proc" do
36 completion = Readline.completion_proc
37 expect(completion).to be_truthy
38 expect(completion).to be_a Proc
39 end
40 it "should set the Readline completion_append_character" do
41 completion_character = Readline.completion_append_character
42 expect(completion_character).to eq(' ')
43 end
44 end
45
46 describe ".completion" do
47 before do
48 @comp = Gitlab::Shell.completion
49 end
50 it "should return a Proc object" do
51 expect(@comp).to be_a Proc
52 end
53 context "called with an argument" do
54 it "should return an Array of matching commands" do
55 completed_cmds = @comp.call 'group'
56 expect(completed_cmds).to be_a Array
57 expect(completed_cmds.sort).to eq(%w(group group_members group_projects group_search groups))
58 end
59 end
60 end
61
62 describe ".parse_input" do
63 context "with arguments" do
64 it "should set command & arguments" do
65 Gitlab::Shell.parse_input('create_branch 1 "api" "master"')
66 expect(Gitlab::Shell.command).to eq('create_branch')
67 expect(Gitlab::Shell.arguments).to eq(%w(1 api master))
68 end
69 end
70
71 context "without arguments" do
72 it 'should set command & empty arguments' do
73 Gitlab::Shell.parse_input('exit')
74 expect(Gitlab::Shell.command).to eq('exit')
75 expect(Gitlab::Shell.arguments).to be_empty
76 end
77 end
78 end
79 end
0 require 'spec_helper'
1
2 describe Gitlab do
3 after { Gitlab.reset }
4
5 describe ".client" do
6 it "should be a Gitlab::Client" do
7 expect(Gitlab.client).to be_a Gitlab::Client
8 end
9
10 it "should not override each other" do
11 client1 = Gitlab.client(endpoint: 'https://api1.example.com', private_token: '001')
12 client2 = Gitlab.client(endpoint: 'https://api2.example.com', private_token: '002')
13 expect(client1.endpoint).to eq('https://api1.example.com')
14 expect(client2.endpoint).to eq('https://api2.example.com')
15 expect(client1.private_token).to eq('001')
16 expect(client2.private_token).to eq('002')
17 end
18
19 it "should set private_token to the auth_token when provided" do
20 client = Gitlab.client(endpoint: 'https://api2.example.com', auth_token: '3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603')
21 expect(client.private_token).to eq('3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603')
22 end
23 end
24
25 describe ".actions" do
26 it "should return an array of client methods" do
27 actions = Gitlab.actions
28 expect(actions).to be_an Array
29 expect(actions.first).to be_a Symbol
30 expect(actions.sort.first).to eq(:accept_merge_request)
31 end
32 end
33
34 describe ".endpoint=" do
35 it "should set endpoint" do
36 Gitlab.endpoint = 'https://api.example.com'
37 expect(Gitlab.endpoint).to eq('https://api.example.com')
38 end
39 end
40
41 describe ".private_token=" do
42 it "should set private_token" do
43 Gitlab.private_token = 'secret'
44 expect(Gitlab.private_token).to eq('secret')
45 end
46 end
47
48 describe ".auth_token=" do
49 it "should set auth_token", focus: true do
50 Gitlab.auth_token = 'auth_secret'
51 expect(Gitlab.private_token).to eq('auth_secret')
52 end
53 end
54
55 describe ".sudo=" do
56 it "should set sudo" do
57 Gitlab.sudo = 'user'
58 expect(Gitlab.sudo).to eq('user')
59 end
60 end
61
62 describe ".user_agent" do
63 it "should return default user_agent" do
64 expect(Gitlab.user_agent).to eq(Gitlab::Configuration::DEFAULT_USER_AGENT)
65 end
66 end
67
68 describe ".user_agent=" do
69 it "should set user_agent" do
70 Gitlab.user_agent = 'Custom User Agent'
71 expect(Gitlab.user_agent).to eq('Custom User Agent')
72 end
73 end
74
75 describe ".configure" do
76 Gitlab::Configuration::VALID_OPTIONS_KEYS.each do |key|
77 it "should set #{key}" do
78 Gitlab.configure do |config|
79 config.send("#{key}=", key)
80 expect(Gitlab.send(key)).to eq(key)
81 end
82 end
83 end
84 end
85
86 describe ".http_proxy" do
87 it "delegates the method to Gitlab::Request" do
88 Gitlab.endpoint = 'https://api.example.com'
89 request = class_spy(Gitlab::Request).as_stubbed_const
90
91 Gitlab.http_proxy('fazbearentertainment.com', 1987, 'ffazbear', 'itsme')
92 expect(request).to have_received(:http_proxy).
93 with('fazbearentertainment.com', 1987, 'ffazbear', 'itsme')
94 end
95 end
96 end
0 require 'rspec'
1 require 'webmock/rspec'
2
3 require File.expand_path('../../lib/gitlab', __FILE__)
4 require File.expand_path('../../lib/gitlab/cli', __FILE__)
5
6 def capture_output
7 out = StringIO.new
8 $stdout = out
9 $stderr = out
10 yield
11 $stdout = STDOUT
12 $stderr = STDERR
13 out.string
14 end
15
16 def load_fixture(name)
17 File.new(File.dirname(__FILE__) + "/fixtures/#{name}.json")
18 end
19
20 RSpec.configure do |config|
21 config.before(:all) do
22 Gitlab.endpoint = 'https://api.example.com'
23 Gitlab.private_token = 'secret'
24 end
25 end
26
27 # GET
28 def stub_get(path, fixture, status_code=200)
29 stub_request(:get, "#{Gitlab.endpoint}#{path}").
30 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
31 to_return(body: load_fixture(fixture), status: status_code)
32 end
33
34 def a_get(path)
35 a_request(:get, "#{Gitlab.endpoint}#{path}").
36 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token })
37 end
38
39 # POST
40 def stub_post(path, fixture, status_code=200)
41 stub_request(:post, "#{Gitlab.endpoint}#{path}").
42 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
43 to_return(body: load_fixture(fixture), status: status_code)
44 end
45
46 def a_post(path)
47 a_request(:post, "#{Gitlab.endpoint}#{path}").
48 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token })
49 end
50
51 # PUT
52 def stub_put(path, fixture)
53 stub_request(:put, "#{Gitlab.endpoint}#{path}").
54 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
55 to_return(body: load_fixture(fixture))
56 end
57
58 def a_put(path)
59 a_request(:put, "#{Gitlab.endpoint}#{path}").
60 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token })
61 end
62
63 # DELETE
64 def stub_delete(path, fixture)
65 stub_request(:delete, "#{Gitlab.endpoint}#{path}").
66 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }).
67 to_return(body: load_fixture(fixture))
68 end
69
70 def a_delete(path)
71 a_request(:delete, "#{Gitlab.endpoint}#{path}").
72 with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token })
73 end