Class: GitReflow::GitServer::BitBucket
- Inherits:
-
Base
- Object
- Base
- GitReflow::GitServer::BitBucket
show all
- Defined in:
- lib/git_reflow/git_server/bit_bucket.rb,
lib/git_reflow/git_server/bit_bucket/pull_request.rb
Defined Under Namespace
Classes: PullRequest
Constant Summary
Constants included
from Sandbox
Sandbox::COLOR_FOR_LABEL
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
api_endpoint=, project_only?, site_url=
#append_to_merge_commit_message, #current_branch, #default_base_branch, #default_editor, #fetch_destination, #get_first_commit_message, #git_editor_command, #git_root_dir, #merge_commit_template, #merge_message_path, #pull_request_template, #push_current_branch, #remote_repo_name, #remote_user, #update_current_branch, #update_destination, #update_feature_branch
Methods included from Sandbox
#run, #run_command_with_label, #say
Constructor Details
#initialize(config_options = {}) ⇒ BitBucket
Returns a new instance of BitBucket.
11
12
13
14
15
16
17
18
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 11
def initialize(config_options = {})
project_only = !!config_options.delete(:project_only)
GitReflow::Config.unset('reflow.local-projects', value: "#{self.class.remote_user}/#{self.class.remote_repo_name}")
GitReflow::Config.add('reflow.local-projects', "#{self.class.remote_user}/#{self.class.remote_repo_name}") if project_only
GitReflow::Config.set('reflow.git-server', 'BitBucket', local: project_only)
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
9
10
11
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 9
def connection
@connection
end
|
Class Method Details
.api_endpoint ⇒ Object
26
27
28
29
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 26
def self.api_endpoint
endpoint = GitReflow::Config.get("bitbucket.endpoint", local: project_only?)
(endpoint.length > 0) ? endpoint : ::BitBucket::Configuration::DEFAULT_ENDPOINT
end
|
.api_key ⇒ Object
36
37
38
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 36
def self.api_key
GitReflow::Config.get("bitbucket.api-key", reload: true, local: project_only?)
end
|
.api_key=(key) ⇒ Object
40
41
42
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 40
def self.api_key=(key)
GitReflow::Config.set("bitbucket.api-key", key, local: project_only?)
end
|
.api_key_setup? ⇒ Boolean
43
44
45
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 43
def self.api_key_setup?
(self.api_key.length > 0)
end
|
.connection ⇒ Object
20
21
22
23
24
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 20
def self.connection
if api_key_setup?
@connection ||= ::BitBucket.new login: remote_user, password: api_key
end
end
|
.site_url ⇒ Object
31
32
33
34
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 31
def self.site_url
site_url = GitReflow::Config.get("bitbucket.site", local: project_only?)
(site_url.length > 0) ? site_url : 'https://bitbucket.org'
end
|
.user ⇒ Object
47
48
49
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 47
def self.user
GitReflow::Config.get('bitbucket.user', local: project_only?)
end
|
.user=(bitbucket_user) ⇒ Object
51
52
53
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 51
def self.user=(bitbucket_user)
GitReflow::Config.set('bitbucket.user', bitbucket_user, local: project_only?)
end
|
Instance Method Details
#authenticate(options = {silent: false}) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 55
def authenticate(options = {silent: false})
begin
if connection and self.class.api_key_setup?
unless options[:silent]
GitReflow.say "\nYour BitBucket account was already setup with:"
GitReflow.say "\tUser Name: #{self.class.user}"
end
else
self.class.user = options[:user] || ask("Please enter your BitBucket username: ")
GitReflow.say "\nIn order to connect your BitBucket account,"
GitReflow.say "you'll need to generate an API key for your team"
GitReflow.say "Visit #{self.class.site_url}/account/user/#{self.class.remote_user}/api-key/, to generate it\n"
self.class.api_key = ask("Please enter your team's API key: ")
connection.repos.all(self.class.remote_user).count
GitReflow.say "Connected to BitBucket\!", :success
end
rescue ::BitBucket::Error::Unauthorized => e
GitReflow::Config.unset('bitbucket.api-key', local: self.class.project_only?)
GitReflow.say "Invalid API key for team #{self.class.remote_user}.", :error
end
end
|
#colorized_build_description(state, description) ⇒ Object
87
88
89
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 87
def colorized_build_description(state, description)
""
end
|
#create_pull_request(options = {}) ⇒ Object
91
92
93
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 91
def create_pull_request(options = {})
PullRequest.create(options)
end
|
#find_open_pull_request(options = {}) ⇒ Object
95
96
97
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 95
def find_open_pull_request(options = {})
PullRequest.find_open(options)
end
|
#get_build_status(sha) ⇒ Object
81
82
83
84
85
|
# File 'lib/git_reflow/git_server/bit_bucket.rb', line 81
def get_build_status(sha)
return nil
end
|