repo_man 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/Rakefile +2 -2
- data/bin/repo +2 -53
- data/lib/repo_man.rb +1 -2
- data/lib/repo_man/cli.rb +62 -0
- data/lib/repo_man/version.rb +1 -1
- data/repo_man.gemspec +15 -14
- data/spec/repo_man_spec.rb +2 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b781f28aef10946cf054f57ea336073677b3fffd
|
4
|
+
data.tar.gz: 4542c5994c8e11425f0da71fb542f98209b7d8cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58553a1a39c27869def0c950b95d7c370a9462c30b4492408bfddb9d07de49f7cd9babe39d84cbc722ceba1329e277e8fa03b58903ff4f90d6bf78cca3baceae
|
7
|
+
data.tar.gz: c0fa2e885b381756cff1d294cd5de694fc5a93b42575998d8466ae3fe9378162fc5b05df9b604c4cb6ed79e7c73891e587d3e07c5ba9b924ad2d833fc7f39413
|
data/.rubocop.yml
ADDED
data/Rakefile
CHANGED
data/bin/repo
CHANGED
@@ -1,55 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'github_api'
|
2
|
+
require_relative '../lib/repo_man/cli'
|
4
3
|
|
5
|
-
|
6
|
-
class_option :pretend, type: :boolean, desc: "Don't actually make any changes"
|
7
|
-
|
8
|
-
desc 'fetch', 'Fetches all repos into the current directory'
|
9
|
-
def fetch
|
10
|
-
puts "Now cloning #{repos.size} repos from #{username}..."
|
11
|
-
|
12
|
-
repos.each do |r|
|
13
|
-
run("git clone #{r.ssh_url}") unless Dir.exists?(r.name)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'update', 'Updates all existing repos in the current directory'
|
18
|
-
def update
|
19
|
-
puts 'Checking all current repos for updates...'
|
20
|
-
|
21
|
-
repos.each do |r|
|
22
|
-
run("cd #{r.name} && pwd && git pull --all") if Dir.exists?(r.name)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
private
|
26
|
-
|
27
|
-
def repos
|
28
|
-
@repos ||= github.repos.list user: username
|
29
|
-
rescue Github::Error::Unauthorized => e
|
30
|
-
puts "\n Missing or incorrect auth token. Please set GITHUB_TOKEN for this env.\n\n"
|
31
|
-
puts e.inspect
|
32
|
-
puts
|
33
|
-
rescue Github::Error::NotFound => e
|
34
|
-
puts "\n Incorrenct user account. The account (#{username}) was not found.\n\n"
|
35
|
-
puts e.inspect
|
36
|
-
puts
|
37
|
-
end
|
38
|
-
|
39
|
-
def username
|
40
|
-
@username ||= Dir.pwd.split(File::Separator).last
|
41
|
-
end
|
42
|
-
|
43
|
-
def github
|
44
|
-
@github ||= Github.new(
|
45
|
-
auto_pagination: true,
|
46
|
-
oauth_token: ENV['GITHUB_TOKEN'])
|
47
|
-
end
|
48
|
-
|
49
|
-
def run(cmd)
|
50
|
-
puts cmd
|
51
|
-
puts `#{cmd}` unless options[:pretend]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
RepoMan.start
|
4
|
+
RepoMan::CLI.start
|
data/lib/repo_man.rb
CHANGED
data/lib/repo_man/cli.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'repo_man'
|
2
|
+
require 'thor'
|
3
|
+
require 'github_api'
|
4
|
+
|
5
|
+
# Register the command-line interface options
|
6
|
+
module RepoMan
|
7
|
+
class CLI < Thor
|
8
|
+
class_option :pretend, type: :boolean, desc: "Don't actually make any changes"
|
9
|
+
|
10
|
+
desc 'version', 'Displays the current gem version'
|
11
|
+
def version
|
12
|
+
puts RepoMan::VERSION
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'fetch', 'Fetches all repos into the current directory'
|
16
|
+
def fetch
|
17
|
+
puts "Now cloning #{repos.size} repos from #{username}..."
|
18
|
+
|
19
|
+
repos.each do |r|
|
20
|
+
run("git clone #{r.ssh_url}") unless Dir.exist?(r.name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'update', 'Updates all existing repos in the current directory'
|
25
|
+
def update
|
26
|
+
puts 'Checking all current repos for updates...'
|
27
|
+
|
28
|
+
repos.each do |r|
|
29
|
+
run("cd #{r.name} && pwd && git pull --all") if Dir.exist?(r.name)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def repos
|
36
|
+
@repos ||= github.repos.list user: username
|
37
|
+
rescue Github::Error::Unauthorized => e
|
38
|
+
puts "\n Missing or incorrect auth token. Please set GITHUB_TOKEN for this env.\n\n"
|
39
|
+
puts e.inspect
|
40
|
+
puts
|
41
|
+
rescue Github::Error::NotFound => e
|
42
|
+
puts "\n Incorrect user account. The account (#{username}) was not found.\n\n"
|
43
|
+
puts e.inspect
|
44
|
+
puts
|
45
|
+
end
|
46
|
+
|
47
|
+
def username
|
48
|
+
@username ||= Dir.pwd.split(File::Separator).last
|
49
|
+
end
|
50
|
+
|
51
|
+
def github
|
52
|
+
@github ||= Github.new(
|
53
|
+
auto_pagination: true,
|
54
|
+
oauth_token: ENV['GITHUB_TOKEN'])
|
55
|
+
end
|
56
|
+
|
57
|
+
def run(cmd)
|
58
|
+
puts cmd
|
59
|
+
puts `#{cmd}` unless options[:pretend]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/repo_man/version.rb
CHANGED
data/repo_man.gemspec
CHANGED
@@ -4,22 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'repo_man/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'repo_man'
|
8
8
|
spec.version = RepoMan::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Brook Riggio']
|
10
|
+
spec.email = ['brook@codefellows.org']
|
11
|
+
spec.summary = 'Keep the repos under one roof.'
|
12
|
+
spec.description = 'Track all the repos for a GitHub user from one parent directory'
|
13
|
+
spec.homepage = 'https://github.com/brookr/repo_man'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(
|
18
|
-
spec.test_files = spec.files.grep(
|
19
|
-
spec.require_paths = [
|
17
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
|
24
|
-
spec.
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
|
24
|
+
spec.add_dependency 'thor', '~> 0.19'
|
25
|
+
spec.add_dependency 'github_api', '~> 0.12'
|
25
26
|
end
|
data/spec/repo_man_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repo_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brook Riggio
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.19'
|
48
|
-
type: :
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0.12'
|
62
|
-
type: :
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
@@ -75,12 +75,14 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
|
+
- ".rubocop.yml"
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|
81
82
|
- Rakefile
|
82
83
|
- bin/repo
|
83
84
|
- lib/repo_man.rb
|
85
|
+
- lib/repo_man/cli.rb
|
84
86
|
- lib/repo_man/version.rb
|
85
87
|
- repo_man.gemspec
|
86
88
|
- spec/repo_man_spec.rb
|