git_tree 0.2.3 → 1.0.0
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 +4 -4
- data/.rubocop.yml +25 -6
- data/CHANGELOG.md +48 -13
- data/README.md +356 -68
- data/exe/git-commitAll +3 -0
- data/exe/git-evars +3 -0
- data/exe/git-exec +3 -0
- data/exe/git-replicate +3 -0
- data/exe/git-update +3 -0
- data/git_tree.gemspec +23 -13
- data/lib/commands/abstract_command.rb +88 -0
- data/lib/commands/git_commit_all.rb +155 -0
- data/lib/commands/git_evars.rb +159 -0
- data/lib/commands/git_exec.rb +104 -0
- data/lib/commands/git_exec_spec.rb +0 -0
- data/lib/commands/git_replicate.rb +91 -0
- data/lib/commands/git_update.rb +113 -0
- data/lib/git_tree/version.rb +1 -1
- data/lib/git_tree.rb +10 -26
- data/lib/util/command_runner.rb +12 -0
- data/lib/{util.rb → util/gem_support.rb} +16 -6
- data/lib/util/git_tree_walker.rb +75 -0
- data/lib/util/git_tree_walker_private.rb +60 -0
- data/lib/util/log.rb +49 -0
- data/lib/util/thread_pool_manager.rb +116 -0
- data/lib/util/zowee_optimizer.rb +136 -0
- metadata +55 -19
- data/bindir/git-tree-evars +0 -5
- data/bindir/git-tree-replicate +0 -5
- data/lib/git_tree_evars.rb +0 -82
- data/lib/git_tree_replicate.rb +0 -86
metadata
CHANGED
@@ -1,15 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
|
-
|
9
|
-
bindir: bindir
|
8
|
+
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: gem_support
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
13
26
|
- !ruby/object:Gem::Dependency
|
14
27
|
name: rainbow
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,16 +52,27 @@ dependencies:
|
|
39
52
|
- !ruby/object:Gem::Version
|
40
53
|
version: '0'
|
41
54
|
description: |
|
42
|
-
Installs
|
55
|
+
Installs 5 commands that process a git directory tree.
|
43
56
|
Directories containing a file called .ignore are ignored.
|
44
|
-
|
57
|
+
|
58
|
+
The git-commitAll command commits all changes to each repository in the tree.
|
59
|
+
|
60
|
+
The git-evars command writes a script that defines environment variables pointing to git repos.
|
61
|
+
|
62
|
+
The git-exec command executes a bash expression on children of a directory, or a list of directories.
|
63
|
+
|
64
|
+
The git-replicate command writes a script that clones the repos in the tree,
|
45
65
|
and adds any defined remotes.
|
46
|
-
|
66
|
+
|
67
|
+
The git-update command updates each repository in the tree.
|
47
68
|
email:
|
48
69
|
- mslinn@mslinn.com
|
49
70
|
executables:
|
50
|
-
- git-
|
51
|
-
- git-
|
71
|
+
- git-commitAll
|
72
|
+
- git-evars
|
73
|
+
- git-exec
|
74
|
+
- git-replicate
|
75
|
+
- git-update
|
52
76
|
extensions: []
|
53
77
|
extra_rdoc_files: []
|
54
78
|
files:
|
@@ -57,14 +81,28 @@ files:
|
|
57
81
|
- LICENSE.txt
|
58
82
|
- README.md
|
59
83
|
- Rakefile
|
60
|
-
-
|
61
|
-
-
|
84
|
+
- exe/git-commitAll
|
85
|
+
- exe/git-evars
|
86
|
+
- exe/git-exec
|
87
|
+
- exe/git-replicate
|
88
|
+
- exe/git-update
|
62
89
|
- git_tree.gemspec
|
90
|
+
- lib/commands/abstract_command.rb
|
91
|
+
- lib/commands/git_commit_all.rb
|
92
|
+
- lib/commands/git_evars.rb
|
93
|
+
- lib/commands/git_exec.rb
|
94
|
+
- lib/commands/git_exec_spec.rb
|
95
|
+
- lib/commands/git_replicate.rb
|
96
|
+
- lib/commands/git_update.rb
|
63
97
|
- lib/git_tree.rb
|
64
98
|
- lib/git_tree/version.rb
|
65
|
-
- lib/
|
66
|
-
- lib/
|
67
|
-
- lib/util.rb
|
99
|
+
- lib/util/command_runner.rb
|
100
|
+
- lib/util/gem_support.rb
|
101
|
+
- lib/util/git_tree_walker.rb
|
102
|
+
- lib/util/git_tree_walker_private.rb
|
103
|
+
- lib/util/log.rb
|
104
|
+
- lib/util/thread_pool_manager.rb
|
105
|
+
- lib/util/zowee_optimizer.rb
|
68
106
|
homepage: https://www.mslinn.com/git/1100-git-tree.html
|
69
107
|
licenses:
|
70
108
|
- MIT
|
@@ -85,17 +123,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
123
|
requirements:
|
86
124
|
- - ">="
|
87
125
|
- !ruby/object:Gem::Version
|
88
|
-
version: 2.
|
126
|
+
version: 3.2.0
|
89
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
128
|
requirements:
|
91
129
|
- - ">="
|
92
130
|
- !ruby/object:Gem::Version
|
93
131
|
version: '0'
|
94
132
|
requirements: []
|
95
|
-
rubygems_version: 3.
|
96
|
-
signing_key:
|
133
|
+
rubygems_version: 3.6.9
|
97
134
|
specification_version: 4
|
98
|
-
summary: Installs
|
99
|
-
for replication.
|
135
|
+
summary: Installs five commands that walk a git directory tree and perform tasks.
|
100
136
|
test_files: []
|
101
137
|
...
|
data/bindir/git-tree-evars
DELETED
data/bindir/git-tree-replicate
DELETED
data/lib/git_tree_evars.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
require_relative 'git_tree'
|
2
|
-
|
3
|
-
module GitTree
|
4
|
-
using Rainbow
|
5
|
-
|
6
|
-
# @param root might be "$envar" or a fully qualified directory name ("/a/b/c")
|
7
|
-
def self.command_evars(root = ARGV[0])
|
8
|
-
help_evars "Environment variable reference was missing. Please enclose it within single quotes." if root.to_s.empty?
|
9
|
-
help_evars "Environment variable reference must start with a dollar sign ($)." unless root.start_with? '$'
|
10
|
-
|
11
|
-
base = MslinnUtil.expand_env root
|
12
|
-
help_evars "Environment variable '#{root}' is undefined." if base.strip.empty?
|
13
|
-
help_evars "Environment variable '#{root}' points to a non-existant directory (#{base})." unless File.exist?(base)
|
14
|
-
help_evars "Environment variable '#{root}' points to a file (#{base}), not a directory." unless Dir.exist?(base)
|
15
|
-
|
16
|
-
dirs = directories_to_process base
|
17
|
-
puts make_env_vars(root, base, dirs)
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.env_var_name(path)
|
21
|
-
name = path.include?('/') ? File.basename(path) : path
|
22
|
-
name.tr(' ', '_').tr('-', '_')
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.help_evars(msg = nil)
|
26
|
-
prog_name = File.basename $PROGRAM_NAME
|
27
|
-
puts "Error: #{msg}\n".red if msg
|
28
|
-
puts <<~END_HELP
|
29
|
-
#{prog_name} - Examines a tree of git repositories and writes a bash script to STDOUT
|
30
|
-
that defines environment variables which point to the repositories in the tree.
|
31
|
-
|
32
|
-
Does not redefine existing environment variables; messages are written to
|
33
|
-
STDERR to indicate environment variables that are not redefined.
|
34
|
-
|
35
|
-
The environment variable must have been exported, for example:
|
36
|
-
|
37
|
-
$ export work=$HOME/work
|
38
|
-
|
39
|
-
Directories containing a file called .ignore are ignored.
|
40
|
-
|
41
|
-
Usage example:
|
42
|
-
|
43
|
-
$ #{prog_name} '$work'
|
44
|
-
|
45
|
-
The name of the environment variable must be preceded by a dollar sign and enclosed within single quotes.
|
46
|
-
END_HELP
|
47
|
-
exit 1
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.make_env_var(name, value)
|
51
|
-
"export #{env_var_name(name)}=#{value}"
|
52
|
-
end
|
53
|
-
|
54
|
-
# @param root should be an "$envar" that points to the root of a directory tree containing git repos.
|
55
|
-
# @param base a fully qualified directory name ("/a/b/c")
|
56
|
-
# @param dirs directory list to process
|
57
|
-
def self.make_env_vars(root, base, dirs)
|
58
|
-
help_evars "Error: Please specify the subdirectory to traverse." if root.to_s.empty?
|
59
|
-
|
60
|
-
result = []
|
61
|
-
result << make_env_var(env_var_name(base), MslinnUtil.deref_symlink(base))
|
62
|
-
dirs.each do |dir|
|
63
|
-
ename = env_var_name dir
|
64
|
-
ename_value = MslinnUtil.expand_env "$#{ename}"
|
65
|
-
ename_value = ename_value.gsub(' ', '\\ ').delete_prefix('\\') unless ename_value.empty?
|
66
|
-
if ename_value.to_s.strip.empty?
|
67
|
-
result << make_env_var(ename, "#{root}/#{dir}")
|
68
|
-
else
|
69
|
-
msg = "$#{ename} was previously defined as #{ename_value}"
|
70
|
-
dir2 = MslinnUtil.expand_env(ename_value)
|
71
|
-
if Dir.exist? dir2
|
72
|
-
warn msg.cyan
|
73
|
-
else
|
74
|
-
msg += ", but that directory does not exist,\n so redefining #{ename} as #{dir}."
|
75
|
-
warn msg.green
|
76
|
-
result << make_env_var(ename, "#{root}/#{dir}")
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
result.map { |x| "#{x}\n" }.join + "\n"
|
81
|
-
end
|
82
|
-
end
|
data/lib/git_tree_replicate.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
require_relative 'git_tree'
|
2
|
-
|
3
|
-
module GitTree
|
4
|
-
using Rainbow
|
5
|
-
|
6
|
-
# @param root might be "$envar" or a fully qualified directory name ("/a/b/c")
|
7
|
-
def self.command_replicate(root = ARGV[0])
|
8
|
-
help_replicate "Environment variable reference was missing. Please enclose it within single quotes." if root.to_s.empty?
|
9
|
-
help_replicate "Error: Environment variable reference must start with a dollar sign ($)" unless root.start_with? '$'
|
10
|
-
|
11
|
-
base = MslinnUtil.expand_env root
|
12
|
-
help_replicate "Environment variable '#{root}' is undefined." if base.strip.empty?
|
13
|
-
help_replicate "Environment variable '#{root}' points to a non-existant directory (#{base})." unless File.exist?(base)
|
14
|
-
help_replicate "Environment variable '#{root}' points to a file (#{base}), not a directory." unless Dir.exist?(base)
|
15
|
-
|
16
|
-
dirs = directories_to_process base
|
17
|
-
puts make_replicate_script(root, base, dirs)
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.help_replicate(msg = nil)
|
21
|
-
prog_name = File.basename $PROGRAM_NAME
|
22
|
-
puts "Error: #{msg}\n".red if msg
|
23
|
-
puts <<~END_HELP
|
24
|
-
#{prog_name} - Replicates a tree of git repositories and writes a bash script
|
25
|
-
to STDOUT that clones the repositories in the tree. Replicates any remotes
|
26
|
-
defined in the source repositories to the target repositories.
|
27
|
-
|
28
|
-
The environment variable must have been exported, for example:
|
29
|
-
|
30
|
-
$ export work=$HOME/work
|
31
|
-
|
32
|
-
Directories containing a file called .ignore are ignored.
|
33
|
-
|
34
|
-
Usage example:
|
35
|
-
Assuming that 'work' is an environment variable that contains the name of a
|
36
|
-
directory that contains a tree of git repositories:
|
37
|
-
|
38
|
-
$ #{prog_name} '$work'
|
39
|
-
|
40
|
-
The name of the environment variable must be preceded by a dollar sign and enclosed within single quotes.
|
41
|
-
END_HELP
|
42
|
-
exit 1
|
43
|
-
end
|
44
|
-
|
45
|
-
# @param root should be an "$envar" that points to the root of a directory tree containing git repos.
|
46
|
-
# @param base a fully qualified directory name ("/a/b/c")
|
47
|
-
# @param dirs directory list to process
|
48
|
-
def self.make_replicate_script(root, base, dirs)
|
49
|
-
help_replicate "Error: Please specify the subdirectory to traverse.\n\n" if root.to_s.empty?
|
50
|
-
|
51
|
-
Dir.chdir(base) do
|
52
|
-
result = dirs.map { |dir| replicate_one(dir) }
|
53
|
-
result.join "\n"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.replicate_one(dir)
|
58
|
-
output = []
|
59
|
-
# project_dir = File.basename dir
|
60
|
-
parent_dir = File.dirname dir
|
61
|
-
repo = Rugged::Repository.new dir
|
62
|
-
origin_url = repo.config['remote.origin.url']
|
63
|
-
|
64
|
-
output << "if [ ! -d \"#{dir}/.git\" ]; then"
|
65
|
-
output << " mkdir -p '#{parent_dir}'"
|
66
|
-
output << " pushd '#{parent_dir}' > /dev/null"
|
67
|
-
output << " git clone #{origin_url}"
|
68
|
-
|
69
|
-
repo.remotes.each do |remote|
|
70
|
-
next if remote.name == 'origin' || remote.url == 'no_push'
|
71
|
-
|
72
|
-
output << " git remote add #{remote.name} '#{remote.url}'"
|
73
|
-
end
|
74
|
-
|
75
|
-
output << ' popd > /dev/null'
|
76
|
-
|
77
|
-
# git_dir_name = File.basename Dir.pwd
|
78
|
-
# if git_dir_name != project_dir
|
79
|
-
# output << ' # Git project directory was renamed, renaming this copy to match original directory structure'
|
80
|
-
# output << " mv #{git_dir_name} #{project_dir}"
|
81
|
-
# end
|
82
|
-
output << 'fi'
|
83
|
-
output << ''
|
84
|
-
output
|
85
|
-
end
|
86
|
-
end
|