gitlab 4.6.0 → 4.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gitlab/client/access_requests.rb +92 -90
  3. data/lib/gitlab/client/award_emojis.rb +126 -124
  4. data/lib/gitlab/client/boards.rb +81 -79
  5. data/lib/gitlab/client/branches.rb +89 -87
  6. data/lib/gitlab/client/build_variables.rb +117 -115
  7. data/lib/gitlab/client/builds.rb +98 -96
  8. data/lib/gitlab/client/commits.rb +154 -152
  9. data/lib/gitlab/client/deployments.rb +29 -27
  10. data/lib/gitlab/client/environments.rb +80 -78
  11. data/lib/gitlab/client/events.rb +54 -52
  12. data/lib/gitlab/client/group_milestones.rb +85 -83
  13. data/lib/gitlab/client/groups.rb +178 -176
  14. data/lib/gitlab/client/issues.rb +190 -188
  15. data/lib/gitlab/client/jobs.rb +150 -148
  16. data/lib/gitlab/client/keys.rb +14 -12
  17. data/lib/gitlab/client/labels.rb +79 -77
  18. data/lib/gitlab/client/merge_request_approvals.rb +101 -99
  19. data/lib/gitlab/client/merge_requests.rb +279 -277
  20. data/lib/gitlab/client/milestones.rb +85 -83
  21. data/lib/gitlab/client/namespaces.rb +18 -16
  22. data/lib/gitlab/client/notes.rb +260 -258
  23. data/lib/gitlab/client/pipeline_schedules.rb +123 -121
  24. data/lib/gitlab/client/pipeline_triggers.rb +93 -91
  25. data/lib/gitlab/client/pipelines.rb +62 -60
  26. data/lib/gitlab/client/projects.rb +526 -524
  27. data/lib/gitlab/client/repositories.rb +67 -65
  28. data/lib/gitlab/client/repository_files.rb +103 -101
  29. data/lib/gitlab/client/runners.rb +114 -112
  30. data/lib/gitlab/client/services.rb +45 -43
  31. data/lib/gitlab/client/sidekiq.rb +32 -30
  32. data/lib/gitlab/client/snippets.rb +86 -84
  33. data/lib/gitlab/client/system_hooks.rb +57 -55
  34. data/lib/gitlab/client/tags.rb +88 -86
  35. data/lib/gitlab/client/todos.rb +40 -38
  36. data/lib/gitlab/client/users.rb +243 -241
  37. data/lib/gitlab/client/versions.rb +13 -11
  38. data/lib/gitlab/help.rb +1 -1
  39. data/lib/gitlab/version.rb +1 -1
  40. metadata +1 -1
@@ -1,106 +1,108 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Defines methods related to builds.
4
- # @see https://docs.gitlab.com/ce/api/builds.html
5
- module Builds
6
- # Gets a list of project builds.
7
- #
8
- # @example
9
- # Gitlab.builds(5)
10
- # Gitlab.builds(5, { per_page: 10, page: 2 })
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
- # @param [Integer, String] project The ID or name of a project.
17
- # @return [Array<Gitlab::ObjectifiedHash>]
18
- def builds(project, options = {})
19
- get("/projects/#{url_encode project}/builds", query: options)
20
- end
3
+ class Gitlab::Client
4
+ # Defines methods related to builds.
5
+ # @see https://docs.gitlab.com/ce/api/builds.html
6
+ module Builds
7
+ # Gets a list of project builds.
8
+ #
9
+ # @example
10
+ # Gitlab.builds(5)
11
+ # Gitlab.builds(5, { per_page: 10, page: 2 })
12
+ #
13
+ # @param [Integer, String] project The ID or name of a project.
14
+ # @param [Hash] options A customizable set of options.
15
+ # @option options [Integer] :page The page number.
16
+ # @option options [Integer] :per_page The number of results per page.
17
+ # @param [Integer, String] project The ID or name of a project.
18
+ # @return [Array<Gitlab::ObjectifiedHash>]
19
+ def builds(project, options = {})
20
+ get("/projects/#{url_encode project}/builds", query: options)
21
+ end
21
22
 
