bitbucket-cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4bd0bdc9f9398500baa8eb74ac59e73bf1d64d19
4
+ data.tar.gz: 6cc07b5dc874fd7a73581e9aee97e1533af75cf6
5
+ SHA512:
6
+ metadata.gz: e5a71191d6a7a063650f19cd6cb041b4b2d60b7db0a485849bdf34af91d404ab3d3b0b74797be4a587140881fb1fc0dfbde672043ecc09317780d4ee1ac8bdfe
7
+ data.tar.gz: 701a927946c15cb6a05b5c18f4681978ed44a6873facd5aaa1f4f857ee62613743ed4e6073b3773675e45886d5b77c534bd2cac44a82a3ec1bb151e89ba9c6b7
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bitbucket-cli.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Claus Witt
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Bitbucket::Cli
2
+
3
+ This gem is a plugin to git. Install it and have access to the bitbucket api directly from the git command.
4
+
5
+ ## Installation
6
+
7
+ Simple install:
8
+
9
+ $ gem install bitbucket-cli
10
+
11
+ ## Usage
12
+
13
+ Currently only repository creation is supported (since this was what I needed).
14
+
15
+ $ git bb account username password
16
+
17
+ This command stores your username and password in a clear text file called .gitbb in your home folder. (Yes, this is NOT secure).
18
+
19
+ $ git bb repository create
20
+
21
+ Creates a repository named after the current directory
22
+
23
+ $ git bb repository create repo-name
24
+
25
+ Creates a repository called "repo-name"
26
+
27
+ $ git bb repository create -p
28
+
29
+ Creates a private repository
30
+
31
+ $ git bb repository create --owner teamname
32
+
33
+ Creates a repository for the team "teamname" (you need to be member of that team off course)
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'daemons'
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
+ require 'bitbucket/cli/command'
6
+ Bitbucket::Cli::Command.start(ARGV)
7
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bitbucket/cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bitbucket-cli"
8
+ spec.version = Bitbucket::Cli::VERSION
9
+ spec.authors = ["Claus Witt"]
10
+ spec.email = ["claus@wittnezz.dk"]
11
+ spec.description = %q{git plugin for using bitbucket}
12
+ spec.summary = %q{interact with bitbucket through cli}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor"
22
+ spec.add_dependency "bitbucket_rest_api"
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,7 @@
1
+ require "bitbucket/cli/version"
2
+
3
+ module Bitbucket
4
+ module Cli
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ require 'thor'
2
+ require 'bitbucket/cli/commands/repository'
3
+ require 'bitbucket/cli/config'
4
+ module Bitbucket
5
+ module Cli
6
+ class Command < Thor
7
+ class_option :account, :default => ''
8
+ desc "repository SUBCOMMAND ...ARGS", "manage repositories"
9
+ subcommand "repository", Bitbucket::Cli::Commands::Repository
10
+
11
+
12
+ desc "account NAME PASSWORD", "adds a new account to config file"
13
+ def account(name='', password='')
14
+ Bitbucket::Cli::Config.new.add_account name, password
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,55 @@
1
+ require 'bitbucket_rest_api'
2
+ require 'thor'
3
+ require 'bitbucket/cli/config'
4
+ module Bitbucket
5
+ module Cli
6
+ module Commands
7
+ class Repository < Thor
8
+ class_option :account, :default => ''
9
+ desc "create NAME [-p] [-r|--remote]", "creates a repository on bitbucket"
10
+ option :p, :type => :boolean, :banner => 'private', :default => false
11
+ option :skip_remote, :type => :boolean, :aliases => :s
12
+ option :owner, :default => ''
13
+ option :issues, :type => :boolean, :default => true, :aliases => :i
14
+ option :wiki, :type => :boolean, :default => true, :aliases => :w
15
+ option :description, :default => '', :aliases => :d
16
+ option :website, :default => ''
17
+ def create(name='')
18
+ a = account(options[:account])
19
+ if a.nil?
20
+ puts 'No account, you need to select an account, or perhaps, create a new one?'
21
+ return
22
+ end
23
+ name = File.basename(Dir.getwd) if name == ''
24
+ bitbucket = BitBucket.new({:login=>a[:name], :password=>a[:password]})
25
+ repo = bitbucket.repos.create(repo_options(name, options))
26
+ puts repo
27
+ if options[:skip_remote].nil?
28
+ `git remote add origin git@bitbucket.org:#{repo['owner']}/#{repo['name']}.git`
29
+ end
30
+ end
31
+
32
+ no_commands do
33
+ def account name
34
+ puts "Getting account: #{name}"
35
+ Bitbucket::Cli::Config.new.get_account name
36
+ end
37
+
38
+ def repo_options name, options
39
+ opts = {
40
+ "name" => name,
41
+ "description" => options[:description],
42
+ "website" => options[:website],
43
+ "is_private" => options[:p],
44
+ "has_issues" => options[:issues],
45
+ "has_wiki" => options[:wiki]
46
+ }
47
+ opts['owner'] = options[:owner] unless @options[:owner] == ''
48
+ return opts
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,61 @@
1
+ require 'yaml'
2
+ module Bitbucket
3
+ module Cli
4
+ class Config
5
+ def initialize
6
+ @default_config = {
7
+ :accounts => [],
8
+ }
9
+ config_from_file
10
+ end
11
+
12
+ def add_account name, password
13
+ @config[:accounts] << {:name => name, :password => password}
14
+ write_file
15
+ end
16
+
17
+ def get_account name=''
18
+ return nil if @config.nil?
19
+ return nil if @config[:accounts].empty?
20
+ return @config[:accounts].first if name == ''
21
+ accounts = @config[:accounts].select {|a| a.has_key?(name)}
22
+ return nil if accounts.empty?
23
+ return accounts.first
24
+ end
25
+
26
+
27
+ def write key, val
28
+ @config[key] = val
29
+ write_file
30
+ end
31
+
32
+ def path
33
+ File.join(ENV['HOME'], '.gitbb')
34
+ end
35
+
36
+ def config_from_file
37
+ begin
38
+ config = YAML::load(IO.read(path))
39
+ rescue Errno::ENOENT
40
+ $stderr.puts(:warning, "YAML configuration file couldn't be found. Using defaults.");
41
+ rescue Psych::SyntaxError
42
+ $stderr.puts(:warning, "YAML configuration file contains invalid syntax. Using defaults.");
43
+ end
44
+ configure(config)
45
+ end
46
+
47
+ def write_file
48
+ File.open(path, 'w') {|f| f.write @config.to_yaml }
49
+ end
50
+
51
+ def configure config=nil
52
+ if config
53
+ @config = config
54
+ else
55
+ @config = @default_config
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+
@@ -0,0 +1,5 @@
1
+ module Bitbucket
2
+ module Cli
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bitbucket-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Claus Witt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bitbucket_rest_api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: git plugin for using bitbucket
70
+ email:
71
+ - claus@wittnezz.dk
72
+ executables:
73
+ - git-bb
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/git-bb
83
+ - bitbucket-cli.gemspec
84
+ - lib/bitbucket/cli.rb
85
+ - lib/bitbucket/cli/command.rb
86
+ - lib/bitbucket/cli/commands/repository.rb
87
+ - lib/bitbucket/cli/config.rb
88
+ - lib/bitbucket/cli/version.rb
89
+ homepage: ''
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.6
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: interact with bitbucket through cli
113
+ test_files: []