monos 0.1.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +8 -6
- data/README.md +56 -22
- data/Rakefile +7 -4
- data/lib/mono.rb +24 -26
- data/lib/mono/base.rb +19 -0
- data/lib/mono/commands/backup.rb +15 -0
- data/lib/mono/commands/env.rb +26 -0
- data/lib/mono/commands/fetch.rb +44 -0
- data/lib/mono/commands/run.rb +47 -0
- data/lib/mono/{git → commands}/status.rb +7 -15
- data/lib/mono/commands/sync.rb +53 -0
- data/lib/mono/{git/tool.rb → tool.rb} +7 -1
- data/lib/mono/version.rb +26 -18
- data/lib/sportdb/setup.rb +106 -0
- data/test/test_base.rb +30 -3
- metadata +39 -10
- data/bin/moget +0 -17
- data/lib/mono/git/base.rb +0 -174
- data/lib/mono/git/sync.rb +0 -98
- data/lib/mono/sportdb.rb +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17e75b31f208961c34bd615af15547d1ebe2f0ba
|
4
|
+
data.tar.gz: 150a65ae3b0296acd3659732193377f4552ad1f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17b55bd1201b91de073dd1e06fc35834231f0a0092fae88c9a6fbcf9f321127e77fb459786e5ba517508fbe66d8ee04f0d4a14ff6c9099be21fdc1124a16cbbc
|
7
|
+
data.tar.gz: ac18e206c095d17a2586a7c7d6da30017010fa9aba2ff73be58b265be548bbb5712676ff482560d45d9a3a261b450e1cd86f3f15ae2a337dbb11836c8850819f
|
data/Manifest.txt
CHANGED
@@ -3,16 +3,18 @@ Manifest.txt
|
|
3
3
|
README.md
|
4
4
|
Rakefile
|
5
5
|
bin/mo
|
6
|
-
bin/moget
|
7
6
|
bin/mono
|
8
7
|
lib/mono.rb
|
9
8
|
lib/mono/base.rb
|
10
|
-
lib/mono/
|
11
|
-
lib/mono/
|
12
|
-
lib/mono/
|
13
|
-
lib/mono/
|
14
|
-
lib/mono/
|
9
|
+
lib/mono/commands/backup.rb
|
10
|
+
lib/mono/commands/env.rb
|
11
|
+
lib/mono/commands/fetch.rb
|
12
|
+
lib/mono/commands/run.rb
|
13
|
+
lib/mono/commands/status.rb
|
14
|
+
lib/mono/commands/sync.rb
|
15
|
+
lib/mono/tool.rb
|
15
16
|
lib/mono/version.rb
|
16
17
|
lib/monos.rb
|
18
|
+
lib/sportdb/setup.rb
|
17
19
|
test/helper.rb
|
18
20
|
test/test_base.rb
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# monos - monorepo / mono source tree tools and (startup) scripts
|
2
2
|
|
3
3
|
|
4
|
-
* home :: [github.com/
|
5
|
-
* bugs :: [github.com/
|
4
|
+
* home :: [github.com/rubycoco/monos](https://github.com/rubycoco/monos)
|
5
|
+
* bugs :: [github.com/rubycoco/monos/issues](https://github.com/rubycoco/monos/issues)
|
6
6
|
* gem :: [rubygems.org/gems/monos](https://rubygems.org/gems/monos)
|
7
7
|
* rdoc :: [rubydoc.info/gems/monos](http://rubydoc.info/gems/monos)
|
8
8
|
* forum :: [opensport](http://groups.google.com/group/opensport)
|
@@ -32,23 +32,17 @@ to be part of the "virtual" all-in-one / single mono source tree
|
|
32
32
|
in your project. Example:
|
33
33
|
|
34
34
|
``` yaml
|
35
|
-
####################
|
36
|
-
# checkout skripts (auto-update machinery)
|
37
|
-
yorobot:
|
38
|
-
- cache.csv ## incl. self
|
39
|
-
- sport.db.more
|
40
|
-
- football.db
|
41
|
-
- football.csv
|
42
|
-
|
43
|
-
###############
|
44
|
-
# use latest sportdb machinery (from source)
|
45
35
|
sportdb:
|
46
36
|
- sport.db
|
47
37
|
- sport.db.sources
|
48
38
|
- football.db
|
49
39
|
|
50
|
-
|
51
|
-
|
40
|
+
yorobot:
|
41
|
+
- cache.csv
|
42
|
+
- sport.db.more
|
43
|
+
- football.db
|
44
|
+
- football.csv
|
45
|
+
|
52
46
|
openfootball:
|
53
47
|
- leagues
|
54
48
|
- clubs
|
@@ -58,7 +52,7 @@ openfootball:
|
|
58
52
|
|
59
53
|
### Commands
|
60
54
|
|
61
|
-
`status` • `sync` • `env`
|
55
|
+
`status` • `fetch` • `sync` • `run` • `env` • `backup`
|
62
56
|
|
63
57
|
### `status` Command
|
64
58
|
|
@@ -77,7 +71,7 @@ resulting in something like:
|
|
77
71
|
```
|
78
72
|
2 change(s) in 9 repo(s) @ 3 org(s)
|
79
73
|
|
80
|
-
|
74
|
+
-- sportdb@sport.db - CHANGES:
|
81
75
|
M monos/Manifest.txt
|
82
76
|
M monos/README.md
|
83
77
|
M monos/Rakefile
|
@@ -88,18 +82,26 @@ RM monos/lib/monoscript.rb -> monos/lib/monos.rb
|
|
88
82
|
M monos/test/test_base.rb
|
89
83
|
?? monos/bin/
|
90
84
|
|
91
|
-
|
85
|
+
-- yorobot@football.csv - CHANGES:
|
92
86
|
?? footballdata/
|
93
87
|
```
|
94
88
|
|
95
89
|
|
90
|
+
### `fetch` Command
|
91
|
+
|
92
|
+
Use the `fetch` command to fetch all (remote) changes (will use `git fetch`) on all existing repos and warn about not-yet-cloned repos. Example:
|
93
|
+
|
94
|
+
```
|
95
|
+
$ mono fetch
|
96
|
+
$ mo fetch # mo is a "shortcut" convenience alias for mono
|
97
|
+
```
|
98
|
+
|
96
99
|
|
97
|
-
### `sync` Command
|
98
100
|
|
101
|
+
### `sync` Command
|
99
102
|
|
100
|
-
Use the `sync` command to sync up (pull) changes (will use `git pull --ff-only`) on all existing repos and `git clone` for new not-yet-cloned repos.
|
101
103
|
|
102
|
-
Example:
|
104
|
+
Use the `sync` command to sync up (pull) changes (will use `git pull --ff-only`) on all existing repos and `git clone` for new not-yet-cloned repos. Example:
|
103
105
|
|
104
106
|
```
|
105
107
|
$ mono sync
|
@@ -107,12 +109,30 @@ $ mono install # install is an alias for sync
|
|
107
109
|
$ mono get # get is another alias for sync
|
108
110
|
$ mo sync # mo is a "shortcut" convenience alias for mono
|
109
111
|
$ mo get
|
110
|
-
$ moget # moget is a "shortcut" convenience alis for mono get
|
111
112
|
```
|
112
113
|
|
113
114
|
Note: `install` or `get` or `up` are all aliases that you can use for `sync`.
|
114
115
|
|
115
|
-
|
116
|
+
|
117
|
+
### `run` Command
|
118
|
+
|
119
|
+
Use the `run` command to run any command in all repos. Example:
|
120
|
+
|
121
|
+
```
|
122
|
+
$ mono run git ls-files
|
123
|
+
$ mono exec git ls-files # exec is an alias for run
|
124
|
+
$ mo run git ls-files # mo is a "shortcut" convenience alias for mono
|
125
|
+
$ mo exec git ls-files
|
126
|
+
|
127
|
+
# -or-
|
128
|
+
|
129
|
+
$ mono run tree
|
130
|
+
$ mono exec tree
|
131
|
+
$ mo run tree
|
132
|
+
$ mo exec tree
|
133
|
+
```
|
134
|
+
|
135
|
+
Note: `exec` is an alias that you can use for `run`.
|
116
136
|
|
117
137
|
|
118
138
|
|
@@ -121,6 +141,20 @@ Note: `moget` is a shortcut convenience command for `mono get` (or, that is, `mo
|
|
121
141
|
Use the `env` command to check your `mono` environment setup.
|
122
142
|
|
123
143
|
|
144
|
+
|
145
|
+
|
146
|
+
### `backup` Command
|
147
|
+
|
148
|
+
Use the `backup` command to backup all repos using
|
149
|
+
the [`gitti-backup` machinery »](https://github.com/rubycoco/gitti/tree/master/gitti-backup)
|
150
|
+
|
151
|
+
In a nutshell backup will backup all repos by using
|
152
|
+
1. `git clone --mirror` or
|
153
|
+
2. `git remote update` (if the local backup already exists)
|
154
|
+
and store all bare repos (without workspace) in the `~/backup` directory.
|
155
|
+
|
156
|
+
|
157
|
+
|
124
158
|
That's all for now.
|
125
159
|
|
126
160
|
|
data/Rakefile
CHANGED
@@ -3,15 +3,15 @@ require './lib/mono/version.rb'
|
|
3
3
|
|
4
4
|
Hoe.spec 'monos' do
|
5
5
|
|
6
|
-
self.version =
|
6
|
+
self.version = MonoCore::VERSION
|
7
7
|
|
8
8
|
self.summary = "monos - monorepo / mono source tree tools and (startup) scripts"
|
9
9
|
self.description = summary
|
10
10
|
|
11
|
-
self.urls =
|
11
|
+
self.urls = { home: 'https://github.com/rubycoco/monos' }
|
12
12
|
|
13
13
|
self.author = 'Gerald Bauer'
|
14
|
-
self.email
|
14
|
+
self.email = 'opensport@googlegroups.com'
|
15
15
|
|
16
16
|
# switch extension to .markdown for gihub formatting
|
17
17
|
self.readme_file = 'README.md'
|
@@ -19,7 +19,10 @@ Hoe.spec 'monos' do
|
|
19
19
|
|
20
20
|
self.licenses = ['Public Domain']
|
21
21
|
|
22
|
-
self.extra_deps = [
|
22
|
+
self.extra_deps = [
|
23
|
+
['gitti', '>= 0.4.0' ],
|
24
|
+
['gitti-backup', '>= 0.4.1' ],
|
25
|
+
]
|
23
26
|
|
24
27
|
self.spec_extras = {
|
25
28
|
required_ruby_version: '>= 2.2.2'
|
data/lib/mono.rb
CHANGED
@@ -1,36 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
|
7
|
-
|
1
|
+
## first add git support
|
2
|
+
## note: use the "modular" version WITHOUT auto-include gitti,
|
3
|
+
## thus, require 'gitti/base' (and NOT 'gitti')
|
4
|
+
require 'gitti/base'
|
5
|
+
require 'gitti/backup/base'
|
6
|
+
|
7
|
+
|
8
|
+
module Mono
|
9
|
+
## note: make Git, GitProject, GitRepoSet, etc. available without Gitti::
|
10
|
+
include Gitti
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
## some more stdlibs
|
15
|
+
# require 'optparse'
|
16
|
+
|
8
17
|
|
9
18
|
|
10
19
|
###
|
11
20
|
# our own code
|
12
21
|
require 'mono/version' # let version always go first
|
13
22
|
require 'mono/base'
|
14
|
-
require 'mono/git/base'
|
15
|
-
require 'mono/git/sync'
|
16
|
-
require 'mono/git/status'
|
17
|
-
require 'mono/git/tool'
|
18
|
-
|
19
|
-
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
puts
|
29
|
-
puts "monorepo.yml:"
|
30
|
-
pp Mono.monofile
|
31
|
-
end
|
32
|
-
end # module Mono
|
24
|
+
require 'mono/commands/status'
|
25
|
+
require 'mono/commands/fetch'
|
26
|
+
require 'mono/commands/sync'
|
27
|
+
require 'mono/commands/env'
|
28
|
+
require 'mono/commands/backup'
|
29
|
+
require 'mono/commands/run'
|
30
|
+
require 'mono/tool'
|
33
31
|
|
34
32
|
|
35
33
|
|
36
|
-
puts
|
34
|
+
puts MonoCore.banner # say hello
|
data/lib/mono/base.rb
CHANGED
@@ -16,6 +16,25 @@ module Mono
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def self.monofile
|
20
|
+
path = if File.exist?( './monorepo.yml' )
|
21
|
+
'./monorepo.yml'
|
22
|
+
elsif File.exist?( './monotree.yml' )
|
23
|
+
'./monotree.yml'
|
24
|
+
elsif File.exist?( './repos.yml' )
|
25
|
+
'./repos.yml'
|
26
|
+
else
|
27
|
+
puts "!! WARN: no mono configuration file (that is, {monorepo,monotree,repos}.yml) found in >#{Dir.getwd}<"
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
if path
|
32
|
+
GitRepoSet.read( path )
|
33
|
+
else
|
34
|
+
GitRepoSet.new( {} ) ## return empty set -todo/check: return nil - why? why not?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
19
38
|
end ## module Mono
|
20
39
|
|
21
40
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
+
def self.backup
|
5
|
+
repos = Mono.monofile
|
6
|
+
|
7
|
+
backup = GitBackup.new
|
8
|
+
|
9
|
+
## step 2: pass in all repos to backup by using
|
10
|
+
## 1) git clone --mirror or
|
11
|
+
## 2) git remote update (if local backup already exists)
|
12
|
+
backup.backup( repos )
|
13
|
+
end # method backup
|
14
|
+
|
15
|
+
end # module Mono
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
def self.env ## check environment setup
|
4
|
+
puts "Mono.root (MOPATH): >#{Mono.root}<"
|
5
|
+
puts "MonoCore.root: >#{MonoCore.root}<"
|
6
|
+
puts
|
7
|
+
|
8
|
+
## add ruby version and path - why? why not? e.g.
|
9
|
+
## ruby:
|
10
|
+
## bin: C:/ri330/Ruby2.0.0/bin/ruby.exe
|
11
|
+
## version: ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
|
12
|
+
|
13
|
+
puts "git version:"
|
14
|
+
Git.version
|
15
|
+
## Git.config( 'user.name' )
|
16
|
+
## Git.config( 'user.email', show_origin: true )
|
17
|
+
|
18
|
+
## dump/print all user.* settings e.g. user.name, user.email
|
19
|
+
Git.config( /user/, show_origin: true )
|
20
|
+
|
21
|
+
puts
|
22
|
+
puts "monorepo.yml:"
|
23
|
+
pp Mono.monofile
|
24
|
+
end
|
25
|
+
|
26
|
+
end # module Mono
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
+
def self.fetch
|
5
|
+
repos = Mono.monofile
|
6
|
+
|
7
|
+
count_orgs = 0
|
8
|
+
count_repos = 0
|
9
|
+
|
10
|
+
total_repos = repos.size
|
11
|
+
|
12
|
+
|
13
|
+
repos.each do |org,names|
|
14
|
+
|
15
|
+
org_path = "#{Mono.root}/#{org}"
|
16
|
+
|
17
|
+
names.each do |name|
|
18
|
+
puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
|
19
|
+
|
20
|
+
repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
|
21
|
+
|
22
|
+
Dir.chdir( org_path ) do
|
23
|
+
if Dir.exist?( repo.name )
|
24
|
+
GitProject.open( repo.name ) do |proj|
|
25
|
+
proj.fetch
|
26
|
+
end
|
27
|
+
else
|
28
|
+
puts "!! repo not found / missing"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
count_repos += 1
|
33
|
+
end
|
34
|
+
count_orgs += 1
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
## print stats & changes summary
|
39
|
+
puts
|
40
|
+
print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
41
|
+
print "\n"
|
42
|
+
end # method fetch
|
43
|
+
|
44
|
+
end # module Mono
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
def self.run( *args )
|
4
|
+
## todo/fix: use a "standard" argument to pass along hash of repos
|
5
|
+
## (e.g. monorepo.yml or repos.yml ) how? - why? why not?
|
6
|
+
repos = Mono.monofile
|
7
|
+
|
8
|
+
|
9
|
+
cmd = args.join( ' ' )
|
10
|
+
|
11
|
+
count_orgs = 0
|
12
|
+
count_repos = 0
|
13
|
+
|
14
|
+
total_repos = repos.size
|
15
|
+
|
16
|
+
repos.each do |org,names|
|
17
|
+
|
18
|
+
org_path = "#{Mono.root}/#{org}"
|
19
|
+
|
20
|
+
names.each do |name|
|
21
|
+
puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
|
22
|
+
|
23
|
+
repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
|
24
|
+
|
25
|
+
Dir.chdir( org_path ) do
|
26
|
+
if Dir.exist?( repo.name )
|
27
|
+
GitProject.open( repo.name ) do |proj|
|
28
|
+
proj.run( cmd )
|
29
|
+
end
|
30
|
+
else
|
31
|
+
puts "!! repo not found / missing"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
count_repos += 1
|
36
|
+
end
|
37
|
+
count_orgs += 1
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
## print stats & changes summary
|
42
|
+
puts
|
43
|
+
print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
44
|
+
print "\n"
|
45
|
+
end # method run
|
46
|
+
|
47
|
+
end # module Mono
|
@@ -1,25 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
module Mono
|
4
2
|
|
5
3
|
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
6
|
-
def self.status
|
4
|
+
def self.status
|
5
|
+
repos = Mono.monofile
|
6
|
+
|
7
7
|
changes = [] ## track changes
|
8
8
|
|
9
9
|
count_orgs = 0
|
10
10
|
count_repos = 0
|
11
11
|
|
12
|
-
|
13
|
-
total_repos = h.reduce(0) {|sum,(_,names)| sum+= names.size; sum }
|
14
|
-
|
15
|
-
|
16
|
-
h.each do |org_with_counter,names|
|
12
|
+
total_repos = repos.size
|
17
13
|
|
18
|
-
|
19
|
-
## mrhydescripts (3) => mrhydescripts
|
20
|
-
## footballjs (4) => footballjs
|
21
|
-
## etc.
|
22
|
-
org = org_with_counter.sub( /\([0-9]+\)/, '' ).strip
|
14
|
+
repos.each do |org,names|
|
23
15
|
|
24
16
|
org_path = "#{Mono.root}/#{org}"
|
25
17
|
|
@@ -30,8 +22,8 @@ module Mono
|
|
30
22
|
|
31
23
|
Dir.chdir( org_path ) do
|
32
24
|
if Dir.exist?( repo.name )
|
33
|
-
|
34
|
-
output =
|
25
|
+
GitProject.open( repo.name ) do |proj|
|
26
|
+
output = proj.changes
|
35
27
|
if output.empty?
|
36
28
|
puts " - no changes -"
|
37
29
|
else
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
+
def self.sync
|
5
|
+
repos = Mono.monofile
|
6
|
+
|
7
|
+
count_orgs = 0
|
8
|
+
count_repos = 0
|
9
|
+
|
10
|
+
total_repos = repos.size
|
11
|
+
|
12
|
+
repos.each do |org,names|
|
13
|
+
org_path = "#{Mono.root}/#{org}"
|
14
|
+
FileUtils.mkdir_p( org_path ) unless Dir.exist?( org_path ) ## make sure path exists
|
15
|
+
|
16
|
+
names.each do |name|
|
17
|
+
puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
|
18
|
+
|
19
|
+
repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
|
20
|
+
|
21
|
+
Dir.chdir( org_path ) do
|
22
|
+
if Dir.exist?( repo.name )
|
23
|
+
GitProject.open( repo.name ) do |proj|
|
24
|
+
if proj.changes?
|
25
|
+
puts "!! WARN - local changes in workdir; skipping fast forward (remote) sync / merge"
|
26
|
+
else
|
27
|
+
proj.fast_forward ## note: use git pull --ff-only (fast forward only - do NOT merge)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
Git.clone( repo.ssh_clone_url )
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# todo/fix: add (back) error log !!!!!!!!!!!!
|
37
|
+
# rescue GitError => ex
|
38
|
+
# puts "!! ERROR: #{ex.message}"
|
39
|
+
#
|
40
|
+
# File.open( './errors.log', 'a' ) do |f|
|
41
|
+
# f.write "#{Time.now} -- repo #{org}/#{name} - #{ex.message}\n"
|
42
|
+
# end
|
43
|
+
|
44
|
+
count_repos += 1
|
45
|
+
end
|
46
|
+
count_orgs += 1
|
47
|
+
end
|
48
|
+
|
49
|
+
## print stats
|
50
|
+
puts "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
51
|
+
end # method sync
|
52
|
+
|
53
|
+
end # module Mono
|
@@ -15,15 +15,21 @@ class Tool
|
|
15
15
|
|
16
16
|
## note: allow shortcut for commands
|
17
17
|
case cmd.downcase
|
18
|
-
when 'status', 'stati', 'stat', 's'
|
18
|
+
when 'status', 'stati', 'stat', 'st', 's'
|
19
19
|
Mono.status
|
20
20
|
when 'sync', 'syn', 'sy', ## note: allow aliases such as install, get & up too
|
21
21
|
'get', 'g',
|
22
22
|
'install', 'insta', 'inst', 'ins', 'i',
|
23
23
|
'up', 'u'
|
24
24
|
Mono.sync
|
25
|
+
when 'fetch', 'f'
|
26
|
+
Mono.fetch
|
25
27
|
when 'env', 'e'
|
26
28
|
Mono.env
|
29
|
+
when 'backup', 'back', 'b'
|
30
|
+
Mono.backup
|
31
|
+
when 'run', 'r', 'exec'
|
32
|
+
Mono.run( args )
|
27
33
|
else
|
28
34
|
puts "!! ERROR: unknown command >#{cmd}<"
|
29
35
|
exit 1
|
data/lib/mono/version.rb
CHANGED
@@ -1,25 +1,33 @@
|
|
1
1
|
## note: use a different module/namespace
|
2
|
-
## for the gem version info e.g.
|
2
|
+
## for the gem version info e.g. MonoCore vs Mono
|
3
3
|
|
4
|
-
module
|
5
|
-
|
4
|
+
module MonoCore ## todo/check: rename to MonoMeta, MonoModule or such - why? why not?
|
5
|
+
|
6
|
+
## note: move root to its own namespace to avoid
|
7
|
+
## conflict with Mono.root!!!!
|
8
|
+
MAJOR = 0 ## todo: namespace inside version or something - why? why not??
|
9
|
+
MINOR = 4
|
10
|
+
PATCH = 0
|
11
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
12
|
+
|
13
|
+
def self.version
|
14
|
+
VERSION
|
15
|
+
end
|
6
16
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
17
|
+
def self.banner
|
18
|
+
"monos/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
19
|
+
end
|
11
20
|
|
12
|
-
|
13
|
-
|
14
|
-
|
21
|
+
def self.root
|
22
|
+
File.expand_path( File.dirname(File.dirname(__FILE__) ))
|
23
|
+
end
|
15
24
|
|
16
|
-
|
17
|
-
"monos/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
18
|
-
end
|
25
|
+
end # module MonoCore
|
19
26
|
|
20
|
-
def self.root
|
21
|
-
File.expand_path( File.dirname(File.dirname(__FILE__) ))
|
22
|
-
end
|
23
27
|
|
24
|
-
|
25
|
-
|
28
|
+
##################################
|
29
|
+
# add a convenience shortcut for now - why? why not?
|
30
|
+
module Mono
|
31
|
+
VERSION = MonoCore::VERSION
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,106 @@
|
|
1
|
+
########
|
2
|
+
##
|
3
|
+
# fix:
|
4
|
+
# move to sportdb/setup or sportdb/boot ?
|
5
|
+
# use module SportDb::Boot
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
##########
|
10
|
+
# setup load path
|
11
|
+
# lets you use environments
|
12
|
+
# e.g. dev/development or production
|
13
|
+
|
14
|
+
|
15
|
+
## todo/fix: move later app/gem-family/-specific configs
|
16
|
+
## to its own gem e.g. mono-sportdb or sportdb-boot/starter/startup or such - why? why not?
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
$RUBYLIBS_DEBUG = true
|
23
|
+
$RUBYCOCO_DEBUG = true ## always include (NOT just in sportdb?)
|
24
|
+
|
25
|
+
|
26
|
+
### include / check for ruby debug flag too - why? why not?
|
27
|
+
def debug? ## always include (NOT just insportdb?)
|
28
|
+
value = ENV['DEBUG']
|
29
|
+
if value && ['true', 't',
|
30
|
+
'yes', 'y',
|
31
|
+
'on'].include?( value.downcase )
|
32
|
+
true
|
33
|
+
else
|
34
|
+
false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
require_relative '../mono'
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
## convenience pre-configured/pre-built shortcut - lets you use
|
44
|
+
## require 'sportdb/setup'
|
45
|
+
## SportDb::Boot.setup
|
46
|
+
|
47
|
+
|
48
|
+
module SportDb
|
49
|
+
module Boot
|
50
|
+
def self.root() Mono.root; end
|
51
|
+
|
52
|
+
def self.setup ## setup load path
|
53
|
+
### note: for now always assume dev/development
|
54
|
+
### add ENV check later or pass in as args or such
|
55
|
+
|
56
|
+
puts "SportDb::Boot.root: >#{root}<"
|
57
|
+
|
58
|
+
### todo/fix: use an inline Gemfile and bundler's setup? why? why not?
|
59
|
+
$LOAD_PATH.unshift( "#{root}/yorobot/sport.db.more/sportdb-exporters/lib" )
|
60
|
+
$LOAD_PATH.unshift( "#{root}/yorobot/sport.db.more/sportdb-writers/lib" )
|
61
|
+
$LOAD_PATH.unshift( "#{root}/yorobot/sport.db.more/sportdb-linters/lib" )
|
62
|
+
|
63
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sports/lib" )
|
64
|
+
|
65
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-importers/lib" )
|
66
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-readers/lib" )
|
67
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-sync/lib" )
|
68
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-models/lib" )
|
69
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-catalogs/lib" )
|
70
|
+
|
71
|
+
## todo/check:
|
72
|
+
## add fifa, footballdb-leagues, footballdb-clubs too ???
|
73
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/football.db/footballdb-clubs/lib" ))
|
74
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/football.db/footballdb-leagues/lib" ))
|
75
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/football.db/fifa/lib" ))
|
76
|
+
|
77
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-formats/lib" )
|
78
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-structs/lib" )
|
79
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-langs/lib" )
|
80
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/score-formats/lib" )
|
81
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/date-formats/lib" )
|
82
|
+
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/alphabets/lib" )
|
83
|
+
|
84
|
+
pp $: # print load path
|
85
|
+
end # method setup
|
86
|
+
end # module Boot
|
87
|
+
end # module Sportdb
|
88
|
+
|
89
|
+
|
90
|
+
### use something like SportDb::Path[:sportdb]
|
91
|
+
## SportDb.path( :sportdb )
|
92
|
+
## SportDb::Boot.sportdb_path or sportdb_dir or such???
|
93
|
+
## SportDb::Env.path( 'sportdb' ) ???
|
94
|
+
## SportDb::Env::SPORTDB_DIR ???
|
95
|
+
## or such - why? why not?
|
96
|
+
##
|
97
|
+
## check rails path setup / style ???
|
98
|
+
|
99
|
+
SPORTDB_DIR = "#{SportDb::Boot.root}/sportdb" # path to libs
|
100
|
+
OPENFOOTBALL_DIR = "#{SportDb::Boot.root}/openfootball"
|
101
|
+
## add more "standard" dirs - why? why not? - why? why not?
|
102
|
+
## use
|
103
|
+
## module SportDb::Source / Code / Boot or such????
|
104
|
+
##
|
105
|
+
## use module SportDb::Boot - yes, yes, yes - why? why not?
|
106
|
+
|
data/test/test_base.rb
CHANGED
@@ -6,10 +6,14 @@ require 'helper'
|
|
6
6
|
|
7
7
|
class TestBase < MiniTest::Test
|
8
8
|
|
9
|
+
Git = Mono::Git
|
10
|
+
|
9
11
|
def test_version
|
10
|
-
puts
|
11
|
-
puts
|
12
|
-
puts
|
12
|
+
puts MonoCore::VERSION
|
13
|
+
puts MonoCore.banner
|
14
|
+
puts MonoCore.root
|
15
|
+
|
16
|
+
puts Mono::VERSION
|
13
17
|
end
|
14
18
|
|
15
19
|
def test_root
|
@@ -20,5 +24,28 @@ class TestBase < MiniTest::Test
|
|
20
24
|
puts Mono.env
|
21
25
|
end
|
22
26
|
|
27
|
+
|
28
|
+
def test_git_config
|
29
|
+
puts "---"
|
30
|
+
Git.config( 'user.name' )
|
31
|
+
Git.config( 'user.name', show_origin: true )
|
32
|
+
# Git.config( 'user.name', show_scope: true )
|
33
|
+
|
34
|
+
puts "---"
|
35
|
+
Git.config( /user/ ) ## note: pass in regex for regex match/search
|
36
|
+
Git.config( /user/, show_origin: true )
|
37
|
+
# Git.config( /user/, show_scope: true )
|
38
|
+
|
39
|
+
puts "---"
|
40
|
+
Git.config( /user\./ ) ## note: pass in regex for regex match/search
|
41
|
+
|
42
|
+
puts "---"
|
43
|
+
## note: if NOT found Mono::Git.config will exit(1) !!!
|
44
|
+
## Mono::Git.config( /proxy/, show_origin: true )
|
45
|
+
## Mono::Git.config( /http/, show_origin: true )
|
46
|
+
|
47
|
+
puts "---"
|
48
|
+
end
|
49
|
+
|
23
50
|
end # class TestBase
|
24
51
|
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gitti
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.4.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.4.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gitti-backup
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.4.1
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rdoc
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,7 +70,6 @@ description: monos - monorepo / mono source tree tools and (startup) scripts
|
|
42
70
|
email: opensport@googlegroups.com
|
43
71
|
executables:
|
44
72
|
- mo
|
45
|
-
- moget
|
46
73
|
- mono
|
47
74
|
extensions: []
|
48
75
|
extra_rdoc_files:
|
@@ -55,20 +82,22 @@ files:
|
|
55
82
|
- README.md
|
56
83
|
- Rakefile
|
57
84
|
- bin/mo
|
58
|
-
- bin/moget
|
59
85
|
- bin/mono
|
60
86
|
- lib/mono.rb
|
61
87
|
- lib/mono/base.rb
|
62
|
-
- lib/mono/
|
63
|
-
- lib/mono/
|
64
|
-
- lib/mono/
|
65
|
-
- lib/mono/
|
66
|
-
- lib/mono/
|
88
|
+
- lib/mono/commands/backup.rb
|
89
|
+
- lib/mono/commands/env.rb
|
90
|
+
- lib/mono/commands/fetch.rb
|
91
|
+
- lib/mono/commands/run.rb
|
92
|
+
- lib/mono/commands/status.rb
|
93
|
+
- lib/mono/commands/sync.rb
|
94
|
+
- lib/mono/tool.rb
|
67
95
|
- lib/mono/version.rb
|
68
96
|
- lib/monos.rb
|
97
|
+
- lib/sportdb/setup.rb
|
69
98
|
- test/helper.rb
|
70
99
|
- test/test_base.rb
|
71
|
-
homepage: https://github.com/
|
100
|
+
homepage: https://github.com/rubycoco/monos
|
72
101
|
licenses:
|
73
102
|
- Public Domain
|
74
103
|
metadata: {}
|
data/bin/moget
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
###################
|
4
|
-
# DEV TIPS:
|
5
|
-
#
|
6
|
-
# For local testing run like:
|
7
|
-
#
|
8
|
-
# ruby -Ilib bin/moget
|
9
|
-
#
|
10
|
-
# Set the executable bit in Linux. Example:
|
11
|
-
#
|
12
|
-
# % chmod a+x bin/moget
|
13
|
-
#
|
14
|
-
|
15
|
-
require 'mono'
|
16
|
-
|
17
|
-
Mono::Tool.main( ['sync'] )
|
data/lib/mono/git/base.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
|
2
|
-
class GitError < StandardError
|
3
|
-
end
|
4
|
-
|
5
|
-
class Git ## make Git a module - why? why not?
|
6
|
-
|
7
|
-
###
|
8
|
-
## todo/fix: change opts=nil to *args or such - why? why not?
|
9
|
-
|
10
|
-
|
11
|
-
###############
|
12
|
-
## "setup" starter git commands
|
13
|
-
|
14
|
-
def self.clone( repo, name=nil )
|
15
|
-
cmd = "git clone #{repo}"
|
16
|
-
cmd << " #{name}" unless name.nil? || name.empty?
|
17
|
-
Shell.run( cmd )
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.mirror( repo )
|
21
|
-
cmd = "git clone --mirror #{repo}"
|
22
|
-
Shell.run( cmd )
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
#################
|
27
|
-
## standard git commands
|
28
|
-
|
29
|
-
def self.version
|
30
|
-
cmd = 'git --version'
|
31
|
-
Shell.run( cmd )
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.status( short: false )
|
35
|
-
cmd = 'git status'
|
36
|
-
cmd << " --short" if short
|
37
|
-
Shell.run( cmd )
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.changes ## same as git status --short - keep shortcut / alias - why? why not?
|
41
|
-
## returns changed files - one per line or empty if no changes
|
42
|
-
cmd = 'git status --short'
|
43
|
-
Shell.run( cmd )
|
44
|
-
end
|
45
|
-
|
46
|
-
#####################
|
47
|
-
## status helpers
|
48
|
-
|
49
|
-
## git status --short returns empty stdout/list
|
50
|
-
def self.clean?() changes.empty?; end
|
51
|
-
|
52
|
-
def self.changes?() clean? == false; end ## reverse of clean?
|
53
|
-
class << self
|
54
|
-
alias_method :dirty?, :changes? ## add alias
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
#######
|
59
|
-
## more (major) git commands
|
60
|
-
|
61
|
-
def self.pull
|
62
|
-
cmd = 'git pull'
|
63
|
-
Shell.run( cmd )
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.fast_forward
|
67
|
-
cmd = 'git pull --ff-only'
|
68
|
-
Shell.run( cmd )
|
69
|
-
end
|
70
|
-
class << self
|
71
|
-
alias_method :ff, :fast_forward ## add alias
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
def self.push
|
76
|
-
cmd = 'git push'
|
77
|
-
Shell.run( cmd )
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.add( pathspec=nil ) ## e.g. git add . or git add *.rb or such
|
81
|
-
cmd = 'git add'
|
82
|
-
cmd << " #{pathspec}" unless pathspec.nil? || pathspec.empty?
|
83
|
-
Shell.run( cmd )
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.add_all
|
87
|
-
cmd = 'git add --all'
|
88
|
-
Shell.run( cmd )
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.commit( message: )
|
92
|
-
cmd = 'git commit'
|
93
|
-
cmd << %Q{ -m "#{message}"} unless message.nil? || message.empty?
|
94
|
-
Shell.run( cmd )
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
###
|
99
|
-
# use nested class for "base" for running commands - why? why not?
|
100
|
-
class Shell
|
101
|
-
def self.run( cmd )
|
102
|
-
print "cmd exec >#{cmd}<..."
|
103
|
-
stdout, stderr, status = Open3.capture3( cmd )
|
104
|
-
|
105
|
-
if status.success?
|
106
|
-
print " OK"
|
107
|
-
print "\n"
|
108
|
-
else
|
109
|
-
print " FAIL (#{status.exitstatus})"
|
110
|
-
print "\n"
|
111
|
-
end
|
112
|
-
|
113
|
-
unless stdout.empty?
|
114
|
-
puts stdout
|
115
|
-
end
|
116
|
-
|
117
|
-
unless stderr.empty?
|
118
|
-
## todo/check: or use >2: or &2: or such
|
119
|
-
## stderr output not always an error (that is, exit status might be 0)
|
120
|
-
puts "STDERR:"
|
121
|
-
puts stderr
|
122
|
-
end
|
123
|
-
|
124
|
-
if status.success?
|
125
|
-
stdout # return stdout string
|
126
|
-
else
|
127
|
-
puts "!! ERROR: cmd exec >#{cmd}< failed with exit status #{status.exitstatus}:"
|
128
|
-
puts stderr
|
129
|
-
raise GitError, "git cmd exec >#{cmd}< failed with exit status #{status.exitstatus}<: #{stderr}"
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end # class Shell
|
133
|
-
|
134
|
-
end # class Git
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
class GitRepo
|
139
|
-
def self.open( path, &blk )
|
140
|
-
new( path ).open( &blk )
|
141
|
-
end
|
142
|
-
|
143
|
-
def initialize( path )
|
144
|
-
raise ArgumentError, "dir >#{path}< not found; dir MUST already exist for GitRepo class - sorry" unless Dir.exist?( path )
|
145
|
-
@path = path
|
146
|
-
end
|
147
|
-
|
148
|
-
def open( &blk )
|
149
|
-
## puts "Dir.getwd: #{Dir.getwd}"
|
150
|
-
Dir.chdir( @path ) do
|
151
|
-
blk.call( self )
|
152
|
-
end
|
153
|
-
## puts "Dir.getwd: #{Dir.getwd}"
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
def status( short: false ) Git.status( short: short ); end
|
158
|
-
def changes() Git.changes; end
|
159
|
-
def clean?() Git.clean?; end
|
160
|
-
def changes?() Git.changes?; end
|
161
|
-
alias_method :dirty?, :changes?
|
162
|
-
|
163
|
-
def pull() Git.pull; end
|
164
|
-
def fast_forward() Git.fast_forward; end
|
165
|
-
alias_method :ff, :fast_forward
|
166
|
-
|
167
|
-
def push() Git.push; end
|
168
|
-
|
169
|
-
def add( pathspec ) Git.add( pathspec ); end
|
170
|
-
def add_all() Git.add_all; end
|
171
|
-
def commit( message: ) Git.commit( message: message ); end
|
172
|
-
|
173
|
-
|
174
|
-
end # class GitRepo
|
data/lib/mono/git/sync.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class GitHubRepo ## todo: change to GitHubRepoRef or such - why? why not?
|
4
|
-
attr_reader :owner, :name
|
5
|
-
|
6
|
-
def initialize( owner, name )
|
7
|
-
@owner = owner ## use/rename to login or something - why? why not??
|
8
|
-
@name = name # e.g. "rubylibs/webservice"
|
9
|
-
end
|
10
|
-
|
11
|
-
def ssh_clone_url
|
12
|
-
## check: use https: as default? for github - http:// still supported? or redirected?
|
13
|
-
## "http://github.com/#{@owner}/#{@name}"
|
14
|
-
"git@github.com:#{@owner}/#{@name}.git"
|
15
|
-
end
|
16
|
-
end ## class GitHubRepo
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
module Mono
|
21
|
-
|
22
|
-
def self.monofile
|
23
|
-
path = if File.exist?( './monorepo.yml' )
|
24
|
-
'./monorepo.yml'
|
25
|
-
elsif File.exist?( './monotree.yml' )
|
26
|
-
'./monotree.yml'
|
27
|
-
elsif File.exist?( './repos.yml' )
|
28
|
-
'./repos.yml'
|
29
|
-
else
|
30
|
-
puts "!! WARN: no mo|moget|mono configuration file (that is, monorepo|monotree|repos.yml) found in >#{Dir.getwd}<"
|
31
|
-
nil
|
32
|
-
end
|
33
|
-
|
34
|
-
if path
|
35
|
-
YAML.load_file( path )
|
36
|
-
else
|
37
|
-
{}
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
43
|
-
def self.sync( h=Mono.monofile )
|
44
|
-
count_orgs = 0
|
45
|
-
count_repos = 0
|
46
|
-
|
47
|
-
## sum up total number of repos
|
48
|
-
total_repos = h.reduce(0) {|sum,(_,names)| sum+= names.size; sum }
|
49
|
-
|
50
|
-
h.each do |org_with_counter,names|
|
51
|
-
|
52
|
-
## remove optional number from key e.g.
|
53
|
-
## mrhydescripts (3) => mrhydescripts
|
54
|
-
## footballjs (4) => footballjs
|
55
|
-
## etc.
|
56
|
-
org = org_with_counter.sub( /\([0-9]+\)/, '' ).strip
|
57
|
-
|
58
|
-
org_path = "#{Mono.root}/#{org}"
|
59
|
-
FileUtils.mkdir_p( org_path ) unless Dir.exist?( org_path ) ## make sure path exists
|
60
|
-
|
61
|
-
names.each do |name|
|
62
|
-
puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
|
63
|
-
|
64
|
-
repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
|
65
|
-
|
66
|
-
Dir.chdir( org_path ) do
|
67
|
-
if Dir.exist?( repo.name )
|
68
|
-
GitRepo.open( repo.name ) do |git|
|
69
|
-
if git.changes?
|
70
|
-
puts "!! WARN - local changes in workdir; skipping fast forward (remote) sync / merge"
|
71
|
-
else
|
72
|
-
git.fast_forward ## note: use git pull --ff-only (fast forward only - do NOT merge)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
else
|
76
|
-
Git.clone( repo.ssh_clone_url )
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
#
|
81
|
-
# todo/fix: add (back) error log !!!!!!!!!!!!
|
82
|
-
# rescue GitError => ex
|
83
|
-
# puts "!! ERROR: #{ex.message}"
|
84
|
-
#
|
85
|
-
# File.open( './errors.log', 'a' ) do |f|
|
86
|
-
# f.write "#{Time.now} -- repo #{org}/#{name} - #{ex.message}\n"
|
87
|
-
# end
|
88
|
-
|
89
|
-
count_repos += 1
|
90
|
-
end
|
91
|
-
count_orgs += 1
|
92
|
-
end
|
93
|
-
|
94
|
-
## print stats
|
95
|
-
puts "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
96
|
-
end # method sync
|
97
|
-
|
98
|
-
end # module Mono
|
data/lib/mono/sportdb.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
##########
|
2
|
-
# setup load path
|
3
|
-
# lets you use environments
|
4
|
-
# e.g. dev/development or production
|
5
|
-
|
6
|
-
|
7
|
-
## todo/fix: move later app/gem-family/-specific configs
|
8
|
-
## to its own gem e.g. mono-sportdb or such - why? why not?
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
require_relative '../mono'
|
13
|
-
|
14
|
-
|
15
|
-
## convenience pre-configured/pre-built shortcut - lets you use
|
16
|
-
## require 'mono/sportdb'
|
17
|
-
## Mono.setup
|
18
|
-
|
19
|
-
|
20
|
-
module Mono
|
21
|
-
def self.setup ## setup load path
|
22
|
-
### note: for now always assume dev/development
|
23
|
-
### add ENV check later or pass in as args or such
|
24
|
-
|
25
|
-
puts "Mono.root: >#{root}<"
|
26
|
-
|
27
|
-
$LOAD_PATH.unshift( "#{root}/yorobot/sport.db.more/sportdb-exporters/lib" )
|
28
|
-
$LOAD_PATH.unshift( "#{root}/yorobot/sport.db.more/sportdb-writers/lib" )
|
29
|
-
$LOAD_PATH.unshift( "#{root}/yorobot/sport.db.more/sportdb-linters/lib" )
|
30
|
-
|
31
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sports/lib" )
|
32
|
-
|
33
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-importers/lib" )
|
34
|
-
## todo - add readers, models, sync, etc.
|
35
|
-
|
36
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-catalogs/lib" )
|
37
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-formats/lib" )
|
38
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-structs/lib" )
|
39
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-langs/lib" )
|
40
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/score-formats/lib" )
|
41
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/date-formats/lib" )
|
42
|
-
|
43
|
-
|
44
|
-
pp $: # print load path
|
45
|
-
end
|
46
|
-
end # module Mono
|
47
|
-
|
48
|
-
|
49
|
-
## todo/fix:
|
50
|
-
## use
|
51
|
-
## module Starter
|
52
|
-
## module SportDb
|
53
|
-
## def setup ...
|
54
|
-
## end
|
55
|
-
## end
|
56
|
-
##
|
57
|
-
## or such? and use Mono.extend - why? why not?
|
58
|
-
## module Mono
|
59
|
-
## extend Starter::SportDb
|
60
|
-
## end
|
61
|
-
|