monos 0.3.1 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee4368f5e1359184cd8592946f23e9140c72d28b
4
- data.tar.gz: c6bcc16a6c88e0ffe2266fee1bce4b5a12772874
3
+ metadata.gz: 62adfa9ee77f46c0ff4a0c5c7946a4ccf5cac96e
4
+ data.tar.gz: e0d7a90b32fb6b422e00667570d69a6dea33ab09
5
5
  SHA512:
6
- metadata.gz: 0675326b562361aef8d40f39db0a20b1d20767b44d1bdea716170e5dd006af94375e89c5e05d2c8681c8fff0958f99de9a08a7bc09c55f1d1fe1b1ad997cb037
7
- data.tar.gz: d3c5e25625174b05bc9a098e64f7614eea15fe15699a9bbfafe98bcb01d2b1dacfd1022801e344202fe9c7b5470561e6b970ae74df3f9b07ea11dbe8f3c1ed77
6
+ metadata.gz: 149cc0dc4355b4dbe4e4c1dfd715edec2b692d62b2de8487dff55ee51a00e82a5fa832bf1ae1c1ee480ca99afaf5f6a447003dc1ac6db961cbc9e5d9c928c4dc
7
+ data.tar.gz: 7d7e020fff8866dd966835e5a260c70282b03a87314b204bc539fe8b77333e345bfb34d159b282bcf4be06710ec621765a77f5350200dd389baddc1cc1270b22
@@ -6,14 +6,15 @@ bin/mo
6
6
  bin/mono
7
7
  lib/mono.rb
8
8
  lib/mono/base.rb
9
+ lib/mono/commands/backup.rb
9
10
  lib/mono/commands/env.rb
10
11
  lib/mono/commands/fetch.rb
11
12
  lib/mono/commands/run.rb
12
13
  lib/mono/commands/status.rb
13
14
  lib/mono/commands/sync.rb
15
+ lib/mono/experimental.rb
14
16
  lib/mono/tool.rb
15
17
  lib/mono/version.rb
16
18
  lib/monos.rb
17
- lib/sportdb/setup.rb
18
19
  test/helper.rb
