gitlab 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -2
- data/README.md +22 -0
- data/bin/console +10 -0
- data/bin/setup +6 -0
- data/{bin → exe}/gitlab +0 -0
- data/gitlab.gemspec +4 -1
- data/lib/gitlab.rb +1 -1
- data/lib/gitlab/cli.rb +20 -2
- data/lib/gitlab/cli_helpers.rb +74 -15
- data/lib/gitlab/client.rb +2 -0
- data/lib/gitlab/client/commits.rb +121 -0
- data/lib/gitlab/client/groups.rb +25 -2
- data/lib/gitlab/client/issues.rb +7 -0
- data/lib/gitlab/client/milestones.rb +6 -0
- data/lib/gitlab/client/namespaces.rb +19 -0
- data/lib/gitlab/client/notes.rb +12 -0
- data/lib/gitlab/client/projects.rb +30 -0
- data/lib/gitlab/client/repositories.rb +0 -75
- data/lib/gitlab/client/repository_files.rb +16 -0
- data/lib/gitlab/client/snippets.rb +15 -0
- data/lib/gitlab/client/users.rb +54 -5
- data/lib/gitlab/configuration.rb +14 -0
- data/lib/gitlab/error.rb +3 -0
- data/lib/gitlab/request.rb +13 -2
- data/lib/gitlab/shell.rb +1 -2
- data/lib/gitlab/version.rb +1 -1
- data/spec/fixtures/branch_delete.json +0 -0
- data/spec/fixtures/get_repository_file.json +1 -0
- data/spec/fixtures/group_create_with_description.json +1 -0
- data/spec/fixtures/group_search.json +2 -0
- data/spec/fixtures/namespaces.json +1 -0
- data/spec/fixtures/project_commit_status.json +42 -0
- data/spec/fixtures/project_edit.json +21 -0
- data/spec/fixtures/project_fork.json +50 -0
- data/spec/fixtures/project_forked_for_user.json +50 -0
- data/spec/fixtures/project_update_commit_status.json +20 -0
- data/spec/fixtures/snippet_content.json +3 -0
- data/spec/fixtures/user.json +1 -1
- data/spec/fixtures/user_block_unblock.json +1 -0
- data/spec/fixtures/users.json +1 -1
- data/spec/gitlab/cli_helpers_spec.rb +6 -6
- data/spec/gitlab/cli_spec.rb +16 -0
- data/spec/gitlab/client/commits_spec.rb +137 -0
- data/spec/gitlab/client/groups_spec.rb +51 -13
- data/spec/gitlab/client/namespaces_spec.rb +22 -0
- data/spec/gitlab/client/projects_spec.rb +51 -0
- data/spec/gitlab/client/repositories_spec.rb +0 -88
- data/spec/gitlab/client/repository_files_spec.rb +17 -0
- data/spec/gitlab/client/snippets_spec.rb +15 -0
- data/spec/gitlab/client/users_spec.rb +73 -0
- data/spec/gitlab/help_spec.rb +1 -1
- data/spec/gitlab/request_spec.rb +16 -3
- data/spec/gitlab/shell_spec.rb +2 -2
- metadata +51 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2242783ef61cde9b3be8c6fad965bfbeb98aaa4
|
4
|
+
data.tar.gz: 01c567c9524d1e9ca20a0c0798d9b72fbe618f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 350d4ff66a74e000d55127271d526c77fbb56889d54b52e3c4f683c210f3c9ea62a763b706086070e1b0ff7cc02293fdc303ddd841c29cd51c4f79f1036f5e77
|
7
|
+
data.tar.gz: 4ca42fbb5fd028381944d77b016167e2471f013393b59030ee7ed3f5c700cf791af9ae43a542f45f7f769550003e64017fa6dde079c3e683dc3314718f6c32ea
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,35 @@
|
|
1
1
|
## Change Log
|
2
2
|
|
3
|
-
### upcoming
|
4
|
-
-
|
3
|
+
### upcoming (26/11/2015)
|
4
|
+
- [a4f2150](https://github.com/NARKOZ/gitlab/commit/a4f21504a7288caace5b7433b49f49dc31e32b30) Add support for namespaces endpoint
|
5
|
+
- [3ad81a1](https://github.com/NARKOZ/gitlab/commit/3ad81a19a10b35ea422c0abcf08e6d03a325f4cd) Add missing "@" in doc. (@asedge)
|
6
|
+
- [fc34acb](https://github.com/NARKOZ/gitlab/commit/fc34acb6b475bb2555e4b035c11fdf42b3db4085) Add Gitlab::Client::Commits and rearrange methods and tests related to commits. (@asedge)
|
7
|
+
- [527089b](https://github.com/NARKOZ/gitlab/commit/527089b17fa7ed74a39b30dc6e8bb33482c1044b) Add commit status API, was added in Gitlab 8.1 (@dsander)
|
8
|
+
- [0a2f1db](https://github.com/NARKOZ/gitlab/commit/0a2f1dbe3efb66511dc836ef0ef884efedd70ef3) Add --json CLI parameter to output results as JSON
|
9
|
+
- [3f9cb62](https://github.com/NARKOZ/gitlab/commit/3f9cb625517c7294652139f2748e4bc7b98848cc) Adding sudo option for when forking a project (@gregoriomelo)
|
10
|
+
- [8dd964e](https://github.com/NARKOZ/gitlab/commit/8dd964ee743e051fade3137d8fac9bb387770150) Fix CLI configuration example comment line width to <= 80. (@asedge)
|
11
|
+
- [bbb8b61](https://github.com/NARKOZ/gitlab/commit/bbb8b61db46b32b8649956cb81d9a41e132493d4) Add comment for CLI configuration example. (@asedge)
|
12
|
+
- [30e96b9](https://github.com/NARKOZ/gitlab/commit/30e96b9444f7d60d4c0a56f57202c609497126eb) Update README.md (@raine)
|
13
|
+
- [d81f05b](https://github.com/NARKOZ/gitlab/commit/d81f05b80b7aaccef49641acfada3b2181f1633d) Change #handle_error method so it handles errors that are returned as an Array. (@asedge)
|
14
|
+
- [4c0395e](https://github.com/NARKOZ/gitlab/commit/4c0395ebc58c5a907489b6dc9dcac151e07b4dc8) Add Unprocessable error handler (@ondra-m)
|
15
|
+
- [3179bed](https://github.com/NARKOZ/gitlab/commit/3179bedc498b6c5577cc3c0b04633f67eb286ea9) Add block/unblock user. This API feature was added in GitLab 7.13 (@azomazo)
|
16
|
+
- [9946c7d](https://github.com/NARKOZ/gitlab/commit/9946c7d2a2c4261cbfc9c4a492b079c79abc2767) Check for specific exceptions in tests to suppress rspec warnings. (@asedge)
|
17
|
+
- [5e1c025](https://github.com/NARKOZ/gitlab/commit/5e1c025b8fdf723770c7c7ac0116acdf5cc9f2d5) Added support description option in create_group method (@azomazo)
|
18
|
+
- [46b657e](https://github.com/NARKOZ/gitlab/commit/46b657e47a29bc18f4122fff593a9eb58b73e4f1) deleting a gitlab project returns the string "true" (@tosmi)
|
19
|
+
- [cc3b489](https://github.com/NARKOZ/gitlab/commit/cc3b489cdeb3bd18b4ec841f80e76e74ddd0ce37) add development scripts (@NARKOZ)
|
20
|
+
- [24ad7fd](https://github.com/NARKOZ/gitlab/commit/24ad7fd2a1bd99eb468f1181d95c75fbec5d8fe0) Added specs edit_project, create_fork, create_user_with_username (@p404)
|
21
|
+
- [42e73a2](https://github.com/NARKOZ/gitlab/commit/42e73a2fde3e64dc8e3cf0ec73b8cfad88e43ca8) Added edit_project method to Projects module && updated the create_user method (@p404)
|
22
|
+
- [c9822f1](https://github.com/NARKOZ/gitlab/commit/c9822f1b61a8d7a5e855616e80e725730340cd48) Refactor create_user method (@p404)
|
23
|
+
- [6d7c4e7](https://github.com/NARKOZ/gitlab/commit/6d7c4e7c3285ee082513b3125346e6ed9c18b24b) Added create_fork method to Projects module (@p404)
|
24
|
+
- [54155b6](https://github.com/NARKOZ/gitlab/commit/54155b6c59d6e307744668cb3592ca98cf11d8f2) Add snippet_content method + tests. (@asedge)
|
25
|
+
- [cfff385](https://github.com/NARKOZ/gitlab/commit/cfff385b7f528223bf9ddc5f4177883e5ca56492) Remove executable permission on fixture file. (@asedge)
|
26
|
+
- [487a372](https://github.com/NARKOZ/gitlab/commit/487a372f7041d104975570747a63c9021881c952) Add RepositoryFiles#get_file method. (@asedge)
|
27
|
+
- [c9c05ad](https://github.com/NARKOZ/gitlab/commit/c9c05adee50828cc2e31048006cc95b5f2b9b7ce) Hide auth_token method from CLI/shell. (@asedge)
|
28
|
+
- [ef408a7](https://github.com/NARKOZ/gitlab/commit/ef408a7de0e677a568a66dbf212139aafc2e6186) Remove unnecessary require. (@asedge)
|
29
|
+
- [a2752d1](https://github.com/NARKOZ/gitlab/commit/a2752d1f5a01759a85d1e2003bb81c8e59cf85d3) Add some missing examples. (@asedge)
|
30
|
+
- [ac595af](https://github.com/NARKOZ/gitlab/commit/ac595af15a07601b3b657d4b4c1c479651aaa7d7) Add group_search method. (@asedge)
|
31
|
+
- [53a6671](https://github.com/NARKOZ/gitlab/commit/53a667184ed3640aefcb3f67836d37f58a504f24) Added Users#delete_user method (@cthulhu666)
|
32
|
+
- [a2360f0](https://github.com/NARKOZ/gitlab/commit/a2360f08019632c2660dbbc6753bd3094286b993) Add httparty ENV variable for CLI. Fixes #127. (@asedge)
|
5
33
|
|
6
34
|
### 3.4.0 (22/04/2015)
|
7
35
|
- [9acb83d](https://github.com/NARKOZ/gitlab/commit/9acb83d2d068720b07934f5152313dc22a2f6374) remove check for missing attributes
|
data/README.md
CHANGED
@@ -88,6 +88,17 @@ For more information, refer to [documentation](http://rubydoc.info/gems/gitlab/f
|
|
88
88
|
|
89
89
|
## CLI
|
90
90
|
|
91
|
+
Configuration example:
|
92
|
+
|
93
|
+
```sh
|
94
|
+
export GITLAB_API_ENDPOINT=https://gitlab.yourcompany.com/api/v3
|
95
|
+
export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/account>
|
96
|
+
# This one is optional and can be used to set any HTTParty option you may need
|
97
|
+
# using YAML hash syntax. For example, this is how you would disable SSL
|
98
|
+
# verification (useful if using a self-signed cert).
|
99
|
+
export GITLAB_API_HTTPARTY_OPTIONS="{verify: false}"
|
100
|
+
```
|
101
|
+
|
91
102
|
Usage examples:
|
92
103
|
|
93
104
|
```sh
|
@@ -105,6 +116,9 @@ gitlab user --only=id,username
|
|
105
116
|
|
106
117
|
gitlab user --except=email,bio
|
107
118
|
|
119
|
+
# get a user and render result as json
|
120
|
+
gitlab user 2 --json
|
121
|
+
|
108
122
|
# passing options hash to a command (use YAML)
|
109
123
|
gitlab create_merge_request 4 "New merge request" "{source_branch: 'new_branch', target_branch: 'master', assignee_id: 42}"
|
110
124
|
|
@@ -134,6 +148,14 @@ gitlab> create_merge_request 4 "New merge request" "{source_branch: 'new_branch'
|
|
134
148
|
Web version is available at https://gitlab-live.herokuapp.com
|
135
149
|
For more information, refer to [website](http://narkoz.github.io/gitlab).
|
136
150
|
|
151
|
+
## Development
|
152
|
+
|
153
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
154
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
155
|
+
prompt that will allow you to experiment.
|
156
|
+
|
157
|
+
For more information see [CONTRIBUTING.md](https://github.com/NARKOZ/gitlab/blob/master/CONTRIBUTING.md).
|
158
|
+
|
137
159
|
## License
|
138
160
|
|
139
161
|
Released under the BSD 2-clause license. See LICENSE.txt for details.
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/{bin → exe}/gitlab
RENAMED
File without changes
|
data/gitlab.gemspec
CHANGED
@@ -13,13 +13,16 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.homepage = "https://github.com/narkoz/gitlab"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
|
-
gem.
|
16
|
+
gem.bindir = "exe"
|
17
|
+
gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
19
|
gem.require_paths = ["lib"]
|
20
|
+
gem.license = "BSD"
|
19
21
|
|
20
22
|
gem.add_runtime_dependency 'httparty'
|
21
23
|
gem.add_runtime_dependency 'terminal-table'
|
22
24
|
|
25
|
+
gem.add_development_dependency 'pry'
|
23
26
|
gem.add_development_dependency 'rake'
|
24
27
|
gem.add_development_dependency 'rspec'
|
25
28
|
gem.add_development_dependency 'webmock'
|
data/lib/gitlab.rb
CHANGED
@@ -36,7 +36,7 @@ module Gitlab
|
|
36
36
|
#
|
37
37
|
# @return [Array<Symbol>]
|
38
38
|
def self.actions
|
39
|
-
hidden = /endpoint|private_token|user_agent|sudo|get|post|put|\Adelete\z|validate|set_request_defaults|httparty/
|
39
|
+
hidden = /endpoint|private_token|auth_token|user_agent|sudo|get|post|put|\Adelete\z|validate|set_request_defaults|httparty/
|
40
40
|
(Gitlab::Client.instance_methods - Object.methods).reject {|e| e[hidden]}
|
41
41
|
end
|
42
42
|
end
|
data/lib/gitlab/cli.rb
CHANGED
@@ -6,6 +6,9 @@ require_relative 'shell'
|
|
6
6
|
class Gitlab::CLI
|
7
7
|
extend Helpers
|
8
8
|
|
9
|
+
# If set to true, JSON will be rendered as output
|
10
|
+
@render_json = false
|
11
|
+
|
9
12
|
# Starts a new CLI session.
|
10
13
|
#
|
11
14
|
# @example
|
@@ -43,6 +46,11 @@ class Gitlab::CLI
|
|
43
46
|
when 'shell'
|
44
47
|
Gitlab::Shell.start
|
45
48
|
else
|
49
|
+
if args.include? '--json'
|
50
|
+
@json_output = true
|
51
|
+
args.delete '--json'
|
52
|
+
end
|
53
|
+
|
46
54
|
unless valid_command?(cmd)
|
47
55
|
puts "Unknown command. Run `gitlab help` for a list of available commands."
|
48
56
|
exit(1)
|
@@ -55,8 +63,7 @@ class Gitlab::CLI
|
|
55
63
|
end
|
56
64
|
|
57
65
|
begin
|
58
|
-
|
59
|
-
command_args.map! {|arg| symbolize_keys arg }
|
66
|
+
command_args.map! { |arg| symbolize_keys(yaml_load(arg)) }
|
60
67
|
rescue => e
|
61
68
|
puts e.message
|
62
69
|
exit 1
|
@@ -65,6 +72,17 @@ class Gitlab::CLI
|
|
65
72
|
confirm_command(cmd)
|
66
73
|
|
67
74
|
data = gitlab_helper(cmd, command_args) { exit(1) }
|
75
|
+
|
76
|
+
render_output(cmd, args, data)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Helper method that checks whether we want to get the output as json
|
81
|
+
# @return [nil]
|
82
|
+
def self.render_output(cmd,args,data)
|
83
|
+
if @json_output
|
84
|
+
output_json(cmd, args, data)
|
85
|
+
else
|
68
86
|
output_table(cmd, args, data)
|
69
87
|
end
|
70
88
|
end
|
data/lib/gitlab/cli_helpers.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'json'
|
3
|
+
|
2
4
|
|
3
5
|
class Gitlab::CLI
|
4
6
|
# Defines methods related to CLI output and formatting.
|
@@ -99,16 +101,29 @@ class Gitlab::CLI
|
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
104
|
+
def output_json(cmd, args, data)
|
105
|
+
if data.empty?
|
106
|
+
puts '{}'
|
107
|
+
else
|
108
|
+
hash_result = case data
|
109
|
+
when Gitlab::ObjectifiedHash
|
110
|
+
record_hash([data], cmd, args, true)
|
111
|
+
when Array
|
112
|
+
record_hash(data, cmd, args)
|
113
|
+
else
|
114
|
+
{ :cmd => cmd, :data => data, :args => args }
|
115
|
+
end
|
116
|
+
puts JSON.pretty_generate(hash_result)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
102
120
|
# Table to display records.
|
103
121
|
#
|
104
122
|
# @return [Terminal::Table]
|
105
123
|
def record_table(data, cmd, args)
|
106
124
|
return 'No data' if data.empty?
|
107
125
|
|
108
|
-
arr = data
|
109
|
-
keys = arr.first.keys.sort {|x, y| x.to_s <=> y.to_s }
|
110
|
-
keys = keys & required_fields(args) if required_fields(args).any?
|
111
|
-
keys = keys - excluded_fields(args)
|
126
|
+
arr, keys = get_keys(args, data)
|
112
127
|
|
113
128
|
table do |t|
|
114
129
|
t.title = "Gitlab.#{cmd} #{args.join(', ')}"
|
@@ -134,6 +149,54 @@ class Gitlab::CLI
|
|
134
149
|
end
|
135
150
|
end
|
136
151
|
|
152
|
+
# Renders the result of given commands and arguments into a Hash
|
153
|
+
#
|
154
|
+
# @param [Array] data Resultset from the API call
|
155
|
+
# @param [String] cmd The command passed to the API
|
156
|
+
# @param [Array] args Options passed to the API call
|
157
|
+
# @param [bool] single_value If set to true, a single result should be returned
|
158
|
+
# @return [Hash] Result hash
|
159
|
+
def record_hash(data, cmd, args, single_value = false)
|
160
|
+
if data.empty?
|
161
|
+
result = nil
|
162
|
+
else
|
163
|
+
arr, keys = get_keys(args, data)
|
164
|
+
result = []
|
165
|
+
arr.each do |hash|
|
166
|
+
row = {}
|
167
|
+
|
168
|
+
keys.each do |key|
|
169
|
+
case hash[key]
|
170
|
+
when Hash
|
171
|
+
row[key] = 'Hash'
|
172
|
+
when nil
|
173
|
+
row[key] = nil
|
174
|
+
else
|
175
|
+
row[key] = hash[key]
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
result.push row
|
180
|
+
end
|
181
|
+
result = result[0] if single_value && result.count > 0
|
182
|
+
end
|
183
|
+
|
184
|
+
{
|
185
|
+
:cmd => "Gitlab.#{cmd} #{args.join(', ')}".strip,
|
186
|
+
:result => result
|
187
|
+
}
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
# Helper function to get rows and keys from data returned from API call
|
192
|
+
def get_keys(args, data)
|
193
|
+
arr = data.map(&:to_h)
|
194
|
+
keys = arr.first.keys.sort { |x, y| x.to_s <=> y.to_s }
|
195
|
+
keys = keys & required_fields(args) if required_fields(args).any?
|
196
|
+
keys = keys - excluded_fields(args)
|
197
|
+
return arr, keys
|
198
|
+
end
|
199
|
+
|
137
200
|
# Helper function to call Gitlab commands with args.
|
138
201
|
def gitlab_helper(cmd, args = [])
|
139
202
|
begin
|
@@ -162,18 +225,14 @@ class Gitlab::CLI
|
|
162
225
|
hash
|
163
226
|
end
|
164
227
|
|
165
|
-
#
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
rescue Psych::SyntaxError
|
172
|
-
raise "error: Argument is not valid YAML syntax: #{arg}"
|
173
|
-
end
|
174
|
-
|
175
|
-
arg
|
228
|
+
# YAML::load on a single argument
|
229
|
+
def yaml_load(arg)
|
230
|
+
begin
|
231
|
+
yaml = YAML::load(arg)
|
232
|
+
rescue Psych::SyntaxError
|
233
|
+
raise "error: Argument is not valid YAML syntax: #{arg}"
|
176
234
|
end
|
235
|
+
yaml
|
177
236
|
end
|
178
237
|
end
|
179
238
|
end
|
data/lib/gitlab/client.rb
CHANGED
@@ -4,11 +4,13 @@ module Gitlab
|
|
4
4
|
Dir[File.expand_path('../client/*.rb', __FILE__)].each {|f| require f}
|
5
5
|
|
6
6
|
include Branches
|
7
|
+
include Commits
|
7
8
|
include Groups
|
8
9
|
include Issues
|
9
10
|
include Labels
|
10
11
|
include MergeRequests
|
11
12
|
include Milestones
|
13
|
+
include Namespaces
|
12
14
|
include Notes
|
13
15
|
include Projects
|
14
16
|
include Repositories
|
@@ -0,0 +1,121 @@
|
|
1
|
+
class Gitlab::Client
|
2
|
+
# Defines methods related to repository commits.
|
3
|
+
# @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/commits.md
|
4
|
+
module Commits
|
5
|
+
# Gets a list of project commits.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# Gitlab.commits('viking')
|
9
|
+
# Gitlab.repo_commits('gitlab', :ref_name => 'api')
|
10
|
+
#
|
11
|
+
# @param [Integer] project The ID of a project.
|
12
|
+
# @param [Hash] options A customizable set of options.
|
13
|
+
# @option options [String] :ref_name The branch or tag name of a project repository.
|
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 commits(project, options={})
|
18
|
+
get("/projects/#{project}/repository/commits", :query => options)
|
19
|
+
end
|
20
|
+
alias_method :repo_commits, :commits
|
21
|
+
|
22
|
+
# Gets a specific commit identified by the commit hash or name of a branch or tag.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Gitlab.commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
26
|
+
# Gitlab.repo_commit(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
|
27
|
+
#
|
28
|
+
# @param [Integer] project The ID of a project.
|
29
|
+
# @param [String] sha The commit hash or name of a repository branch or tag
|
30
|
+
# @return [Gitlab::ObjectifiedHash]
|
31
|
+
def commit(project, sha)
|
32
|
+
get("/projects/#{project}/repository/commits/#{sha}")
|
33
|
+
end
|
34
|
+
alias_method :repo_commit, :commit
|
35
|
+
|
36
|
+
# Get the diff of a commit in a project.
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# Gitlab.commit_diff(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
40
|
+
# Gitlab.repo_commit_diff(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
|
41
|
+
#
|
42
|
+
# @param [Integer] project The ID of a project.
|
43
|
+
# @param [String] sha The name of a repository branch or tag or if not given the default branch.
|
44
|
+
# @return [Gitlab::ObjectifiedHash]
|
45
|
+
def commit_diff(project, sha)
|
46
|
+
get("/projects/#{project}/repository/commits/#{sha}/diff")
|
47
|
+
end
|
48
|
+
alias_method :repo_commit_diff, :commit_diff
|
49
|
+
|
50
|
+
# Gets a list of comments for a commit.
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# Gitlab.commit_comments(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b')
|
54
|
+
#
|
55
|
+
# @param [Integer] project The ID of a project.
|
56
|
+
# @param [String] sha The commit hash or name of a repository branch or tag.
|
57
|
+
# @option options [Integer] :page The page number.
|
58
|
+
# @option options [Integer] :per_page The number of results per page.
|
59
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
60
|
+
def commit_comments(project, commit, options={})
|
61
|
+
get("/projects/#{project}/repository/commits/#{commit}/comments", :query => options)
|
62
|
+
end
|
63
|
+
alias_method :repo_commit_comments, :commit_comments
|
64
|
+
|
65
|
+
# Creates a new comment for a commit.
|
66
|
+
#
|
67
|
+
# @example
|
68
|
+
# Gitlab.create_commit_comment(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b', 'Nice work on this commit!')
|
69
|
+
#
|
70
|
+
# @param [Integer] project The ID of a project.
|
71
|
+
# @param [String] sha The commit hash or name of a repository branch or tag.
|
72
|
+
# @param [String] note The text of a comment.
|
73
|
+
# @param [Hash] options A customizable set of options.
|
74
|
+
# @option options [String] :path The file path.
|
75
|
+
# @option options [Integer] :line The line number.
|
76
|
+
# @option options [String] :line_type The line type (new or old).
|
77
|
+
# @return [Gitlab::ObjectifiedHash] Information about created comment.
|
78
|
+
def create_commit_comment(project, commit, note, options={})
|
79
|
+
post("/projects/#{project}/repository/commits/#{commit}/comments", :body => options.merge(:note => note))
|
80
|
+
end
|
81
|
+
alias_method :repo_create_commit_comment, :create_commit_comment
|
82
|
+
|
83
|
+
# Get the status of a commit
|
84
|
+
#
|
85
|
+
# @example
|
86
|
+
# Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
87
|
+
# Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', name: 'jenkins')
|
88
|
+
# Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', name: 'jenkins', all: true)
|
89
|
+
#
|
90
|
+
# @param [Integer] project The ID of a project.
|
91
|
+
# @param [String] sha The commit hash
|
92
|
+
# @param [Hash] options A customizable set of options.
|
93
|
+
# @option options [String] :ref Filter by ref name, it can be branch or tag
|
94
|
+
# @option options [String] :stage Filter by stage
|
95
|
+
# @option options [String] :name Filer by status name, eg. jenkins
|
96
|
+
# @option options [Boolean] :all The flag to return all statuses, not only latest ones
|
97
|
+
def commit_status(id, sha, options = {})
|
98
|
+
get("/projects/#{id}/repository/commits/#{sha}/statuses", query: options)
|
99
|
+
end
|
100
|
+
alias_method :repo_commit_status, :commit_status
|
101
|
+
|
102
|
+
# Adds or updates a status of a commit.
|
103
|
+
#
|
104
|
+
# @example
|
105
|
+
# Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'success')
|
106
|
+
# Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'failed', name: 'jenkins')
|
107
|
+
# Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'canceled', name: 'jenkins', target_url: 'http://example.com/builds/1')
|
108
|
+
#
|
109
|
+
# @param [Integer] project The ID of a project.
|
110
|
+
# @param [String] sha The commit hash
|
111
|
+
# @param [String] state of the status. Can be: pending, running, success, failed, canceled
|
112
|
+
# @param [Hash] options A customizable set of options.
|
113
|
+
# @option options [String] :ref The ref (branch or tag) to which the status refers
|
114
|
+
# @option options [String] :name Filer by status name, eg. jenkins
|
115
|
+
# @option options [String] :target_url The target URL to associate with this status
|
116
|
+
def update_commit_status(id, sha, state, options = {})
|
117
|
+
post("/projects/#{id}/statuses/#{sha}", query: options.merge(state: state))
|
118
|
+
end
|
119
|
+
alias_method :repo_update_commit_status, :update_commit_status
|
120
|
+
end
|
121
|
+
end
|