22
- # Gets a single build.
23
- #
24
- # @example
25
- # Gitlab.build(5, 36)
26
- #
27
- # @param [Integer, String] project The ID or name of a project.
28
- # @param [Integer] id The ID of a build.
29
- # @return [Gitlab::ObjectifiedHash]
30
- def build(project, id)
31
- get("/projects/#{url_encode project}/builds/#{id}")
32
- end
23
+ # Gets a single build.
24
+ #
25
+ # @example
26
+ # Gitlab.build(5, 36)
27
+ #
28
+ # @param [Integer, String] project The ID or name of a project.
29
+ # @param [Integer] id The ID of a build.
30
+ # @return [Gitlab::ObjectifiedHash]
31
+ def build(project, id)
32
+ get("/projects/#{url_encode project}/builds/#{id}")
33
+ end
33
34
 
34
- # Gets build artifacts.
35
- #
36
- # @example
37
- # Gitlab.build_artifacts(1, 8)
38
- #
39
- # @param [Integer, String] project The ID or name of a project.
40
- # @param [Integer] id The ID of a build.
41
- # @return [Gitlab::FileResponse]
42
- def build_artifacts(project, id)
43
- get("/projects/#{url_encode project}/builds/#{id}/artifacts",
44
- format: nil,
45
- headers: { Accept: 'application/octet-stream' },
46
- parser: proc { |body, _|
47
- if body.encoding == Encoding::ASCII_8BIT # binary response
48
- ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
49
- else # error with json response
50
- ::Gitlab::Request.parse(body)
51
- end
52
- })
53
- end
35
+ # Gets build artifacts.
36
+ #
37
+ # @example
38
+ # Gitlab.build_artifacts(1, 8)
39
+ #
40
+ # @param [Integer, String] project The ID or name of a project.
41
+ # @param [Integer] id The ID of a build.
42
+ # @return [Gitlab::FileResponse]
43
+ def build_artifacts(project, id)
44
+ get("/projects/#{url_encode project}/builds/#{id}/artifacts",
45
+ format: nil,
46
+ headers: { Accept: 'application/octet-stream' },
47
+ parser: proc { |body, _|
48
+ if body.encoding == Encoding::ASCII_8BIT # binary response
49
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
50
+ else # error with json response
51
+ ::Gitlab::Request.parse(body)
52
+ end
53
+ })
54
+ end
54
55
 
55
- # Gets a list of builds for specific commit in a project.
56
- #
57
- # @example
58
- # Gitlab.commit_builds(5, 'asdf')
59
- # Gitlab.commit_builds(5, 'asdf', { per_page: 10, page: 2 })
60
- #
61
- # @param [Integer, String] project The ID or name of a project.
62
- # @param [String] sha The SHA checksum of a commit.
63
- # @param [Hash] options A customizable set of options.
64
- # @option options [Integer] :page The page number.
65
- # @option options [Integer] :per_page The number of results per page.
66
- # @return [Array<Gitlab::ObjectifiedHash>] The list of builds.
67
- def commit_builds(project, sha, options = {})
68
- get("/projects/#{url_encode project}/repository/commits/#{sha}/builds", query: options)
69
- end
56
+ # Gets a list of builds for specific commit in a project.
57
+ #
58
+ # @example
59
+ # Gitlab.commit_builds(5, 'asdf')
60
+ # Gitlab.commit_builds(5, 'asdf', { per_page: 10, page: 2 })
61
+ #
62
+ # @param [Integer, String] project The ID or name of a project.
63
+ # @param [String] sha The SHA checksum of a commit.
64
+ # @param [Hash] options A customizable set of options.
65
+ # @option options [Integer] :page The page number.
66
+ # @option options [Integer] :per_page The number of results per page.
67
+ # @return [Array<Gitlab::ObjectifiedHash>] The list of builds.
68
+ def commit_builds(project, sha, options = {})
69
+ get("/projects/#{url_encode project}/repository/commits/#{sha}/builds", query: options)
70
+ end
70
71
 
