octopush 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/gictocat.rb +54 -0
- data/lib/octopush.rb +27 -36
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4dda158a0983deb8a132eb47a962062d3752934
|
4
|
+
data.tar.gz: cded430ac329f0c3c7ef8298ef7e965686714090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 142a63650d5abb430a0e1ea93ab887233e432d84d2a3d22c8ae0009b6e55bbf18e5c370e9ab4c7a57f1097884added5cef8f2edf76b3a3afe26ed46b70c155a0
|
7
|
+
data.tar.gz: 7a6f128310f5f87b92e81ae3edf665818d1f52870d0693a1934b949ec4ab7aa05b081e04f5ad349c68dc609983267486745a46e0669f68ad881fc8e6423ec15f
|
data/lib/gictocat.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'github_api'
|
3
|
+
|
4
|
+
# mix in model for very simple github repo manipulation
|
5
|
+
# requires class to respond to repository name
|
6
|
+
module Gictocat
|
7
|
+
|
8
|
+
def initialize_repo(repository_name = repository_name)
|
9
|
+
puts "#{cyan_arrow} Initializing repo in '#{repository_name}'"
|
10
|
+
# re-initializing existing repos is safe:
|
11
|
+
# http://stackoverflow.com/questions/5149694/does-running-git-init-twice-initialize-a-repository-or-reinitialize-an-existing
|
12
|
+
`git init #{repository_name}`
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_and_commit_readme
|
16
|
+
puts "#{cyan_arrow} Touching and committing README.md"
|
17
|
+
FileUtils.touch('README.md')
|
18
|
+
`git add README.md`
|
19
|
+
`git commit -m 'add README.md (via octopush)'`
|
20
|
+
end
|
21
|
+
|
22
|
+
def push_to_github
|
23
|
+
create_repo_on_github
|
24
|
+
add_github_remote
|
25
|
+
push_repo
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_repo_on_github
|
29
|
+
puts "#{cyan_arrow} Creating repo '#{repository_name}' on GitHub"
|
30
|
+
github_user.repos.create(name: repository_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_github_remote(remote_name = 'origin')
|
34
|
+
puts "#{cyan_arrow} Adding GitHub as a remote"
|
35
|
+
`git remote add #{remote_name} https://github.com/#{configuration['username']}/#{repository_name}.git`
|
36
|
+
end
|
37
|
+
|
38
|
+
def push_repo
|
39
|
+
puts "#{cyan_arrow} Pushing repo to GitHub"
|
40
|
+
`git push -u origin master`
|
41
|
+
end
|
42
|
+
|
43
|
+
def github_user
|
44
|
+
@github_user ||= Github.new({
|
45
|
+
login: username,
|
46
|
+
password: password
|
47
|
+
})
|
48
|
+
end
|
49
|
+
|
50
|
+
def cyan_arrow
|
51
|
+
'==>'.colorize(:cyan)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/lib/octopush.rb
CHANGED
@@ -1,53 +1,50 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'colorize'
|
4
|
-
|
4
|
+
require_relative 'gictocat'
|
5
5
|
|
6
6
|
CONFIGURATION_FILE = (ENV['HOME'] + '/.octopushrc')
|
7
7
|
|
8
8
|
class Octopush < Thor
|
9
9
|
|
10
|
+
include Gictocat
|
11
|
+
|
10
12
|
desc "octopush REPOSITORY_NAME", "uploads REPOSITORY_NAME to github (creates an empty one if needed)"
|
11
13
|
def octopush(repository_name)
|
12
14
|
@repository_name = repository_name
|
13
|
-
|
14
|
-
# re-initializing existing repos is safe:
|
15
|
-
# http://stackoverflow.com/questions/5149694/does-running-git-init-twice-initialize-a-repository-or-reinitialize-an-existing
|
16
|
-
`git init #{repository_name}`
|
17
|
-
|
15
|
+
initialize_repo
|
18
16
|
Dir.chdir("./#{repository_name}")
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
add_and_commit_readme
|
18
|
+
push_to_github
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "create_config", "Creates an empty octopush configuration in ~/.octopushrc"
|
22
|
+
def create_config
|
23
|
+
create_empty_configuration
|
25
24
|
end
|
26
25
|
|
27
26
|
private
|
28
27
|
|
29
|
-
def
|
30
|
-
|
28
|
+
def repository_name
|
29
|
+
@repository_name
|
31
30
|
end
|
32
31
|
|
33
|
-
def
|
34
|
-
|
32
|
+
def username
|
33
|
+
return configuration['username'] if configuration['username']
|
34
|
+
ask "Github Username:"
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
|
37
|
+
def password
|
38
|
+
return configuration['password'] if configuration['password']
|
39
|
+
ask("GitHub Password:", :echo => false)
|
39
40
|
end
|
40
41
|
|
41
42
|
def configuration
|
42
|
-
@configuration ||= load_configuration
|
43
|
-
end
|
44
|
-
|
45
|
-
def load_configuration
|
46
43
|
begin
|
47
|
-
YAML.load(File.read(CONFIGURATION_FILE))
|
44
|
+
@configuration ||= YAML.load(File.read(CONFIGURATION_FILE))
|
48
45
|
rescue
|
49
|
-
|
50
|
-
|
46
|
+
puts "#{red_arrow} Run octopush create_config for storing credentials"
|
47
|
+
return @configuration = {} # an empty configuration..
|
51
48
|
end
|
52
49
|
end
|
53
50
|
|
@@ -55,22 +52,16 @@ class Octopush < Thor
|
|
55
52
|
configuration ="username: <your_username>\npassword: <your_password>"
|
56
53
|
File.open(CONFIGURATION_FILE, 'wb') { |f| f.write(configuration) }
|
57
54
|
|
58
|
-
puts
|
59
|
-
puts "No configuration found!".colorize(:red)
|
55
|
+
puts "#{red_arrow} No configuration found!"
|
60
56
|
puts "Initialized configuration file in ~/.octopushrc"
|
61
|
-
puts ".. go edit it"
|
62
|
-
puts ('*' * 50).colorize(:red)
|
63
57
|
end
|
64
58
|
|
65
|
-
def
|
66
|
-
|
59
|
+
def red_arrow
|
60
|
+
'==>'.colorize(:red)
|
67
61
|
end
|
68
62
|
|
69
|
-
def
|
70
|
-
|
71
|
-
login: configuration['username'],
|
72
|
-
password: configuration['password']
|
73
|
-
})
|
63
|
+
def cyan_arrow
|
64
|
+
'==>'.colorize(:cyan)
|
74
65
|
end
|
75
66
|
|
76
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martino Visintin
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- lib/octopush.rb
|
63
|
+
- lib/gictocat.rb
|
63
64
|
- bin/octopush
|
64
65
|
homepage: https://github.com/vise890/octopush
|
65
66
|
licenses:
|