Module: Octokit::Client::Commits
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/commits.rb
Overview
Methods for the Commits API
Instance Method Summary collapse
-
#commit(repo, sha, options = {}) ⇒ Sawyer::Resource
Get a single commit.
-
#commit_comment(repo, id, options = {}) ⇒ Sawyer::Resource
Get a single commit comment.
-
#commit_comments(repo, sha, options = {}) ⇒ Array
List comments for a single commit.
-
#commits(*args) ⇒ Array<Sawyer::Resource>
(also: #list_commits)
List commits.
-
#commits_before(*args) ⇒ Array<Sawyer::Resource>
Get commits before a specified date.
-
#commits_between(*args) ⇒ Array<Sawyer::Resource>
Get commits made between two nominated dates.
-
#commits_on(*args) ⇒ Array<Sawyer::Resource>
Get commits on a specified date.
-
#commits_since(*args) ⇒ Array<Sawyer::Resource>
Get commits after a specified date.
-
#compare(repo, start, endd, options = {}) ⇒ Sawyer::Resource
Compare two commits.
-
#create_commit(repo, message, tree, parents = nil, options = {}) ⇒ Sawyer::Resource
Create a commit.
-
#create_commit_comment(repo, sha, body, path = nil, line = nil, position = nil, options = {}) ⇒ Sawyer::Resource
Create a commit comment.
-
#delete_commit_comment(repo, id, options = {}) ⇒ nil
Delete a commit comment.
-
#git_commit(repo, sha, options = {}) ⇒ Sawyer::Resource
Get a detailed git commit.
-
#list_commit_comments(repo, options = {}) ⇒ Array
List all commit comments.
-
#merge(repo, base, head, options = {}) ⇒ Sawyer::Resource
Merge a branch or sha.
-
#update_commit_comment(repo, id, body, options = {}) ⇒ Sawyer::Resource
Update a commit comment.
Instance Method Details
#commit(repo, sha, options = {}) ⇒ Sawyer::Resource
Get a single commit
153 154 155 |
# File 'lib/octokit/client/commits.rb', line 153 def commit(repo, sha, = {}) get "repos/#{Repository.new(repo)}/commits/#{sha}", end |
#commit_comment(repo, id, options = {}) ⇒ Sawyer::Resource
Get a single commit comment
217 218 219 |
# File 'lib/octokit/client/commits.rb', line 217 def commit_comment(repo, id, = {}) get "repos/#{Repository.new(repo)}/comments/#{id}", end |
#commit_comments(repo, sha, options = {}) ⇒ Array
List comments for a single commit
207 208 209 |
# File 'lib/octokit/client/commits.rb', line 207 def commit_comments(repo, sha, = {}) get "repos/#{Repository.new(repo)}/commits/#{sha}/comments", end |
#commits(repo, sha_or_branch, options = {}) ⇒ Array<Sawyer::Resource> #commits(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_commits
List commits
23 24 25 26 27 28 29 30 |
# File 'lib/octokit/client/commits.rb', line 23 def commits(*args) arguments = Octokit::RepoArguments.new(args) sha_or_branch = arguments.pop if sha_or_branch arguments.[:sha] = sha_or_branch end paginate "repos/#{Repository.new(arguments.repo)}/commits", arguments. end |
#commits_before(repo, date, options = {}) ⇒ Array<Sawyer::Resource> #commits_before(repo, date, sha_or_branch, options = {}) ⇒ Array<Sawyer::Resource>
Get commits before a specified date
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/octokit/client/commits.rb', line 76 def commits_before(*args) arguments = Octokit::RepoArguments.new(args) date = parse_date(arguments.shift) params = arguments. end_date = date + 1 params.merge!(:until => iso8601(date)) sha_or_branch = arguments.pop if sha_or_branch params[:sha] = sha_or_branch end commits(arguments.repo, params) end |
#commits_between(repo, start_date, end_date, options = {}) ⇒ Array<Sawyer::Resource> #commits_between(repo, start_date, end_date, sha_or_branch, options = {}) ⇒ Array<Sawyer::Resource>
Get commits made between two nominated dates
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/octokit/client/commits.rb', line 132 def commits_between(*args) arguments = Octokit::RepoArguments.new(args) date = parse_date(arguments.shift) end_date = parse_date(arguments.shift) raise ArgumentError, "Start date #{date} does not precede #{end_date}" if date > end_date params = arguments. params.merge!(:since => iso8601(date), :until => iso8601(end_date)) sha_or_branch = arguments.pop if sha_or_branch params[:sha] = sha_or_branch end commits(arguments.repo, params) end |
#commits_on(repo, date, options = {}) ⇒ Array<Sawyer::Resource> #commits_on(repo, date, sha_or_branch, options = {}) ⇒ Array<Sawyer::Resource>
Get commits on a specified date
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/octokit/client/commits.rb', line 103 def commits_on(*args) arguments = Octokit::RepoArguments.new(args) date = parse_date(arguments.shift) params = arguments. end_date = date + 1 params.merge!(:since => iso8601(date), :until => iso8601(end_date)) sha_or_branch = arguments.pop if sha_or_branch params[:sha] = sha_or_branch end commits(arguments.repo, params) end |
#commits_since(repo, date, options = {}) ⇒ Array<Sawyer::Resource> #commits_since(repo, date, sha_or_branch, options = {}) ⇒ Array<Sawyer::Resource>
Get commits after a specified date
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/octokit/client/commits.rb', line 49 def commits_since(*args) arguments = Octokit::RepoArguments.new(args) date = parse_date(arguments.shift) params = arguments. end_date = date + 1 params.merge!(:since => iso8601(date)) sha_or_branch = arguments.pop if sha_or_branch params[:sha] = sha_or_branch end commits(arguments.repo, params) end |
#compare(repo, start, endd, options = {}) ⇒ Sawyer::Resource
Compare two commits
284 285 286 |
# File 'lib/octokit/client/commits.rb', line 284 def compare(repo, start, endd, = {}) get "repos/#{Repository.new(repo)}/compare/#{start}...#{endd}", end |
#create_commit(repo, message, tree, parents = nil, options = {}) ⇒ Sawyer::Resource
Create a commit
Optionally pass author
and committer
hashes in options
if you’d like manual control over those parameters. If absent, details will be inferred from the authenticated user. See <a href=“developer.github.com/v3/git/commits/”>GitHub’s documentation</a> for details about how to format committer identities.
186 187 188 189 190 |
# File 'lib/octokit/client/commits.rb', line 186 def create_commit(repo, , tree, parents=nil, = {}) params = { :message => , :tree => tree } params[:parents] = [parents].flatten if parents post "repos/#{Repository.new(repo)}/git/commits", .merge(params) end |
#create_commit_comment(repo, sha, body, path = nil, line = nil, position = nil, options = {}) ⇒ Sawyer::Resource
Create a commit comment
238 239 240 241 242 243 244 245 246 247 |
# File 'lib/octokit/client/commits.rb', line 238 def create_commit_comment(repo, sha, body, path=nil, line=nil, position=nil, = {}) params = { :body => body, :commit_id => sha, :path => path, :line => line, :position => position } post "repos/#{Repository.new(repo)}/commits/#{sha}/comments", .merge(params) end |
#delete_commit_comment(repo, id, options = {}) ⇒ nil
Delete a commit comment
273 274 275 |
# File 'lib/octokit/client/commits.rb', line 273 def delete_commit_comment(repo, id, = {}) boolean_from_response :delete, "repos/#{Repository.new(repo)}/comments/#{id}", end |
#git_commit(repo, sha, options = {}) ⇒ Sawyer::Resource
Get a detailed git commit
163 164 165 |
# File 'lib/octokit/client/commits.rb', line 163 def git_commit(repo, sha, = {}) get "repos/#{Repository.new(repo)}/git/commits/#{sha}", end |
#list_commit_comments(repo, options = {}) ⇒ Array
List all commit comments
197 198 199 |
# File 'lib/octokit/client/commits.rb', line 197 def list_commit_comments(repo, = {}) get "repos/#{Repository.new(repo)}/comments", end |
#merge(repo, base, head, options = {}) ⇒ Sawyer::Resource
Merge a branch or sha
296 297 298 299 300 301 302 |
# File 'lib/octokit/client/commits.rb', line 296 def merge(repo, base, head, = {}) params = { :base => base, :head => head }.merge() post "repos/#{Repository.new(repo)}/merges", params end |
#update_commit_comment(repo, id, body, options = {}) ⇒ Sawyer::Resource
Update a commit comment
260 261 262 263 264 265 |
# File 'lib/octokit/client/commits.rb', line 260 def update_commit_comment(repo, id, body, = {}) params = { :body => body } patch "repos/#{Repository.new(repo)}/comments/#{id}", .merge(params) end |