71
- # Cancels a build.
72
- #
73
- # @example
74
- # Gitlab.build_cancel(5, 1)
75
- #
76
- # @param [Integer, String] project The ID or name of a project.
77
- # @param [Integer] id The ID of a build.
78
- # @return [Gitlab::ObjectifiedHash] The builds changes.
79
- def build_cancel(project, id)
80
- post("/projects/#{url_encode project}/builds/#{id}/cancel")
81
- end
72
+ # Cancels a build.
73
+ #
74
+ # @example
75
+ # Gitlab.build_cancel(5, 1)
76
+ #
77
+ # @param [Integer, String] project The ID or name of a project.
78
+ # @param [Integer] id The ID of a build.
79
+ # @return [Gitlab::ObjectifiedHash] The builds changes.
80
+ def build_cancel(project, id)
81
+ post("/projects/#{url_encode project}/builds/#{id}/cancel")
82
+ end
82
83
 
83
- # Retry a build.
84
- #
85
- # @example
86
- # Gitlab.build_retry(5, 1)
87
- #
88
- # @param [Integer, String] project The ID or name of a project.
89
- # @param [Integer] id The ID of a build.
90
- # @return [Array<Gitlab::ObjectifiedHash>] The builds changes.
91
- def build_retry(project, id)
92
- post("/projects/#{url_encode project}/builds/#{id}/retry")
93
- end
84
+ # Retry a build.
85
+ #
86
+ # @example
87
+ # Gitlab.build_retry(5, 1)
88
+ #
89
+ # @param [Integer, String] project The ID or name of a project.
90
+ # @param [Integer] id The ID of a build.
91
+ # @return [Array<Gitlab::ObjectifiedHash>] The builds changes.
92
+ def build_retry(project, id)
93
+ post("/projects/#{url_encode project}/builds/#{id}/retry")
94
+ end
94
95
 
95
- # Erase a single build of a project (remove build artifacts and a build trace)
96
- #
97
- # @example
98
- # Gitlab.build_erase(5, 1)
99
- #
100
- # @param [Integer, String] project The ID or name of a project.
101
- # @param [Integer] id The ID of a build.
102
- # @return [Gitlab::ObjectifiedHash] The build's changes.
103
- def build_erase(project, id)
104
- post("/projects/#{url_encode project}/builds/#{id}/erase")
96
+ # Erase a single build of a project (remove build artifacts and a build trace)
97
+ #
98
+ # @example
99
+ # Gitlab.build_erase(5, 1)
100
+ #
101
+ # @param [Integer, String] project The ID or name of a project.
102
+ # @param [Integer] id The ID of a build.
103
+ # @return [Gitlab::ObjectifiedHash] The build's changes.
104
+ def build_erase(project, id)
105
+ post("/projects/#{url_encode project}/builds/#{id}/erase")
106
+ end
105
107
  end
106
108
  end
@@ -1,164 +1,166 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Defines methods related to repository commits.
4
- # @see https://docs.gitlab.com/ce/api/commits.html
5
- module Commits
6
- # Gets a list of project commits.
7
- #
8
- # @example
9
- # Gitlab.commits('viking')
10
- # Gitlab.repo_commits('gitlab', { ref_name: 'api' })
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 [String] :ref_name The branch or tag name of a project repository.
15
- # @option options [Integer] :page The page number.
16
- # @option options [Integer] :per_page The number of results per page.
17
- # @return [Array<Gitlab::ObjectifiedHash>]
18
- def commits(project, options = {})
19
- get("/projects/#{url_encode project}/repository/commits", query: options)
20
- end
21
- alias repo_commits commits
3
+ class Gitlab::Client
4
+ # Defines methods related to repository commits.
5
+ # @see https://docs.gitlab.com/ce/api/commits.html
6
+ module Commits
7
+ # Gets a list of project commits.
8
+ #
9
+ # @example
10
+ # Gitlab.commits('viking')
11
+ # Gitlab.repo_commits('gitlab', { ref_name: 'api' })
12
+ #
13
+ # @param [Integer, String] project The ID or name of a project.
14
+ # @param [Hash] options A customizable set of options.
15
+ # @option options [String] :ref_name The branch or tag name of a project repository.
16
+ # @option options [Integer] :page The page number.
17
+ # @option options [Integer] :per_page The number of results per page.
18
+ # @return [Array<Gitlab::ObjectifiedHash>]
19
+ def commits(project, options = {})
20
+ get("/projects/#{url_encode project}/repository/commits", query: options)
21
+ end
22
+ alias repo_commits commits
22
23
 
