monos 0.2.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70c115bc6f5762608c35c75b05991cafa719485f
4
- data.tar.gz: f6c91d659878aacc2f5902b0525acbbd27a52106
3
+ metadata.gz: a2b5768d1c5b1f9862099eb5d67e7c574561f256
4
+ data.tar.gz: e257ffe48bab62974a02b76443e0d0c4aad563af
5
5
  SHA512:
6
- metadata.gz: d7c3067d9f56f3b4888017540746ae118dae15cf3c9a46a86d47f5489ac07246105feccf608203c23628f5c15c3a11ff71fca8816f13226aa9e31f21ca6b0d97
7
- data.tar.gz: 2e19f6360434425c493ff6bbfbf72fef6b22e7e4d96ec7d99a5a28d7aa89c2599fb009bc8686ee725375b04bbce0ca11d4d9a5b6fed54838e73784feb4e9f479
6
+ metadata.gz: 63f482ee7c5696cff694e57a22efc2a187a20a074e10c651bbd272acedb03104a8646464fe0386cea3bb71f0e532b7f039ebcec9301c185437ca23ac6bfffad0
7
+ data.tar.gz: 4d6213f4928e6abcb3809101f7b7d299eeaf24c51edeee8424f497bdeed6b3e7406127472e3639eb6efb719d4d98f98663a93b59c77634130074b2053cfc66be
@@ -6,12 +6,13 @@ 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
12
+ lib/mono/commands/run.rb
11
13
  lib/mono/commands/status.rb
12
14
  lib/mono/commands/sync.rb
13
- lib/mono/git/base.rb
14
- lib/mono/sportdb.rb
15
+ lib/mono/experimental.rb
15
16
  lib/mono/tool.rb
16
17
  lib/mono/version.rb
