bucket-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +13 -0
- data/bin/bucket +6 -0
- data/bucket.gemspec +29 -0
- data/lib/bucket/cli.rb +75 -0
- data/lib/bucket/client.rb +29 -0
- data/lib/bucket/version.rb +3 -0
- data/lib/bucket.rb +7 -0
- data/spec/bucket_spec.rb +3 -0
- data/spec/spec_helper.rb +4 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 40c5f1a4499778d641fb6a1b843721593567ad5a
|
4
|
+
data.tar.gz: 42a542e11a64d789a7822870bc56534f6b3ceab0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4e4205cf5d982a68596797778235cf000bdc7013c197b7eaebbc5255cadcc2dc3c1528e12cd198a484d263468330a27bc95218b0cbb07dcf727c3418fb077eeb
|
7
|
+
data.tar.gz: 2fc5dc71f444b063efb848912f3ef2792308ef0ce9fa2f1a76205f9dc73881d48b642d94e41ed7b4f8612cc889aa226453c23aa13cebb802d566c7e7f617a39a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Roberto Poo
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Bucket
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'bucket'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install bucket
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/bucket
ADDED
data/bucket.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bucket/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bucket-cli"
|
8
|
+
spec.version = Bucket::VERSION
|
9
|
+
spec.authors = ["Roberto Poo"]
|
10
|
+
spec.email = ["xaro@poo.cl"]
|
11
|
+
spec.description = %q{CLI for BitBucket}
|
12
|
+
spec.summary = %q{Easily clone and create repositories in BitBucket from the command line.
|
13
|
+
Init and link the local repository with a new BitBucket one in one command.}
|
14
|
+
spec.homepage = "https://github.com/xaro/bucket"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "omniauth"
|
23
|
+
spec.add_dependency "thor"
|
24
|
+
spec.add_dependency "bitbucket_rest_api"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
end
|
data/lib/bucket/cli.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "io/console"
|
3
|
+
require "yaml"
|
4
|
+
require_relative "../bucket"
|
5
|
+
|
6
|
+
module Bucket
|
7
|
+
class CLI < Thor
|
8
|
+
def initialize(*args)
|
9
|
+
super
|
10
|
+
|
11
|
+
@client = Bucket::Client.new load_config
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "setup", "Setup your BitBucket credentials"
|
15
|
+
def setup
|
16
|
+
generate_config
|
17
|
+
|
18
|
+
say("Configuration saved to ~/.bucket")
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "repos", "List your own repositories."
|
22
|
+
def repos
|
23
|
+
@client.repos_list.each do |repo|
|
24
|
+
say(@client.repo_full_name(repo))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "clone [USER] [NAME]", "Clone repository USER/NAME from bitbucket."
|
29
|
+
def clone(user, name)
|
30
|
+
`git clone #{@client.repo_url(user, name)}`
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "init [directory]", "Create a new repository locally and on BitBucket."
|
34
|
+
option :name
|
35
|
+
option :description
|
36
|
+
option :public, type: :boolean, default: false
|
37
|
+
def init(directory)
|
38
|
+
expanded_dir = File.expand_path(directory)
|
39
|
+
`git init #{expanded_dir}`
|
40
|
+
|
41
|
+
repo = @client.create_repo(options[:name] || File.basename(expanded_dir), options)
|
42
|
+
`git remote add origin #{@client.repo_url(repo[:owner], repo[:slug])}`
|
43
|
+
|
44
|
+
say("Repository #{@client.repo_full_name(repo)} created.")
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def load_config
|
49
|
+
YAML.load_file("#{Dir.home}/.bucket")
|
50
|
+
rescue
|
51
|
+
generate_config
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate_config
|
55
|
+
save_config ask_credentials
|
56
|
+
end
|
57
|
+
|
58
|
+
def save_config(credentials)
|
59
|
+
File.open "#{Dir.home}/.bucket", 'w' do |f|
|
60
|
+
YAML.dump(credentials , f)
|
61
|
+
end
|
62
|
+
|
63
|
+
credentials
|
64
|
+
end
|
65
|
+
|
66
|
+
def ask_credentials
|
67
|
+
username = @shell.ask("Username:")
|
68
|
+
@shell.say("Password: ")
|
69
|
+
password = $stdin.noecho(&:gets).strip
|
70
|
+
@shell.say("")
|
71
|
+
|
72
|
+
{ "username" => username, "password" => password }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Bucket
|
2
|
+
class Client
|
3
|
+
GIT_URL = "git@bitbucket.org"
|
4
|
+
|
5
|
+
def initialize(credentials)
|
6
|
+
@connection = BitBucket.new basic_auth: "#{credentials["username"]}:#{credentials["password"]}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def repos_list
|
10
|
+
@connection.repos.list
|
11
|
+
end
|
12
|
+
|
13
|
+
def repo_url(user, name)
|
14
|
+
"#{GIT_URL}:#{user}/#{name}.git"
|
15
|
+
end
|
16
|
+
|
17
|
+
def repo_full_name(repo)
|
18
|
+
"#{repo[:owner]}/#{repo[:slug]}"
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the created repository scm url
|
22
|
+
def create_repo(name, options={})
|
23
|
+
options = options.merge(is_private: !options[:public])
|
24
|
+
|
25
|
+
@connection.repos.create(options.merge(name: name))
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
data/lib/bucket.rb
ADDED
data/spec/bucket_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bucket-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Roberto Poo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
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: thor
|
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: bitbucket_rest_api
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: CLI for BitBucket
|
98
|
+
email:
|
99
|
+
- xaro@poo.cl
|
100
|
+
executables:
|
101
|
+
- bucket
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/bucket
|
111
|
+
- bucket.gemspec
|
112
|
+
- lib/bucket.rb
|
113
|
+
- lib/bucket/cli.rb
|
114
|
+
- lib/bucket/client.rb
|
115
|
+
- lib/bucket/version.rb
|
116
|
+
- spec/bucket_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
homepage: https://github.com/xaro/bucket
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.0.3
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Easily clone and create repositories in BitBucket from the command line.
|
142
|
+
Init and link the local repository with a new BitBucket one in one command.
|
143
|
+
test_files:
|
144
|
+
- spec/bucket_spec.rb
|
145
|
+
- spec/spec_helper.rb
|
146
|
+
has_rdoc:
|