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) ⇒ 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.
-
#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) ⇒ Gitlab::ObjectifiedHash
Cherry picks a commit to a given branch.
63 64 65 |
# File 'lib/gitlab/client/commits.rb', line 63 def cherry_pick_commit(project, sha, branch) post("/projects/#{url_encode project}/repository/commits/#{sha}/cherry_pick", body: { branch: branch }) 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.
91 92 93 |
# File 'lib/gitlab/client/commits.rb', line 91 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.
76 77 78 |
# File 'lib/gitlab/client/commits.rb', line 76 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
190 191 192 |
# File 'lib/gitlab/client/commits.rb', line 190 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
128 129 130 |
# File 'lib/gitlab/client/commits.rb', line 128 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’])
168 169 170 171 172 173 174 175 |
# File 'lib/gitlab/client/commits.rb', line 168 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.
109 110 111 |
# File 'lib/gitlab/client/commits.rb', line 109 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.
147 148 149 |
# File 'lib/gitlab/client/commits.rb', line 147 def update_commit_status(project, sha, state, = {}) post("/projects/#{url_encode project}/statuses/#{sha}", query: .merge(state: state)) end |