New upstream version 4.1.0
Sophie Brun
6 years ago
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** — check if the issue has already been | |
23 | reported. | |
24 | ||
25 | 2. **Check if the issue has been fixed** — try to reproduce it using the | |
26 | `master` branch in the repository. | |
27 | ||
28 | 3. **Isolate and report the problem** — 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 | 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 | [](https://travis-ci.org/NARKOZ/gitlab) | |
3 | [](https://codeclimate.com/github/NARKOZ/gitlab) | |
4 | [](https://inch-ci.org/github/NARKOZ/gitlab) | |
5 | [](https://rubygems.org/gems/gitlab) | |
6 | [](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 | # |