Module: Octokit::Client::Commits
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/commits.rb
Instance Method Summary collapse
-
#commit(repo, sha, options = {}) ⇒ Hashie::Mash
Get a single commit.
-
#commit_comment(repo, id, options = {}) ⇒ Hashie::Mash
Get a single commit comment.
-
#commit_comments(repo, sha, options = {}) ⇒ Array
List comments for a single commit.
-
#commits(repo, sha_or_branch = "master", options = {}) ⇒ Array
(also: #list_commits)
List commits.
-
#commits_before(repo, date, sha_or_branch = "master", options = {}) ⇒ Array
Get commits before a specified date.
-
#commits_between(repo, start_date, end_date, sha_or_branch = "master", options = {}) ⇒ Array
Get commits made between two nominated dates.
-
#commits_on(repo, date, sha_or_branch = "master", options = {}) ⇒ Array
Get commits on a specified date.
-
#commits_since(repo, date, sha_or_branch = "master", options = {}) ⇒ Array
Get commits after a specified date.
-
#compare(repo, start, endd, options = {}) ⇒ Hashie::Mash
Compare two commits.
-
#create_commit(repo, message, tree, parents = nil, options = {}) ⇒ Hashie::Mash
Create a commit.
-
#create_commit_comment(repo, sha, body, path = nil, line = nil, position = nil, options = {}) ⇒ Hashie::Mash
Create a commit comment.
-
#delete_commit_comment(repo, id, options = {}) ⇒ nil
Delete a commit comment.
-
#list_commit_comments(repo, options = {}) ⇒ Array
List all commit comments.
-
#merge(repo, base, head, options = {}) ⇒ Hashie::Mash
Merge a branch or sha.
-
#update_commit_comment(repo, id, body, options = {}) ⇒ Hashie::Mash
Update a commit comment.
Instance Method Details
#commit(repo, sha, options = {}) ⇒ Hashie::Mash
Get a single commit
28 29 30 |
# File 'lib/octokit/client/commits.rb', line 28 def commit(repo, sha, ={}) get("repos/#{Repository.new(repo)}/commits/#{sha}", ) end |
#commit_comment(repo, id, options = {}) ⇒ Hashie::Mash
Get a single commit comment
82 83 84 |
# File 'lib/octokit/client/commits.rb', line 82 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
72 73 74 |
# File 'lib/octokit/client/commits.rb', line 72 def commit_comments(repo, sha, ={}) get("repos/#{Repository.new(repo)}/commits/#{sha}/comments", ) end |
#commits(repo, sha_or_branch = "master", options = {}) ⇒ Array Also known as: list_commits
List commits
Optionally pass path => "path/to/file.rb"
in options
to only return commits containing the given file path.
16 17 18 19 |
# File 'lib/octokit/client/commits.rb', line 16 def commits(repo, sha_or_branch="master", ={}) params = { :sha => sha_or_branch, :per_page => 35 } get("repos/#{Repository.new(repo)}/commits", params.merge()) end |
#commits_before(repo, date, sha_or_branch = "master", options = {}) ⇒ Array
Get commits before a specified date
194 195 196 197 |
# File 'lib/octokit/client/commits.rb', line 194 def commits_before(repo, date, sha_or_branch="master", ={}) params = {:until => iso8601(parse_date(date))} commits(repo, sha_or_branch, params.merge()) end |
#commits_between(repo, start_date, end_date, sha_or_branch = "master", options = {}) ⇒ Array
Get commits made between two nominated dates
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/octokit/client/commits.rb', line 231 def commits_between(repo, start_date, end_date, sha_or_branch="master", ={}) begin # defaults to 00:00:00 # use a second var for the parsed date so error message is consistent _start_date = DateTime.parse(start_date) rescue ArgumentError raise ArgumentError, "#{start_date} is not a valid date" end begin # defaults to 00:00:00 # use a second var for the parsed date so error message is consistent _end_date = DateTime.parse(end_date) rescue ArgumentError raise ArgumentError, "#{end_date} is not a valid date" end if _end_date < _start_date raise ArgumentError, "Start date #{start_date} does not precede #{end_date}" end params = {:since => iso8601(_start_date), :until => iso8601(_end_date) } commits(repo, sha_or_branch, params.merge()) end |
#commits_on(repo, date, sha_or_branch = "master", options = {}) ⇒ Array
Get commits on a specified date
208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/octokit/client/commits.rb', line 208 def commits_on(repo, date, sha_or_branch="master", ={}) begin # defaults to 00:00:00 start_date = DateTime.parse(date) # addition defaults to n days end_date = start_date + 1 rescue ArgumentError raise ArgumentError, "#{date} is not a valid date" end params = { :since => iso8601(start_date), :until => iso8601(end_date) } commits(repo, sha_or_branch, params.merge()) end |
#commits_since(repo, date, sha_or_branch = "master", options = {}) ⇒ Array
Get commits after a specified date
180 181 182 183 |
# File 'lib/octokit/client/commits.rb', line 180 def commits_since(repo, date, sha_or_branch="master", ={}) params = {:since => iso8601(parse_date(date))} commits(repo, sha_or_branch, params.merge()) end |
#compare(repo, start, endd, options = {}) ⇒ Hashie::Mash
Compare two commits
149 150 151 |
# File 'lib/octokit/client/commits.rb', line 149 def compare(repo, start, endd, ={}) get("repos/#{Repository.new(repo)}/compare/#{start}...#{endd}", ) end |
#create_commit(repo, message, tree, parents = nil, options = {}) ⇒ Hashie::Mash
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.
51 52 53 54 55 |
# File 'lib/octokit/client/commits.rb', line 51 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 = {}) ⇒ Hashie::Mash
Create a commit comment
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/octokit/client/commits.rb', line 103 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
138 139 140 |
# File 'lib/octokit/client/commits.rb', line 138 def delete_commit_comment(repo, id, ={}) boolean_from_response(:delete, "repos/#{Repository.new(repo)}/comments/#{id}", ) end |
#list_commit_comments(repo, options = {}) ⇒ Array
List all commit comments
62 63 64 |
# File 'lib/octokit/client/commits.rb', line 62 def list_commit_comments(repo, ={}) get("repos/#{Repository.new(repo)}/comments", ) end |
#merge(repo, base, head, options = {}) ⇒ Hashie::Mash
Merge a branch or sha
161 162 163 164 165 166 167 |
# File 'lib/octokit/client/commits.rb', line 161 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 = {}) ⇒ Hashie::Mash
Update a commit comment
125 126 127 128 129 130 |
# File 'lib/octokit/client/commits.rb', line 125 def update_commit_comment(repo, id, body, ={}) params = { :body => body } patch("repos/#{Repository.new(repo)}/comments/#{id}", .merge(params)) end |