23
- # Gets a specific commit identified by the commit hash or name of a branch or tag.
24
- #
25
- # @example
26
- # Gitlab.commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
27
- # Gitlab.repo_commit(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
28
- #
29
- # @param [Integer, String] project The ID or name of a project.
30
- # @param [String] sha The commit hash or name of a repository branch or tag
31
- # @return [Gitlab::ObjectifiedHash]
32
- def commit(project, sha)
33
- get("/projects/#{url_encode project}/repository/commits/#{sha}")
34
- end
35
- alias repo_commit commit
24
+ # Gets a specific commit identified by the commit hash or name of a branch or tag.
25
+ #
26
+ # @example
27
+ # Gitlab.commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
28
+ # Gitlab.repo_commit(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
29
+ #
30
+ # @param [Integer, String] project The ID or name of a project.
31
+ # @param [String] sha The commit hash or name of a repository branch or tag
32
+ # @return [Gitlab::ObjectifiedHash]
33
+ def commit(project, sha)
34
+ get("/projects/#{url_encode project}/repository/commits/#{sha}")
35
+ end
36
+ alias repo_commit commit
36
37
 
37
- # Get the diff of a commit in a project.
38
- #
39
- # @example
40
- # Gitlab.commit_diff(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
41
- # Gitlab.repo_commit_diff(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
42
- #
43
- # @param [Integer, String] project The ID or name of a project.
44
- # @param [String] sha The name of a repository branch or tag or if not given the default branch.
45
- # @return [Gitlab::ObjectifiedHash]
46
- def commit_diff(project, sha)
47
- get("/projects/#{url_encode project}/repository/commits/#{sha}/diff")
48
- end
49
- alias repo_commit_diff commit_diff
38
+ # Get the diff of a commit in a project.
39
+ #
40
+ # @example
41
+ # Gitlab.commit_diff(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
42
+ # Gitlab.repo_commit_diff(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
43
+ #
44
+ # @param [Integer, String] project The ID or name of a project.
45
+ # @param [String] sha The name of a repository branch or tag or if not given the default branch.
46
+ # @return [Gitlab::ObjectifiedHash]
47
+ def commit_diff(project, sha)
48
+ get("/projects/#{url_encode project}/repository/commits/#{sha}/diff")
49
+ end
50
+ alias repo_commit_diff commit_diff
50
51
 
51
- # Gets a list of comments for a commit.
52
- #
53
- # @example
54
- # Gitlab.commit_comments(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b')
55
- #
56
- # @param [Integer] project The ID of a project.
57
- # @param [String] sha The commit hash or name of a repository branch or tag.
58
- # @option options [Integer] :page The page number.
59
- # @option options [Integer] :per_page The number of results per page.
60
- # @return [Array<Gitlab::ObjectifiedHash>]
61
- def commit_comments(project, commit, options = {})
62
- get("/projects/#{url_encode project}/repository/commits/#{commit}/comments", query: options)
63
- end
64
- alias repo_commit_comments commit_comments
52
+ # Gets a list of comments for a commit.
53
+ #
54
+ # @example
55
+ # Gitlab.commit_comments(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b')
56
+ #
57
+ # @param [Integer] project The ID of a project.
58
+ # @param [String] sha The commit hash or name of a repository branch or tag.
59
+ # @option options [Integer] :page The page number.
60
+ # @option options [Integer] :per_page The number of results per page.
61
+ # @return [Array<Gitlab::ObjectifiedHash>]
62
+ def commit_comments(project, commit, options = {})
63
+ get("/projects/#{url_encode project}/repository/commits/#{commit}/comments", query: options)
64
+ end
65
+ alias repo_commit_comments commit_comments
65
66
 
