monos 0.5.0 → 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: 7785eb99b7c2f8d35ea8b0f11e06ae8cf366f613
4
- data.tar.gz: f141af65145dd3b7095f7145314558b6245ad54a
3
+ metadata.gz: a2b5768d1c5b1f9862099eb5d67e7c574561f256
4
+ data.tar.gz: e257ffe48bab62974a02b76443e0d0c4aad563af
5
5
  SHA512:
6
- metadata.gz: db773ecea48e74063358fb5c862aaa940bdef1601244e395c54f7f61de7e870525b2c747f77d75c84ff4cd3b4bcdfc221a8eee477085ec56ba426b6ab24f12bd
7
- data.tar.gz: 8076d1725422bce4a74dc07d7dd4eec7252b4e5dea8abbb335fd8663f59bbc5295ecf5353c9147fa36a7c79c6827d9b4d43e97029dc0c2f6379f69a9b0fbece2
6
+ metadata.gz: 63f482ee7c5696cff694e57a22efc2a187a20a074e10c651bbd272acedb03104a8646464fe0386cea3bb71f0e532b7f039ebcec9301c185437ca23ac6bfffad0
7
+ data.tar.gz: 4d6213f4928e6abcb3809101f7b7d299eeaf24c51edeee8424f497bdeed6b3e7406127472e3639eb6efb719d4d98f98663a93b59c77634130074b2053cfc66be
@@ -12,6 +12,7 @@ lib/mono/commands/fetch.rb
12
12
  lib/mono/commands/run.rb
13
13
  lib/mono/commands/status.rb
14
14
  lib/mono/commands/sync.rb
15
+ lib/mono/experimental.rb
15
16
  lib/mono/tool.rb
16
17
  lib/mono/version.rb
17
18
  lib/monos.rb
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Hoe.spec 'monos' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['gitti', '>= 0.6.0' ],
23
+ ['gitti', '>= 0.6.1' ],
24
24
  ['gitti-backup', '>= 0.4.1' ],
25
25
  ]
26
26
 
@@ -18,8 +18,9 @@ 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'
@@ -30,5 +31,4 @@ require 'mono/commands/run'
30
31
  require 'mono/tool'
31
32
 
32
33
 
33
-
34
34
  puts MonoCore.banner # say hello
@@ -7,8 +7,9 @@ module Mono
7
7
  ## check if windows - otherwise use /sites
8
8
  ## check if root directory exists?
9
9
  if ENV['MOPATH']
10
- ENV['MOPATH']
11
- elsif Dir.exist?( 'C:/Sites' )
10
+ ## use expand path to make (assure) absolute path - why? why not?
11
+ ::File.expand_path( ENV['MOPATH'] )
12
+ elsif ::Dir.exist?( 'C:/Sites' )
12
13
  'C:/Sites'
13
14
  else
14
15
  '/sites'
@@ -16,12 +17,20 @@ module Mono
16
17
  end
17
18
  end
18
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
+
19
28
  def self.monofile
20
- path = if File.exist?( './monorepo.yml' )
29
+ path = if ::File.exist?( './monorepo.yml' )
21
30
  './monorepo.yml'
22
- elsif File.exist?( './monotree.yml' )
31
+ elsif ::File.exist?( './monotree.yml' )
23
32
  './monotree.yml'
24
- elsif File.exist?( './repos.yml' )
33
+ elsif ::File.exist?( './repos.yml' )
25
34
  './repos.yml'
26
35
  else
27
36
  puts "!! WARN: no mono configuration file (that is, {monorepo,monotree,repos}.yml) found in >#{Dir.getwd}<"
@@ -34,7 +43,95 @@ module Mono
34
43
  GitRepoSet.new( {} ) ## return empty set -todo/check: return nil - why? why not?
35
44
  end
36
45
  end
37
-
38
46
  end ## module Mono
39
47
 
40
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
+
@@ -1,5 +1,4 @@
1
1
  module Mono
2
-
3
2
  ## pass along hash of repos (e.g. monorepo.yml or repos.yml )
4
3
  def self.fetch
5
4
  repos = Mono.monofile
@@ -19,8 +18,8 @@ module Mono
19
18
 
20
19
  repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
21
20
 
22
- Dir.chdir( org_path ) do
23
- if Dir.exist?( repo.name )
21
+ ::Dir.chdir( org_path ) do
22
+ if ::Dir.exist?( repo.name )
24
23
  GitProject.open( repo.name ) do |proj|
25
24
  proj.fetch
26
25
  end
@@ -22,8 +22,8 @@ module Mono
22
22
 
23
23
  repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
24
24
 
25
- Dir.chdir( org_path ) do
26
- if Dir.exist?( repo.name )
25
+ ::Dir.chdir( org_path ) do
26
+ if ::Dir.exist?( repo.name )
27
27
  GitProject.open( repo.name ) do |proj|
28
28
  proj.run( cmd )
29
29
  end
@@ -20,8 +20,8 @@ module Mono
20
20
 
21
21
  repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
22
22
 
23
- Dir.chdir( org_path ) do
24
- if Dir.exist?( repo.name )
23
+ ::Dir.chdir( org_path ) do
24
+ if ::Dir.exist?( repo.name )
25
25
  GitProject.open( repo.name ) do |proj|
26
26
  output = proj.changes
27
27
  if output.empty?
@@ -11,15 +11,15 @@ module Mono
11
11
 
12
12
  repos.each do |org,names|
13
13
  org_path = "#{Mono.root}/#{org}"
14
- FileUtils.mkdir_p( org_path ) unless Dir.exist?( org_path ) ## make sure path exists
14
+ ::FileUtils.mkdir_p( org_path ) unless ::Dir.exist?( org_path ) ## make sure path exists
15
15
 
16
16
  names.each do |name|
17
17
  puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
18
18
 
19
19
  repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
20
20
 
21
- Dir.chdir( org_path ) do
22
- if Dir.exist?( repo.name )
21
+ ::Dir.chdir( org_path ) do
22
+ if ::Dir.exist?( repo.name )
23
23
  GitProject.open( repo.name ) do |proj|
24
24
  if proj.changes?
25
25
  puts "!! WARN - local changes in workdir; skipping fast forward (remote) sync / merge"
@@ -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
@@ -6,7 +6,7 @@ module MonoCore ## todo/check: rename to MonoMeta, MonoModule or such - why? w
6
6
  ## note: move root to its own namespace to avoid
7
7
  ## conflict with Mono.root!!!!
8
8
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
9
- MINOR = 5
9
+ MINOR = 6
10
10
  PATCH = 0
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.5.0
4
+ version: 0.6.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-10-21 00:00:00.000000000 Z
11
+ date: 2020-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitti
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.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.6.0
26
+ version: 0.6.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gitti-backup
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -97,6 +97,7 @@ files:
97
97
  - lib/mono/commands/run.rb
98
98
  - lib/mono/commands/status.rb
99
99
  - lib/mono/commands/sync.rb
100
+ - lib/mono/experimental.rb
100
101
  - lib/mono/tool.rb
101
102
  - lib/mono/version.rb
102
103
  - lib/monos.rb