Module: Gitlab::Client::Commits
- Included in:
- Gitlab::Client
- Defined in:
- lib/gitlab/client/commits.rb
Overview
Defines methods related to repository commits.
Instance Method Summary collapse
-
#commit(project, sha) ⇒ Gitlab::ObjectifiedHash
(also: #repo_commit)
Gets a specific commit identified by the commit hash or name of a branch or tag.
-
#commit_comments(project, commit, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
(also: #repo_commit_comments)
Gets a list of comments for a commit.
-
#commit_diff(project, sha) ⇒ Gitlab::ObjectifiedHash
(also: #repo_commit_diff)
Get the diff of a commit in a project.
-
#commit_merge_requests(project, commit, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
(also: #repo_commit_merge_requests)
Gets a list of merge requests for a commit.
-
#commit_status(project, sha, options = {}) ⇒ Object
(also: #repo_commit_status)
Get the status of a commit.
-
#commits(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
(also: #repo_commits)
Gets a list of project commits.
-
#create_commit(project, branch, message, actions, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a single commit with one or more changes.
-
#create_commit_comment(project, commit, note, options = {}) ⇒ Gitlab::ObjectifiedHash
(also: #repo_create_commit_comment)
Creates a new comment for a commit.
-
#update_commit_status(project, sha, state, options = {}) ⇒ Object
(also: #repo_update_commit_status)
Adds or updates a status of a commit.
Instance Method Details
#commit(project, sha) ⇒ Gitlab::ObjectifiedHash Also known as: repo_commit
Gets a specific commit identified by the commit hash or name of a branch or tag.
33 34 35 |
# File 'lib/gitlab/client/commits.rb', line 33 def commit(project, sha) get("/projects/#{url_encode project}/repository/commits/#{sha}") end |
#commit_comments(project, commit, options = {}) ⇒ Array<Gitlab::ObjectifiedHash> Also known as: repo_commit_comments
Gets a list of comments for a commit.
62 63 64 |
# File 'lib/gitlab/client/commits.rb', line 62 def commit_comments(project, commit, = {}) get("/projects/#{url_encode project}/repository/commits/#{commit}/comments", query: ) end |
#commit_diff(project, sha) ⇒ Gitlab::ObjectifiedHash Also known as: repo_commit_diff
Get the diff of a commit in a project.
47 48 49 |
# File 'lib/gitlab/client/commits.rb', line 47 def commit_diff(project, sha) get("/projects/#{url_encode project}/repository/commits/#{sha}/diff") end |
#commit_merge_requests(project, commit, options = {}) ⇒ Array<Gitlab::ObjectifiedHash> Also known as: repo_commit_merge_requests
Gets a list of merge requests for a commit.
Introduced in Gitlab 10.7
161 162 163 |
# File 'lib/gitlab/client/commits.rb', line 161 def commit_merge_requests(project, commit, = {}) get("/projects/#{url_encode project}/repository/commits/#{commit}/merge_requests", query: ) end |
#commit_status(project, sha, options = {}) ⇒ Object Also known as: repo_commit_status
Get the status of a commit
99 100 101 |
# File 'lib/gitlab/client/commits.rb', line 99 def commit_status(project, sha, = {}) get("/projects/#{url_encode project}/repository/commits/#{sha}/statuses", query: ) end |
#commits(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash> Also known as: repo_commits
Gets a list of project commits.
19 20 21 |
# File 'lib/gitlab/client/commits.rb', line 19 def commits(project, = {}) get("/projects/#{url_encode project}/repository/commits", query: ) end |
#create_commit(project, branch, message, actions, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a single commit with one or more changes
Introduced in Gitlab 8.13
Gitlab.create_commit(2726132, ‘master’, ‘refactors everything’, [‘create’, file_path: ‘/foo.txt’, content: ‘bar’]) Gitlab.create_commit(2726132, ‘master’, ‘refactors everything’, [‘delete’, file_path: ‘/foo.txt’])
139 140 141 142 143 144 145 146 |
# File 'lib/gitlab/client/commits.rb', line 139 def create_commit(project, branch, , actions, = {}) payload = { branch: branch, commit_message: , actions: actions }.merge() post("/projects/#{url_encode project}/repository/commits", body: payload) end |
#create_commit_comment(project, commit, note, options = {}) ⇒ Gitlab::ObjectifiedHash Also known as: repo_create_commit_comment
Creates a new comment for a commit.
80 81 82 |
# File 'lib/gitlab/client/commits.rb', line 80 def create_commit_comment(project, commit, note, = {}) post("/projects/#{url_encode project}/repository/commits/#{commit}/comments", body: .merge(note: note)) end |
#update_commit_status(project, sha, state, options = {}) ⇒ Object Also known as: repo_update_commit_status
Adds or updates a status of a commit.
118 119 120 |
# File 'lib/gitlab/client/commits.rb', line 118 def update_commit_status(project, sha, state, = {}) post("/projects/#{url_encode project}/statuses/#{sha}", query: .merge(state: state)) end |