66
- # Creates a new comment for a commit.
67
- #
68
- # @example
69
- # Gitlab.create_commit_comment(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b', 'Nice work on this commit!')
70
- #
71
- # @param [Integer, String] project The ID or name of a project.
72
- # @param [String] sha The commit hash or name of a repository branch or tag.
73
- # @param [String] note The text of a comment.
74
- # @param [Hash] options A customizable set of options.
75
- # @option options [String] :path The file path.
76
- # @option options [Integer] :line The line number.
77
- # @option options [String] :line_type The line type (new or old).
78
- # @return [Gitlab::ObjectifiedHash] Information about created comment.
79
- def create_commit_comment(project, commit, note, options = {})
80
- post("/projects/#{url_encode project}/repository/commits/#{commit}/comments", body: options.merge(note: note))
81
- end
82
- alias repo_create_commit_comment create_commit_comment
67
+ # Creates a new comment for a commit.
68
+ #
69
+ # @example
70
+ # Gitlab.create_commit_comment(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b', 'Nice work on this commit!')
71
+ #
72
+ # @param [Integer, String] project The ID or name of a project.
73
+ # @param [String] sha The commit hash or name of a repository branch or tag.
74
+ # @param [String] note The text of a comment.
75
+ # @param [Hash] options A customizable set of options.
76
+ # @option options [String] :path The file path.
77
+ # @option options [Integer] :line The line number.
78
+ # @option options [String] :line_type The line type (new or old).
79
+ # @return [Gitlab::ObjectifiedHash] Information about created comment.
80
+ def create_commit_comment(project, commit, note, options = {})
81
+ post("/projects/#{url_encode project}/repository/commits/#{commit}/comments", body: options.merge(note: note))
82
+ end
83
+ alias repo_create_commit_comment create_commit_comment
83
84
 
84
- # Get the status of a commit
85
- #
86
- # @example
87
- # Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
88
- # Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins' })
89
- # Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins', all: true })
90
- #
91
- # @param [Integer, String] project The ID or name of a project.
92
- # @param [String] sha The commit hash
93
- # @param [Hash] options A customizable set of options.
94
- # @option options [String] :ref Filter by ref name, it can be branch or tag
95
- # @option options [String] :stage Filter by stage
96
- # @option options [String] :name Filter by status name, eg. jenkins
97
- # @option options [Boolean] :all The flag to return all statuses, not only latest ones
98
- def commit_status(project, sha, options = {})
99
- get("/projects/#{url_encode project}/repository/commits/#{sha}/statuses", query: options)
100
- end
101
- alias repo_commit_status commit_status
85
+ # Get the status of a commit
86
+ #
87
+ # @example
88
+ # Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
89
+ # Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins' })
90
+ # Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins', all: true })
91
+ #
92
+ # @param [Integer, String] project The ID or name of a project.
93
+ # @param [String] sha The commit hash
94
+ # @param [Hash] options A customizable set of options.
95
+ # @option options [String] :ref Filter by ref name, it can be branch or tag
96
+ # @option options [String] :stage Filter by stage
97
+ # @option options [String] :name Filter by status name, eg. jenkins
98
+ # @option options [Boolean] :all The flag to return all statuses, not only latest ones
99
+ def commit_status(project, sha, options = {})
100
+ get("/projects/#{url_encode project}/repository/commits/#{sha}/statuses", query: options)
101
+ end
102
+ alias repo_commit_status commit_status
102
103
 
103
- # Adds or updates a status of a commit.
104
- #
105
- # @example
106
- # Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'success')
107
- # Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'failed', { name: 'jenkins' })
108
- # Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'canceled', { name: 'jenkins', target_url: 'http://example.com/builds/1' })
109
- #
110
- # @param [Integer, String] project The ID or name of a project.
111
- # @param [String] sha The commit hash
112
- # @param [String] state of the status. Can be: pending, running, success, failed, canceled
113
- # @param [Hash] options A customizable set of options.
114
- # @option options [String] :ref The ref (branch or tag) to which the status refers
115
- # @option options [String] :name Filter by status name, eg. jenkins
116
- # @option options [String] :target_url The target URL to associate with this status
117
- def update_commit_status(project, sha, state, options = {})
118
- post("/projects/#{url_encode project}/statuses/#{sha}", query: options.merge(state: state))
119
- end
120
- alias repo_update_commit_status update_commit_status
104
+ # Adds or updates a status of a commit.
105
+ #
106
+ # @example
107
+ # Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'success')
108
+ # Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'failed', { name: 'jenkins' })
109
+ # Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'canceled', { name: 'jenkins', target_url: 'http://example.com/builds/1' })
110
+ #
111
+ # @param [Integer, String] project The ID or name of a project.
112
+ # @param [String] sha The commit hash
113
+ # @param [String] state of the status. Can be: pending, running, success, failed, canceled
114
+ # @param [Hash] options A customizable set of options.
115
+ # @option options [String] :ref The ref (branch or tag) to which the status refers
116
+ # @option options [String] :name Filter by status name, eg. jenkins
117
+ # @option options [String] :target_url The target URL to associate with this status
118
+ def update_commit_status(project, sha, state, options = {})
119
+ post("/projects/#{url_encode project}/statuses/#{sha}", query: options.merge(state: state))
120
+ end
121
+ alias repo_update_commit_status update_commit_status
121
122
 
