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
-
#cherry_pick_commit(project, sha, branch, options = {}) ⇒ Gitlab::ObjectifiedHash
Cherry picks a commit to a given branch.
-
#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_refs(project, sha, options = {}) ⇒ Gitlab::ObjectifiedHash
Get all references (from branches or tags) a commit is pushed to.
-
#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.
-
#revert_commit(project, sha, branch, options = {}) ⇒ Gitlab::ObjectifiedHash
Reverts a commit in a given branch.
-
#update_commit_status(project, sha, state, options = {}) ⇒ Object
(also: #repo_update_commit_status)
Adds or updates a status of a commit.
Instance Method Details
#cherry_pick_commit(project, sha, branch, options = {}) ⇒ Gitlab::ObjectifiedHash
Cherry picks a commit to a given branch.
65 66 67 68 69 |
# File 'lib/gitlab/client/commits.rb', line 65 def cherry_pick_commit(project, sha, branch, = {}) [:branch] = branch post("/projects/#{url_encode project}/repository/commits/#{sha}/cherry_pick", body: ) end |
#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.
112 113 114 |
# File 'lib/gitlab/client/commits.rb', line 112 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.
97 98 99 |
# File 'lib/gitlab/client/commits.rb', line 97 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
211 212 213 |
# File 'lib/gitlab/client/commits.rb', line 211 def commit_merge_requests(project, commit, = {}) get("/projects/#{url_encode project}/repository/commits/#{commit}/merge_requests", query: ) end |
#commit_refs(project, sha, options = {}) ⇒ Gitlab::ObjectifiedHash
Get all references (from branches or tags) a commit is pushed to.
50 51 52 |
# File 'lib/gitlab/client/commits.rb', line 50 def commit_refs(project, sha, = {}) get("/projects/#{url_encode project}/repository/commits/#{sha}/refs", query: ) end |
#commit_status(project, sha, options = {}) ⇒ Object Also known as: repo_commit_status
Get the status of a commit
149 150 151 |
# File 'lib/gitlab/client/commits.rb', line 149 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’])
189 190 191 192 193 194 195 196 |
# File 'lib/gitlab/client/commits.rb', line 189 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.
130 131 132 |
# File 'lib/gitlab/client/commits.rb', line 130 def create_commit_comment(project, commit, note, = {}) post("/projects/#{url_encode project}/repository/commits/#{commit}/comments", body: .merge(note: note)) end |
#revert_commit(project, sha, branch, options = {}) ⇒ Gitlab::ObjectifiedHash
Reverts a commit in a given branch.
82 83 84 85 86 |
# File 'lib/gitlab/client/commits.rb', line 82 def revert_commit(project, sha, branch, = {}) [:branch] = branch post("/projects/#{url_encode project}/repository/commits/#{sha}/revert", body: ) end |
#update_commit_status(project, sha, state, options = {}) ⇒ Object Also known as: repo_update_commit_status
Adds or updates a status of a commit.
168 169 170 |
# File 'lib/gitlab/client/commits.rb', line 168 def update_commit_status(project, sha, state, = {}) post("/projects/#{url_encode project}/statuses/#{sha}", body: .merge(state: state)) end |