changit 0.2.2 → 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/README.md +7 -0
- data/bin/changit +2 -1
- data/lib/changit/cli.rb +42 -0
- data/lib/changit/config_reader.rb +2 -1
- data/lib/changit/git_dir_finder.rb +4 -3
- data/lib/changit/version.rb +1 -1
- data/lib/changit.rb +4 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076d3ca051c1b061e2e66ed520eb75a205b76a61
|
4
|
+
data.tar.gz: 87ccbdfcacf49c8c95774a46879444673395f3f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a970bd68cba72a8d36261f86148aa1519daf53f5753380e74758b8d3c8f657e108dca0169a2bf94dd5bbede8d518c1b7339c18a6cd50fa162a05202f0ae53a88
|
7
|
+
data.tar.gz: 6942d0f4a470de75778a5dfda520ab5a20b6d9198a85fcb8218375c33e621ab080332d7f5db63a4173b32dabfc348caded4b924d8d3455889293f72f5954e93d
|
data/README.md
CHANGED
data/bin/changit
CHANGED
data/lib/changit/cli.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Changit
|
4
|
+
class CLI
|
5
|
+
def initialize
|
6
|
+
options = {}
|
7
|
+
options[:target_paths] = []
|
8
|
+
|
9
|
+
opt_parser = OptionParser.new do |opt|
|
10
|
+
opt.banner = "Usage: changit [OPTIONS]"
|
11
|
+
opt.separator ""
|
12
|
+
opt.separator "Options"
|
13
|
+
|
14
|
+
opt.on("-s","--source SOURCE","Which gitconfig file to copy from") do |src_path|
|
15
|
+
options[:src_path] = src_path
|
16
|
+
end
|
17
|
+
|
18
|
+
opt.on("-t","--target TARGET","Which directory to copy the config to."\
|
19
|
+
" To copy to different directories, pass more than one -t argument each for one directory"
|
20
|
+
) do |target_path|
|
21
|
+
options[:target_paths] << target_path
|
22
|
+
end
|
23
|
+
|
24
|
+
opt.on("-v","--version","Show version number") do
|
25
|
+
puts Changit::VERSION
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
opt.on("-h","--help","Show CLI options") do
|
30
|
+
puts opt_parser
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
opt_parser.parse!
|
36
|
+
|
37
|
+
options[:target_paths] = nil if options[:target_paths].empty?
|
38
|
+
options
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -2,14 +2,15 @@ module Changit
|
|
2
2
|
class GitDirFinder
|
3
3
|
DEFAULT_SEARCH_PATH = Dir.pwd.freeze
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
|
5
|
+
def initialize(search_paths: nil)
|
6
|
+
search_paths ||= [DEFAULT_SEARCH_PATH]
|
7
|
+
@search_paths = search_paths.collect! { |path| "#{path}/**/.git/config" }
|
7
8
|
|
8
9
|
freeze
|
9
10
|
end
|
10
11
|
|
11
12
|
def find_all
|
12
|
-
Dir.glob(@
|
13
|
+
Dir.glob(@search_paths)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
data/lib/changit/version.rb
CHANGED
data/lib/changit.rb
CHANGED
@@ -6,14 +6,15 @@ require 'changit/git_dir_finder'
|
|
6
6
|
require 'changit/config_merger'
|
7
7
|
require 'changit/config_reader'
|
8
8
|
require 'changit/config_writer'
|
9
|
+
require 'changit/cli'
|
9
10
|
|
10
11
|
module Changit
|
11
|
-
def self.run
|
12
|
+
def self.run(src_file, target_files)
|
12
13
|
# File to copy from
|
13
|
-
config = ConfigReader.new.read
|
14
|
+
config = ConfigReader.new(search_path: src_file).read
|
14
15
|
|
15
16
|
# First, search directories inside the current pwd and make sure they contain a .git dir
|
16
|
-
files_to_write_to = GitDirFinder.new.find_all
|
17
|
+
files_to_write_to = GitDirFinder.new(search_paths: target_files).find_all
|
17
18
|
|
18
19
|
# Then, copy the gitconfig file content to each .git/config file in these directories
|
19
20
|
ConfigWriter.new(config, files_to_write_to).write
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: changit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aaooki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An over-engineered tool to change git config for multiple projects at
|
14
14
|
once.
|
@@ -27,6 +27,7 @@ files:
|
|
27
27
|
- changit.gemspec
|
28
28
|
- demo.gif
|
29
29
|
- lib/changit.rb
|
30
|
+
- lib/changit/cli.rb
|
30
31
|
- lib/changit/config_merger.rb
|
31
32
|
- lib/changit/config_reader.rb
|
32
33
|
- lib/changit/config_writer.rb
|