19
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/rubycoco/sport.db](https://github.com/rubycoco/monos)
5
- * bugs :: [github.com/rubycoco/sport.db/issues](https://github.com/rubycoco/monos/issues)
4
+ * home :: [github.com/rubycoco/git](https://github.com/rubycoco/git)
5
+ * bugs :: [github.com/rubycoco/git/issues](https://github.com/rubycoco/git/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)
@@ -52,7 +52,7 @@ openfootball:
52
52
 
53
53
  ### Commands
54
54
 
55
- `status` • `fetch` • `sync` • `run` •`env`
55
+ `status` • `fetch` • `sync` • `run` • `env` • `backup`
56
56
 
57
57
  ### `status` Command
58
58
 
@@ -141,6 +141,20 @@ Note: `exec` is an alias that you can use for `run`.
141
141
  Use the `env` command to check your `mono` environment setup.
142
142
 
143
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
+
144
158
  That's all for now.
145
159
 
146
160
 
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ Hoe.spec 'monos' do
8
8
  self.summary = "monos - monorepo / mono source tree tools and (startup) scripts"
9
9
  self.description = summary
10
10
 
11
- self.urls = { home: 'https://github.com/rubycoco/monos' }
11
+ self.urls = { home: 'https://github.com/rubycoco/git' }
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
14
  self.email = 'opensport@googlegroups.com'
@@ -20,8 +20,8 @@ Hoe.spec 'monos' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['gitti', '>= 0.4.0' ],
24
- ['gitti-backup', '>= 0.3.0' ],
23
+ ['gitti', '>= 0.6.1' ],
24
+ ['gitti-backup', '>= 0.4.1' ],
25
25
  ]
26
26
 
27
27
  self.spec_extras = {
@@ -18,16 +18,17 @@ end
18
18
 
19
19
  ###
20
20
  # our own code
21
- require 'mono/version' # let version always go first
21
+ require 'mono/version' # let version always go first
22
22
  require 'mono/base'
23
+ require 'mono/experimental'
23
24
 
24
25
  require 'mono/commands/status'
25
26
  require 'mono/commands/fetch'
26
27
  require 'mono/commands/sync'
27
28
  require 'mono/commands/env'
29
+ require 'mono/commands/backup'
28
30
  require 'mono/commands/run'
29
31
  require 'mono/tool'
30
32
 
31
33
 
32
-
33
34
  puts MonoCore.banner # say hello
@@ -1,40 +1,130 @@
1
-
2
- module Mono
3
-
4
- def self.root ## root of single (monorepo) source tree
5
- @@root ||= begin
6
- ## todo/fix:
7
- ## check if windows - otherwise use /sites
8
- ## check if root directory exists?
9
- if ENV['MOPATH']
10
- ENV['MOPATH']
11
- elsif Dir.exist?( 'C:/Sites' )
12
- 'C:/Sites'
13
- else
14
- '/sites'
15
- end
16
- end
17
- end
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
-
38
- end ## module Mono
39
-
40
-
1
+
2
+ module Mono
3
+
4
+ def self.root ## root of single (monorepo) source tree
5
+ @@root ||= begin
6
+ ## todo/fix:
7
+ ## check if windows - otherwise use /sites
8
+ ## check if root directory exists?
9
+ if ENV['MOPATH']
10
+ ## use expand path to make (assure) absolute path - why? why not?
11
+ ::File.expand_path( ENV['MOPATH'] )
12
+ elsif ::Dir.exist?( 'C:/Sites' )
13
+ 'C:/Sites'
14
+ else
15
+ '/sites'
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.root=( path )
21
+ ## use expand path to make (assure) absolute path - why? why not?
22
+ @@root = ::File.expand_path( path )
23
+ end
24
+
25
+
26
+
27
+
28
+ def self.monofile
29
+ path = if ::File.exist?( './monorepo.yml' )
30
+ './monorepo.yml'
31
+ elsif ::File.exist?( './monotree.yml' )
32
+ './monotree.yml'
33
+ elsif ::File.exist?( './repos.yml' )
34
+ './repos.yml'
35
+ else
36
+ puts "!! WARN: no mono configuration file (that is, {monorepo,monotree,repos}.yml) found in >#{Dir.getwd}<"
37
+ nil
38
+ end
39
+
40
+ if path
41
+ GitRepoSet.read( path )
42
+ else
43
+ GitRepoSet.new( {} ) ## return empty set -todo/check: return nil - why? why not?
44
+ end
45
+ end
46
+ end ## module Mono
47
+
48
+
49
+
50
+
51
+ #####################
52
+ # add file and repo helper
53
+
54
+ ##
55
+ ## todo/fix: ALWAYS assert name format
56
+ ## (rename to mononame and monopath) - why? why not?
57
+
58
+ class MonoGitHub
59
+ def self.clone( name, depth: nil )
60
+ path = MonoFile.real_path( name )
61
+
62
+ org_path = File.dirname( path )
63
+ FileUtils.mkdir_p( org_path ) unless Dir.exist?( org_path ) ## make sure path exists
64
+
65
+ ### note: use a github clone url (using ssh) like:
66
+ ## git@github.com:rubycoco/gitti.git
67
+ ssh_clone_url = "git@github.com:#{name}.git"
68
+
69
+ Dir.chdir( org_path ) do
70
+ Gitti::Git.clone( ssh_clone_url, depth: depth )
71
+ end
72
+ end
73
+ end
74
+ MonoGithub = MonoGitHub ## add convenience (typo?) alias
75
+
76
+
77
+
78
+ class MonoGitProject
79
+ def self.open( name, &block )
80
+ path = MonoFile.real_path( name )
81
+ Gitti::GitProject.open( path, &block )
82
+ end
83
+ end
84
+
85
+
86
+
87
+ class MonoFile
88
+ ## e.g. openfootball/austria etc.
89
+ ## expand to to "real" absolute path
90
+ ##
91
+ ## todo/check: assert name must be {orgname,username}/reponame
92
+ def self.real_path( path )
93
+ "#{Mono.root}/#{path}"
94
+ end
95
+ def self.exist?( path )
96
+ ::File.exist?( real_path( path ))
97
+ end
98
+
99
+
100
+ ## path always relative to Mono.root
101
+ ## todo/fix: use File.expand_path( path, Mono.root ) - why? why not?
102
+ ## or always enfore "absolut" path e.g. do NOT allow ../ or ./ or such
103
+ def self.open( path, mode='r:utf-8', &block )
104
+ full_path = real_path( path )
105
+ ## make sure path exists if we open for writing/appending - why? why not?
106
+ if mode[0] == 'w' || mode[0] == 'a'
107
+ ::FileUtils.mkdir_p( ::File.dirname( full_path ) ) ## make sure path exists
108
+ end
109
+
110
+ ::File.open( full_path, mode ) do |file|
111
+ block.call( file )
112
+ end
113
+ end
114
+
115
+ def self.read_utf8( path )
116
+ open( path, 'r:utf-8') { |file| file.read }
117
+ end
118
+ end ## class MonoFile
119
+
120
+
121
+
122
+ module Mono
123
+ #################
124
+ ## add some short cuts
125
+ def self.open( name, &block ) MonoGitProject.open( name, &block ); end
126
+ def self.clone( name, depth: nil ) MonoGitHub.clone( name, depth: depth ); end
127
+ def self.real_path( name) MonoFile.real_path( name ); end
128
+ end ## module Mono
129
+
130
+
@@ -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
@@ -1,26 +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
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
@@ -1,44 +1,43 @@
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
1
+ module Mono
2
+ ## pass along hash of repos (e.g. monorepo.yml or repos.yml )
3
+ def self.fetch
4
+ repos = Mono.monofile
5
+
6
+ count_orgs = 0
7
+ count_repos = 0
8
+
9
+ total_repos = repos.size
10
+
11
+
12
+ repos.each do |org,names|
13
+
14
+ org_path = "#{Mono.root}/#{org}"
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
+ proj.fetch
25
+ end
26
+ else
27
+ puts "!! repo not found / missing"
28
+ end
29
+ end
30
+
31
+ count_repos += 1
32
+ end
33
+ count_orgs += 1
34
+ end
35
+
36
+
37
+ ## print stats & changes summary
38
+ puts
39
+ print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
40
+ print "\n"
41
+ end # method fetch
42
+
43
+ end # module Mono
@@ -1,47 +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
+ 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,65 +1,65 @@
1
- module Mono
2
-
3
- ## pass along hash of repos (e.g. monorepo.yml or repos.yml )
4
- def self.status
5
- repos = Mono.monofile
6
-
7
- changes = [] ## track changes
8
-
9
- count_orgs = 0
10
- count_repos = 0
11
-
12
- total_repos = repos.size
13
-
14
- repos.each do |org,names|
15
-
16
- org_path = "#{Mono.root}/#{org}"
17
-
18
- names.each do |name|
19
- puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
20
-
21
- repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
22
-
23
- Dir.chdir( org_path ) do
24
- if Dir.exist?( repo.name )
25
- GitProject.open( repo.name ) do |proj|
26
- output = proj.changes
27
- if output.empty?
28
- puts " - no changes -"
29
- else
30
- changes << ["#{org}@#{name}", :CHANGES, output]
31
- end
32
- end
33
- else
34
- puts "!! repo not found / missing"
35
- changes << ["#{org}@#{name}", :NOT_FOUND]
36
- end
37
- end
38
-
39
- count_repos += 1
40
- end
41
- count_orgs += 1
42
- end
43
-
44
-
45
- ## print stats & changes summary
46
- puts
47
- print "#{changes.size} change(s) in "
48
- print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
49
- print "\n"
50
-
51
- changes.each do |item|
52
- puts
53
- print "== #{item[0]} - #{item[1]}"
54
- case item[1]
55
- when :CHANGES
56
- print ":\n"
57
- print item[2]
58
- when :NOT_FOUND
59
- print "\n"
60
- end
61
- end
62
-
63
- end # method status
64
-
65
- end # module Mono
1
+ module Mono
2
+
3
+ ## pass along hash of repos (e.g. monorepo.yml or repos.yml )
4
+ def self.status
5
+ repos = Mono.monofile
6
+
7
+ changes = [] ## track changes
8
+
9
+ count_orgs = 0
10
+ count_repos = 0
11
+
12
+ total_repos = repos.size
13
+
14
+ repos.each do |org,names|
15
+
16
+ org_path = "#{Mono.root}/#{org}"
17
+
18
+ names.each do |name|
19
+ puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
20
+
21
+ repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
22
+
23
+ ::Dir.chdir( org_path ) do
24
+ if ::Dir.exist?( repo.name )
25
+ GitProject.open( repo.name ) do |proj|
26
+ output = proj.changes
27
+ if output.empty?
28
+ puts " - no changes -"
29
+ else
30
+ changes << ["#{org}@#{name}", :CHANGES, output]
31
+ end
32
+ end
33
+ else
34
+ puts "!! repo not found / missing"
35
+ changes << ["#{org}@#{name}", :NOT_FOUND]
36
+ end
37
+ end
38
+
39
+ count_repos += 1
40
+ end
41
+ count_orgs += 1
42
+ end
43
+
44
+
45
+ ## print stats & changes summary
46
+ puts
47
+ print "#{changes.size} change(s) in "
48
+ print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
49
+ print "\n"
50
+
51
+ changes.each do |item|
52
+ puts
53
+ print "== #{item[0]} - #{item[1]}"
54
+ case item[1]
55
+ when :CHANGES
56
+ print ":\n"
57
+ print item[2]
58
+ when :NOT_FOUND
59
+ print "\n"
60
+ end
61
+ end
62
+
63
+ end # method status
64
+
65
+ end # module Mono
@@ -1,53 +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
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
@@ -0,0 +1,104 @@
1
+ ##############
2
+ # experimental stuff
3
+ #
4
+
5
+ module Mono
6
+
7
+ ######################
8
+ ### lint/print mono (source) tree
9
+ ### - check for git repos (via .git/ dir)
10
+ #
11
+ # turn into
12
+ # - tree or
13
+ # - lint or
14
+ # - doctor or
15
+ # - check or such command - why? why not?
16
+ def self.walk( path=root)
17
+ repos = walk_dir( path )
18
+ repos
19
+ end
20
+
21
+
22
+ ###############
23
+ # private helpers
24
+ private
25
+
26
+ ## todo/check - use max_depth or max_level or such - why? why not?
27
+ def self.walk_dir( path, repos=[], level=1, depth: nil )
28
+ entries = ::Dir.entries(path)
29
+
30
+ ## filter dirs
31
+ dirs = entries.select do |entry|
32
+ if ['..', '.'].include?( entry ) ## first check for excludes
33
+ false
34
+ else
35
+ full_path = ::File.join( path, entry )
36
+ ::File.directory?( full_path )
37
+ end
38
+ end
39
+
40
+ if dirs.size == 0 ## shortcircuit - no dirs in dir
41
+ return repos
42
+ end
43
+
44
+ repos_count = 0 ## note: local (only) repos count
45
+ warns_count = 0
46
+ sub_dirs = []
47
+
48
+
49
+
50
+ buf = String.new('') ## use an output buffer (allows optional print)
51
+
52
+
53
+ buf << ">#{path}< - level #{level}:\n"
54
+ dirs.each do |entry|
55
+ next if ['..', '.', '.git'].include?( entry )
56
+ full_path = ::File.join( path, entry )
57
+
58
+ if ::Dir.exist?( ::File.join( full_path, '.git' ))
59
+ repos_count += 1
60
+
61
+ if level == 1
62
+ warns_count += 1
63
+ buf << "!! WARN - top-level repo (w/o user/org) >#{entry}< @ #{path}\n"
64
+ end
65
+
66
+ if level > 2
67
+ warns_count += 1
68
+ buf << "!! WARN - hidden (?) sub-level #{level} repo (nested too deep?) >#{entry}< @ #{path}\n"
69
+ end
70
+
71
+ buf << " repo ##{'%-2d' % repos_count} | "
72
+ buf << "#{'%-20s' % entry} @ #{::File.basename(path)} (#{path})"
73
+ buf << "\n"
74
+ repos << full_path
75
+
76
+ ## check for bare bone git repos - todo/fix: add .gitconfig or such and more - why? why not?
77
+ elsif ::Dir.exist?( ::File.join( full_path, 'hooks' )) &&
78
+ ::Dir.exist?( ::File.join( full_path, 'info' )) &&
79
+ ::Dir.exist?( ::File.join( full_path, 'objects' )) &&
80
+ ::Dir.exist?( ::File.join( full_path, 'refs' ))
81
+ warns_count += 1
82
+ buf << "!! WARN - skip bare git repo >#{entry}< @ #{path}\n"
83
+ else
84
+ buf << " x >#{entry}<\n"
85
+ sub_dirs << entry
86
+ end
87
+ end
88
+ buf << " #{repos_count} repos(s), #{dirs.size} dir(s), #{warns_count} warn(s)\n"
89
+ buf << "\n"
90
+
91
+ ## note: skip output of "plain" diretory listings (no repos, no warnings)
92
+ puts buf if repos_count > 0 || warns_count > 0
93
+
94
+
95
+ sub_dirs.each do |entry|
96
+ ## continue walking
97
+ full_path = ::File.join( path, entry )
98
+ walk_dir( full_path, repos, level+1, depth: depth )
99
+ end
100
+
101
+ repos
102
+ end
103
+
104
+ end # module Mono
@@ -1,39 +1,46 @@
1
- module Mono
2
-
3
-
4
- class Tool
5
- def self.main( args=ARGV )
6
-
7
- ## note: for now assume first argument is command
8
- ## add options later
9
-
10
- cmd = if args.size == 0
11
- 'status' ## make status "default" command
12
- else
13
- args.shift ## remove first (head) element
14
- end
15
-
16
- ## note: allow shortcut for commands
17
- case cmd.downcase
18
- when 'status', 'stati', 'stat', 'st', 's'
19
- Mono.status
20
- when 'sync', 'syn', 'sy', ## note: allow aliases such as install, get & up too
21
- 'get', 'g',
22
- 'install', 'insta', 'inst', 'ins', 'i',
23
- 'up', 'u'
24
- Mono.sync
25
- when 'fetch', 'f'
26
- Mono.fetch
27
- when 'env', 'e'
28
- Mono.env
29
- when 'run', 'r', 'exec'
30
- Mono.run( args )
31
- else
32
- puts "!! ERROR: unknown command >#{cmd}<"
33
- exit 1
34
- end
35
-
36
- end # method self.main
37
- end # class Tool
38
-
1
+ module Mono
2
+
3
+
4
+ class Tool
5
+ def self.main( args=ARGV )
6
+
7
+ ## note: for now assume first argument is command
8
+ ## add options later
9
+
10
+ cmd = if args.size == 0
11
+ 'status' ## make status "default" command
12
+ else
13
+ args.shift ## remove first (head) element
14
+ end
15
+
16
+ ## note: allow shortcut for commands
17
+ case cmd.downcase
18
+ when 'status', 'stati', 'stat', 'st', 's'
19
+ Mono.status
20
+ when 'sync', 'syn', 'sy', ## note: allow aliases such as install, get & up too
21
+ 'get', 'g',
22
+ 'install', 'insta', 'inst', 'ins', 'i',
23
+ 'up', 'u'
24
+ Mono.sync
25
+ when 'fetch', 'f'
26
+ Mono.fetch
27
+ when 'env', 'e'
28
+ Mono.env
29
+ when 'backup', 'back', 'b'
30
+ Mono.backup
31
+ when 'run', 'r', 'exec'
32
+ Mono.run( args )
33
+
34
+ ##################
35
+ ## for debugging / linting
36
+ when 'walk'
37
+ Mono.walk
38
+ else
39
+ puts "!! ERROR: unknown command >#{cmd}<"
40
+ exit 1
41
+ end
42
+
43
+ end # method self.main
44
+ end # class Tool
45
+
39
46
  end # module Mono
@@ -5,8 +5,8 @@ module MonoCore ## todo/check: rename to MonoMeta, MonoModule or such - why? w
5
5
 
6
6
  ## note: move root to its own namespace to avoid
7
7
  ## conflict with Mono.root!!!!
8
- MAJOR = 0 ## todo: namespace inside version or something - why? why not??
9
- MINOR = 3
8
+ MAJOR = 1 ## todo: namespace inside version or something - why? why not??
9
+ MINOR = 0
10
10
  PATCH = 1
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.0.1
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-06 00:00:00.000000000 Z
11
+ date: 2020-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitti
@@ -16,56 +16,62 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.4.0
19
+ version: 0.6.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.4.0
26
+ version: 0.6.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gitti-backup
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.0
33
+ version: 0.4.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.3.0
40
+ version: 0.4.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4.0'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '7'
48
51
  type: :development
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
57
  version: '4.0'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '7'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: hoe
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '3.16'
67
+ version: '3.22'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '3.16'
74
+ version: '3.22'
69
75
  description: monos - monorepo / mono source tree tools and (startup) scripts
70
76
  email: opensport@googlegroups.com
71
77
  executables:
@@ -85,18 +91,19 @@ files:
85
91
  - bin/mono
86
92
  - lib/mono.rb
87
93
  - lib/mono/base.rb
94
+ - lib/mono/commands/backup.rb
88
95
  - lib/mono/commands/env.rb
89
96
  - lib/mono/commands/fetch.rb
90
97
  - lib/mono/commands/run.rb
91
98
  - lib/mono/commands/status.rb
92
99
  - lib/mono/commands/sync.rb
100
+ - lib/mono/experimental.rb
93
101
  - lib/mono/tool.rb
94
102
  - lib/mono/version.rb
95
103
  - lib/monos.rb
96
- - lib/sportdb/setup.rb
97
104
  - test/helper.rb
98
105
  - test/test_base.rb
99
- homepage: https://github.com/rubycoco/monos
106
+ homepage: https://github.com/rubycoco/git
100
107
  licenses:
101
108
  - Public Domain
102
109
  metadata: {}
@@ -1,106 +0,0 @@
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
-