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.
31 32 33 |
# File 'lib/gitlab/client/commits.rb', line 31 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.
60 61 62 |
# File 'lib/gitlab/client/commits.rb', line 60 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.
45 46 47 |
# File 'lib/gitlab/client/commits.rb', line 45 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
159 160 161 |
# File 'lib/gitlab/client/commits.rb', line 159 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
97 98 99 |
# File 'lib/gitlab/client/commits.rb', line 97 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.
17 18 19 |
# File 'lib/gitlab/client/commits.rb', line 17 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’])
137 138 139 140 141 142 143 144 |
# File 'lib/gitlab/client/commits.rb', line 137 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.
78 79 80 |
# File 'lib/gitlab/client/commits.rb', line 78 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.
116 117 118 |
# File 'lib/gitlab/client/commits.rb', line 116 def update_commit_status(project, sha, state, ={}) post("/projects/#{url_encode project}/statuses/#{sha}", query: .merge(state: state)) end |