Class: FlashFlow::Data::Bitbucket
- Inherits:
-
Object
- Object
- FlashFlow::Data::Bitbucket
- Defined in:
- lib/flash_flow/data/bitbucket.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#unmergeable_label ⇒ Object
Returns the value of attribute unmergeable_label.
Instance Method Summary collapse
- #add_to_merge(branch) ⇒ Object
- #branch_link(branch) ⇒ Object
- #can_ship?(branch) ⇒ Boolean
- #code_reviewed?(branch) ⇒ Boolean
- #fetch ⇒ Object
-
#initialize(config = {}) ⇒ Bitbucket
constructor
A new instance of Bitbucket.
- #initialize_connection!(oauth_token, oauth_secret) ⇒ Object
- #mark_failure(branch) ⇒ Object
- #mark_success(branch) ⇒ Object
- #remove_from_merge(branch) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Bitbucket
Returns a new instance of Bitbucket.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/flash_flow/data/bitbucket.rb', line 10 def initialize(config={}) initialize_connection!(config['oauth_token'], config['oauth_secret']) @repo_owner = config['repo_owner'] @repo = config['repo'] @master_branch = config['master_branch'] || 'master' @unmergeable_label = config['unmergeable_label'] || 'Flash Flow -- Unmergeable' @do_not_merge_label = config['do_not_merge_label'] || 'Flash Flow -- Do Not Merge' # @code_reviewed_label = config['code_reviewed_label'] || 'code reviewed' # @shippable_label = config['shippable_label'] || 'shippable' end |
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
8 9 10 |
# File 'lib/flash_flow/data/bitbucket.rb', line 8 def repo @repo end |
#unmergeable_label ⇒ Object
Returns the value of attribute unmergeable_label.
8 9 10 |
# File 'lib/flash_flow/data/bitbucket.rb', line 8 def unmergeable_label @unmergeable_label end |
Instance Method Details
#add_to_merge(branch) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/flash_flow/data/bitbucket.rb', line 49 def add_to_merge(branch) pr = pr_for(branch) pr ||= create_pr(branch.ref, branch.ref, branch.ref) branch.((pr)) if pr && @do_not_merge_label remove_labeling(pr, @do_not_merge_label) end end |
#branch_link(branch) ⇒ Object
76 77 78 |
# File 'lib/flash_flow/data/bitbucket.rb', line 76 def branch_link(branch) branch.['pr_url'] end |
#can_ship?(branch) ⇒ Boolean
72 73 74 |
# File 'lib/flash_flow/data/bitbucket.rb', line 72 def can_ship?(branch) is_labeled?(pr_for(branch), @shippable_label) end |
#code_reviewed?(branch) ⇒ Boolean
68 69 70 |
# File 'lib/flash_flow/data/bitbucket.rb', line 68 def code_reviewed?(branch) is_labeled?(pr_for(branch), @code_reviewed_label) end |
#fetch ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/flash_flow/data/bitbucket.rb', line 38 def fetch pull_requests.map do |pr| Branch.from_hash( 'ref' => pr.source['branch']['name'], 'status' => status_from_labeling(pr), 'metadata' => (pr), 'sha' => pr.source['commit']['hash'] ) end end |
#initialize_connection!(oauth_token, oauth_secret) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/flash_flow/data/bitbucket.rb', line 21 def initialize_connection!(oauth_token, oauth_secret) if oauth_token.nil? || oauth_secret.nil? raise RuntimeError.new("Oauth token and Oauth secret must be set in your flash_flow config file.") end Tinybucket.configure do |config| config.oauth_token = oauth_token config.oauth_secret = oauth_secret end end |
#mark_failure(branch) ⇒ Object
64 65 66 |
# File 'lib/flash_flow/data/bitbucket.rb', line 64 def mark_failure(branch) add_labeling(pr_for(branch), @unmergeable_label) end |
#mark_success(branch) ⇒ Object
60 61 62 |
# File 'lib/flash_flow/data/bitbucket.rb', line 60 def mark_success(branch) remove_labeling(pr_for(branch), @unmergeable_label) end |
#remove_from_merge(branch) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/flash_flow/data/bitbucket.rb', line 31 def remove_from_merge(branch) pr = pr_for(branch) if pr && @do_not_merge_label add_labeling(pr, @do_not_merge_label) end end |