122
- # Creates a single commit with one or more changes
123
- #
124
- # @see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
125
- # Introduced in Gitlab 8.13
126
- #
127
- # @example
128
- # Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'create', file_path: '/foo.txt', content: 'bar'}])
129
- # Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'delete', file_path: '/foo.txt'}])
130
- #
131
- # @param [Integer, String] project The ID or name of a project.
132
- # @param [String] branch the branch name you wish to commit to
133
- # @param [String] message the commit message
134
- # @param [Array[Hash]] An array of action hashes to commit as a batch. See the next table for what attributes it can take.
135
- # @option options [String] :author_email the email address of the author
136
- # @option options [String] :author_name the name of the author
137
- # @return [Gitlab::ObjectifiedHash] hash of commit related data
138
- def create_commit(project, branch, message, actions, options = {})
139
- payload = {
140
- branch: branch,
141
- commit_message: message,
142
- actions: actions
143
- }.merge(options)
144
- post("/projects/#{url_encode project}/repository/commits", body: payload)
145
- end
123
+ # Creates a single commit with one or more changes
124
+ #
125
+ # @see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
126
+ # Introduced in Gitlab 8.13
127
+ #
128
+ # @example
129
+ # Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'create', file_path: '/foo.txt', content: 'bar'}])
130
+ # Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'delete', file_path: '/foo.txt'}])
131
+ #
132
+ # @param [Integer, String] project The ID or name of a project.
133
+ # @param [String] branch the branch name you wish to commit to
134
+ # @param [String] message the commit message
135
+ # @param [Array[Hash]] An array of action hashes to commit as a batch. See the next table for what attributes it can take.
136
+ # @option options [String] :author_email the email address of the author
137
+ # @option options [String] :author_name the name of the author
138
+ # @return [Gitlab::ObjectifiedHash] hash of commit related data
139
+ def create_commit(project, branch, message, actions, options = {})
140
+ payload = {
141
+ branch: branch,
142
+ commit_message: message,
143
+ actions: actions
144
+ }.merge(options)
145
+ post("/projects/#{url_encode project}/repository/commits", body: payload)
146
+ end
146
147
 
147
- # Gets a list of merge requests for a commit.
148
- #
149
- # @see https://docs.gitlab.com/ce/api/commits.html#list-merge-requests-associated-with-a-commit
150
- # Introduced in Gitlab 10.7
151
- #
152
- # @example
153
- # Gitlab.commit_merge_requests(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b')
154
- #
155
- # @param [Integer] project The ID of a project.
156
- # @param [String] sha The commit hash.
157
- # @option options [Integer] :page The page number.
158
- # @option options [Integer] :per_page The number of results per page.
159
- # @return [Array<Gitlab::ObjectifiedHash>]
160
- def commit_merge_requests(project, commit, options = {})
161
- get("/projects/#{url_encode project}/repository/commits/#{commit}/merge_requests", query: options)
148
+ # Gets a list of merge requests for a commit.
149
+ #
150
+ # @see https://docs.gitlab.com/ce/api/commits.html#list-merge-requests-associated-with-a-commit
151
+ # Introduced in Gitlab 10.7
152
+ #
153
+ # @example
154
+ # Gitlab.commit_merge_requests(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b')
155
+ #
156
+ # @param [Integer] project The ID of a project.
157
+ # @param [String] sha The commit hash.
158
+ # @option options [Integer] :page The page number.
159
+ # @option options [Integer] :per_page The number of results per page.
160
+ # @return [Array<Gitlab::ObjectifiedHash>]
161
+ def commit_merge_requests(project, commit, options = {})
162
+ get("/projects/#{url_encode project}/repository/commits/#{commit}/merge_requests", query: options)
163
+ end
164
+ alias repo_commit_merge_requests commit_merge_requests
162
165
  end
163
- alias repo_commit_merge_requests commit_merge_requests
164
166
  end