|
3 | 3 | module BitBucket |
4 | 4 | class Repos::Commits < API |
5 | 5 |
|
6 | | - def get(user_name, repo_name) |
| 6 | + VALID_KEY_PARAM_NAMES = %w(include exclude).freeze |
| 7 | + |
| 8 | + # Gets the commit information associated with a repository. By default, this |
| 9 | + # call returns all the commits across all branches, bookmarks, and tags. The |
| 10 | + # newest commit is first. |
| 11 | + # |
| 12 | + # = Parameters |
| 13 | + # *<tt>include</tt> - The SHA, branch, bookmark, or tag to include, for example, v10 or master. You can repeat the parameter multiple times. |
| 14 | + # *<tt>exclude</tt> - The SHA, branch, bookmark, or tag to exclude, for example, v10 or master . You can repeat the parameter multiple times. |
| 15 | + # |
| 16 | + # = Examples |
| 17 | + # bitbucket = BitBucket.new |
| 18 | + # bitbucket.repos.commits.list 'user-name', 'repo-name' |
| 19 | + # bitbucket.repos.commits.list 'user-name', 'repo-name', 'master' |
| 20 | + # bitbucket.repos.commits.list 'user-name', 'repo-name' { |key| ... } |
| 21 | + # bitbucket.repos.commits.list 'user-name', 'repo-name', nil, |
| 22 | + # "include" => "feature-branch", |
| 23 | + # "exclude" => "master" |
| 24 | + # |
| 25 | + def list(user_name, repo_name, branchortag=nil, params={}) |
7 | 26 | _update_user_repo_params(user_name, repo_name) |
8 | 27 | _validate_user_repo_params(user, repo) unless user? && repo? |
9 | | - get_request("/2.0/repositories/#{user}/#{repo.downcase}/commits") |
10 | | - end |
| 28 | + normalize! params |
| 29 | + filter! VALID_KEY_PARAM_NAMES, params |
11 | 30 |
|
| 31 | + path = "/2.0/repositories/#{user}/#{repo.downcase}/commits" |
| 32 | + path << "/#{branchortag}" if branchortag |
| 33 | + response = get_request(path, params) |
| 34 | + return response unless block_given? |
| 35 | + response.each { |el| yield el } |
| 36 | + end |
| 37 | + alias :all :list |
12 | 38 |
|
13 | | - end # Repos::Keys |
| 39 | + end # Repos::Commits |
14 | 40 | end # BitBucket |
0 commit comments