Class: Tinybucket::Api::CommitsApi
- Includes:
- Helper::CommitsHelper
- Defined in:
- lib/tinybucket/api/commits_api.rb
Overview
Commits Api client
Constant Summary
Constants included from Connection
Connection::DEFAULT_USER_AGENT
Instance Attribute Summary collapse
-
#repo_owner ⇒ String
Repository owner name.
- #repo_slug ⇒ String
Instance Method Summary collapse
-
#approve(revision, options = {}) ⇒ true, false
Send ‘POST a commit approval’ request.
-
#branch(name, options = {}) ⇒ Tinybucket::Model::Commit
Send ‘GET commits for a branch’ request.
-
#find(revision, options = {}) ⇒ Tinybucket::Model::Commit
Send ‘GET an individual commit’ request.
-
#list(options = {}) ⇒ Tinybucket::Model::Page
Send ‘GET a commits list for a repository’ request.
-
#unapprove(revision, options = {}) ⇒ true, false
Send ‘DELETE a commit approval’ request.
Methods included from Connection
#caching?, #clear_cache, #connection
Instance Attribute Details
#repo_owner ⇒ String
Returns repository owner name.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/tinybucket/api/commits_api.rb', line 11 class CommitsApi < BaseApi include Tinybucket::Api::Helper::CommitsHelper attr_accessor :repo_owner, :repo_slug # Send 'GET a commits list for a repository' request # # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commits#get # GET a commits list for a repository # # @note This method does not support 'compare commits across branches' # API call, yet. # # @param options [Hash] # @return [Tinybucket::Model::Page] def list( = {}) get_path( path_to_list, , get_parser(:collection, Tinybucket::Model::Commit) ) end # Send 'GET an individual commit' request # # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commits/%7Brevision%7D#get # GET an individual commit # # @param revision [String] A SHA1 value for the commit. # @param options [Hash] # @return [Tinybucket::Model::Commit] def find(revision, = {}) get_path( path_to_find(revision), , get_parser(:object, Tinybucket::Model::Commit) ) end # Send 'POST a commit approval' request # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/approve#post # POST a commit approval request # # @param revision [String] # @param options [Hash] # @return [true, false] def approve(revision, = {}) result = post_path(path_to_approve(revision), ) (result['approved'] == true) rescue Tinybucket::Error::Conflict => e logger.debug 'Already approved: ' + e.inspect true end # Send 'DELETE a commit approval' request # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/approve#delete # DELETE a commit approval (unapprove the commit) # # @param revision [String] # @param options [Hash] # @return [true, false] def unapprove(revision, = {}) delete_path(path_to_approve(revision), ) true rescue Tinybucket::Error::NotFound => e logger.debug 'Already unapproved: ' + e.inspect true end # Send 'GET commits for a branch' request # # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commits # GET an individual commit # # @param name [String] The branch name or a SHA1 value for the commit. # @param options [Hash] # @return [Tinybucket::Model::Commit] def branch(name, = {}) get_path( path_to_branch(name), , get_parser(:collection, Tinybucket::Model::Commit) ) end end |
#repo_slug ⇒ String
Returns repository slug.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/tinybucket/api/commits_api.rb', line 11 class CommitsApi < BaseApi include Tinybucket::Api::Helper::CommitsHelper attr_accessor :repo_owner, :repo_slug # Send 'GET a commits list for a repository' request # # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commits#get # GET a commits list for a repository # # @note This method does not support 'compare commits across branches' # API call, yet. # # @param options [Hash] # @return [Tinybucket::Model::Page] def list( = {}) get_path( path_to_list, , get_parser(:collection, Tinybucket::Model::Commit) ) end # Send 'GET an individual commit' request # # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commits/%7Brevision%7D#get # GET an individual commit # # @param revision [String] A SHA1 value for the commit. # @param options [Hash] # @return [Tinybucket::Model::Commit] def find(revision, = {}) get_path( path_to_find(revision), , get_parser(:object, Tinybucket::Model::Commit) ) end # Send 'POST a commit approval' request # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/approve#post # POST a commit approval request # # @param revision [String] # @param options [Hash] # @return [true, false] def approve(revision, = {}) result = post_path(path_to_approve(revision), ) (result['approved'] == true) rescue Tinybucket::Error::Conflict => e logger.debug 'Already approved: ' + e.inspect true end # Send 'DELETE a commit approval' request # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/approve#delete # DELETE a commit approval (unapprove the commit) # # @param revision [String] # @param options [Hash] # @return [true, false] def unapprove(revision, = {}) delete_path(path_to_approve(revision), ) true rescue Tinybucket::Error::NotFound => e logger.debug 'Already unapproved: ' + e.inspect true end # Send 'GET commits for a branch' request # # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commits # GET an individual commit # # @param name [String] The branch name or a SHA1 value for the commit. # @param options [Hash] # @return [Tinybucket::Model::Commit] def branch(name, = {}) get_path( path_to_branch(name), , get_parser(:collection, Tinybucket::Model::Commit) ) end end |
Instance Method Details
#approve(revision, options = {}) ⇒ true, false
Send ‘POST a commit approval’ request
57 58 59 60 61 62 63 |
# File 'lib/tinybucket/api/commits_api.rb', line 57 def approve(revision, = {}) result = post_path(path_to_approve(revision), ) (result['approved'] == true) rescue Tinybucket::Error::Conflict => e logger.debug 'Already approved: ' + e.inspect true end |
#branch(name, options = {}) ⇒ Tinybucket::Model::Commit
Send ‘GET commits for a branch’ request
88 89 90 91 92 93 94 |
# File 'lib/tinybucket/api/commits_api.rb', line 88 def branch(name, = {}) get_path( path_to_branch(name), , get_parser(:collection, Tinybucket::Model::Commit) ) end |
#find(revision, options = {}) ⇒ Tinybucket::Model::Commit
Send ‘GET an individual commit’ request
42 43 44 45 46 47 48 |
# File 'lib/tinybucket/api/commits_api.rb', line 42 def find(revision, = {}) get_path( path_to_find(revision), , get_parser(:object, Tinybucket::Model::Commit) ) end |
#list(options = {}) ⇒ Tinybucket::Model::Page
Note:
This method does not support ‘compare commits across branches’ API call, yet.
Send ‘GET a commits list for a repository’ request
26 27 28 29 30 31 32 |
# File 'lib/tinybucket/api/commits_api.rb', line 26 def list( = {}) get_path( path_to_list, , get_parser(:collection, Tinybucket::Model::Commit) ) end |
#unapprove(revision, options = {}) ⇒ true, false
Send ‘DELETE a commit approval’ request
72 73 74 75 76 77 78 |
# File 'lib/tinybucket/api/commits_api.rb', line 72 def unapprove(revision, = {}) delete_path(path_to_approve(revision), ) true rescue Tinybucket::Error::NotFound => e logger.debug 'Already unapproved: ' + e.inspect true end |