module GitBak::Services::Bitbucket
Constants
- API
- HTTPS
- SSH
Public Class Methods
cat_json_values(pages)
click to toggle source
# File lib/gitbak/services/bitbucket.rb, line 30 def self.cat_json_values(pages) pages.map { |x| x['values'] } .flatten(1) .sort_by { |x| x['name'] } end
configure(cfg, dir, opts = {})
click to toggle source
# File lib/gitbak/services/bitbucket.rb, line 34 def self.configure(cfg, dir, opts = {}) # {{{1 u = opts[:user] or raise 'no user' # TODO c = cfg[:bitbucket] ||= [] a = if opts[:auth] == false nil else p = GitBak::Misc.prompt "password for bitbucket/#{u}: ", true { user: u, pass: p } end c << { dir: dir, user: u, auth: a, method: opts[:method] } end
fetch(cfg, verbose)
click to toggle source
# File lib/gitbak/services/bitbucket.rb, line 46 def self.fetch(cfg, verbose) # {{{1 f = method :to_json; pag = method :next_page join = method :cat_json_values (cfg[:bitbucket] || []).each do |x| meth = x[:method] == :https ? HTTPS : SSH info = "bitbucket/#{x[:user]}" print "fetching #{info} ..." if verbose repos = GitBak.paginate API[x[:user]], nil, info, x[:auth], f, pag, join x[:repos] = repos.select { |r| r['scm'] == 'git' } .map do |r| { name: r['name'], remote: meth[x[:user], r['name']], description: r['description'] } end puts " #{repos.length} repositories" if verbose end end
mirror(cfg, verbose, noact)
click to toggle source
# File lib/gitbak/services/bitbucket.rb, line 63 def self.mirror(cfg, verbose, noact) # {{{1 (cfg[:bitbucket] || []).each do |x| x[:repos].each do |r| GitBak.show_mirror 'bitbucket', x[:user], r[:name], r[:description] GitBak.mirror_repo verbose, noact, r[:remote], x[:dir] puts if verbose end end end
next_page(data)
click to toggle source
# File lib/gitbak/services/bitbucket.rb, line 26 def self.next_page(data) data['next'] end
summarise(cfg)
click to toggle source
# File lib/gitbak/services/bitbucket.rb, line 73 def self.summarise(cfg) (cfg[:bitbucket] || []).each do |x| GitBak.show_summary "bitbucket/#{x[:user]}", x[:repos].length end end
to_json(data)
click to toggle source
# File lib/gitbak/services/bitbucket.rb, line 22 def self.to_json(data) JSON.parse data end