17
18
  lib/monos.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/sportdb/sport.db](https://github.com/sportdb/sport.db)
5
- * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/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` • `env`
55
+ `status` • `fetch` • `sync` • `run` • `env` • `backup`
56
56
 
57
57
  ### `status` Command
58
58
 
@@ -114,12 +114,47 @@ $ mo get
114
114
  Note: `install` or `get` or `up` are all aliases that you can use for `sync`.
115
115
 
116
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`.
136
+
137
+
117
138
 
118
139
  ### `env` Command
119
140
 
120
141
  Use the `env` command to check your `mono` environment setup.
121
142
 
122
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
+
123
158
  That's all for now.
124
159
 
125
160
 
data/Rakefile CHANGED
@@ -3,13 +3,12 @@ require './lib/mono/version.rb'
3
3
 
4
4
  Hoe.spec 'monos' do
5
5
 
6
- self.version = Mono::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 = ['https://github.com/sportdb/sport.db' ]
12
- self.urls = { home: 'https://github.com/sportdb/sport.db' }
11
+ self.urls = { home: 'https://github.com/rubycoco/git' }
13
12
 
14
13
  self.author = 'Gerald Bauer'
15
14
  self.email = 'opensport@googlegroups.com'
@@ -20,7 +19,10 @@ Hoe.spec 'monos' do
20
19
 
21
20
  self.licenses = ['Public Domain']
22
21
 
23
- self.extra_deps = []
22
+ self.extra_deps = [
23
+ ['gitti', '>= 0.6.1' ],
24
+ ['gitti-backup', '>= 0.4.1' ],
25
+ ]
24
26
 
25
27
  self.spec_extras = {
26
28
  required_ruby_version: '>= 2.2.2'
@@ -1,24 +1,34 @@
1
- require 'pp'
2
- require 'time'
3
- require 'date'
4
- require 'yaml'
5
- require 'open3'
6
- require 'fileutils'
7
- require 'optparse'
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
- require 'mono/version' # let version always go first
21
+ require 'mono/version' # let version always go first
13
22
  require 'mono/base'
14
- require 'mono/git/base'
23
+ require 'mono/experimental'
15
24
 
16
25
  require 'mono/commands/status'
17
26
  require 'mono/commands/fetch'
18
27
  require 'mono/commands/sync'
19
28
  require 'mono/commands/env'
29
+ require 'mono/commands/backup'
30
+ require 'mono/commands/run'
20
31
  require 'mono/tool'
21
32
 
22
33
 
23
-
24
- puts Mono::Module.banner # say hello
34
+ puts MonoCore.banner # say hello
@@ -1,40 +1,137 @@
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
- YAML.load_file( path )
33
- else
34
- {}
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 )
60
+ path = MonoFile.expand_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 )
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.expand_path( name )
81
+ Gitti::GitProject.open( path, &block )
82
+ end
83
+ end
84
+
85
+
86
+ module Mono
87
+ ## add some short cuts
88
+ def self.open( name, &block ) MonoGitProject.open( name, &block ); end
89
+ def self.clone( name ) MonoGitHub.clone( name ); end
90
+ end
91
+
92
+
93
+
94
+ class MonoFile
95
+ ## e.g. openfootball/austria etc.
96
+ ## expand to to "real" absolute path
97
+ ##
98
+ ## todo/check: assert name must be {orgname,username}/reponame
99
+ def self.expand_path( path )
100
+ "#{Mono.root}/#{path}"
101
+ end
102
+ def self.exist?( path )
103
+ ::File.exist?( expand_path( path ))
104
+ end
105
+
106
+
107
+ ## add some aliases - why? why not?
108
+ class << self
109
+ alias_method :real_path, :expand_path
110
+ alias_method :exists?, :exist? ## add deprecated exists? too - why? why not?
111
+ end
112
+
113
+
114
+
115
+ ## path always relative to Mono.root
116
+ ## todo/fix: use File.expand_path( path, Mono.root ) - why? why not?
117
+ ## or always enfore "absolut" path e.g. do NOT allow ../ or ./ or such
118
+ def self.open( path, mode='r:utf-8', &block )
119
+ full_path = "#{Mono.root}/#{path}"
120
+ ## make sure path exists if we open for writing/appending - why? why not?
121
+ if mode[0] == 'w' || mode[0] == 'a'
122
+ ::FileUtils.mkdir_p( ::File.dirname( full_path ) ) ## make sure path exists
123
+ end
124
+
125
+ ::File.open( full_path, mode ) do |file|
126
+ block.call( file )
127
+ end
128
+ end
129
+
130
+ def self.read_utf8( path )
131
+ open( path, 'r:utf-8') { |file| file.read }
132
+ end
133
+ end ## class MonoFile
134
+
135
+
136
+
137
+
@@ -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,13 +1,26 @@
1
- module Mono
2
-
3
- def self.env ## check environment setup
4
- puts "Mono.root (MOPATH): >#{Mono.root}<"
5
- puts "Mono::Module.root: >#{Mono::Module.root}<"
6
- puts "git version:"
7
- Git.version
8
- puts
9
- puts "monorepo.yml:"
10
- pp Mono.monofile
11
- end
12
-
13
- 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,49 +1,43 @@
1
- module Mono
2
-
3
- ## pass along hash of repos (e.g. monorepo.yml or repos.yml )
4
- def self.fetch( h=Mono.monofile )
5
- count_orgs = 0
6
- count_repos = 0
7
-
8
- ## sum up total number of repos
9
- total_repos = h.reduce(0) {|sum,(_,names)| sum+= names.size; sum }
10
-
11
-
12
- h.each do |org_with_counter,names|
13
-
14
- ## remove optional number from key e.g.
15
- ## mrhydescripts (3) => mrhydescripts
16
- ## footballjs (4) => footballjs
17
- ## etc.
18
- org = org_with_counter.sub( /\([0-9]+\)/, '' ).strip
19
-
20
- org_path = "#{Mono.root}/#{org}"
21
-
22
- names.each do |name|
23
- puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
24
-
25
- repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
26
-
27
- Dir.chdir( org_path ) do
28
- if Dir.exist?( repo.name )
29
- GitProject.open( repo.name ) do |git|
30
- git.fetch
31
- end
32
- else
33
- puts "!! repo not found / missing"
34
- end
35
- end
36
-
37
- count_repos += 1
38
- end
39
- count_orgs += 1
40
- end
41
-
42
-
43
- ## print stats & changes summary
44
- puts
45
- print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
46
- print "\n"
47
- end # method fetch
48
-
49
- 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