git-gsub 0.0.6 → 0.0.7
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 +5 -5
- data/lib/git/gsub.rb +6 -3
- data/lib/git/gsub/version.rb +1 -1
- data/spec/git_gsub_spec.rb +26 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fe7b943789da1bf44d4009c787ea6e8c330c8face2076f9fea1e69260185371c
|
4
|
+
data.tar.gz: f44ce00c4b6c6f5b67820a843e4a8f682b3ed95e2dfc0ca3f59eae366594c506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 403c39886db868e4a86d251c2a33c6f8b3333071f251ab9b3ce14ffc452c6e70110c971faab855756ceb3940dd7c4029cceb7fe608302495208fc61fc09d5ddc
|
7
|
+
data.tar.gz: 92771c117e89261cf91a88c78608b4f796909b2c0e530585fc80444e39cbb7bbc0553f003b1d57d7a98e32f629bbe9d2db0157d4fd6eb0a5943dabedd51dd36b
|
data/lib/git/gsub.rb
CHANGED
@@ -3,6 +3,7 @@ require 'active_support/inflector'
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'shellwords'
|
5
5
|
require 'English'
|
6
|
+
require "open3"
|
6
7
|
|
7
8
|
module Git
|
8
9
|
module Gsub
|
@@ -78,9 +79,9 @@ module Git
|
|
78
79
|
|
79
80
|
def run_commands(commands)
|
80
81
|
if options[:dry]
|
81
|
-
commands.each { |
|
82
|
+
commands.each { |args| puts args.join(' ') }
|
82
83
|
else
|
83
|
-
commands.each { |
|
84
|
+
commands.each { |args| Open3.capture3(*args) }
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
@@ -103,11 +104,13 @@ module Git
|
|
103
104
|
|
104
105
|
def build_command(from, to, paths = [], _options = {})
|
105
106
|
from, to, *paths = [from, to, *paths].map { |s| Shellwords.escape s }
|
107
|
+
[from, to].each { |s| s.gsub! '@', '\@' }
|
106
108
|
|
107
109
|
target_files = `git grep -l #{from} #{paths.join ' '}`.each_line.map(&:chomp).join ' '
|
108
110
|
return if target_files.empty?
|
109
111
|
|
110
|
-
|
112
|
+
|
113
|
+
['perl', '-pi', '-e', "s{#{from}}{#{to}}g", *target_files]
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
data/lib/git/gsub/version.rb
CHANGED
data/spec/git_gsub_spec.rb
CHANGED
@@ -3,6 +3,11 @@ require 'tmpdir'
|
|
3
3
|
require 'git/gsub'
|
4
4
|
require 'pry'
|
5
5
|
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.filter_run :focus => true
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
end
|
10
|
+
|
6
11
|
describe 'git-gsub' do
|
7
12
|
def run_in_directory_with_a_file(filename, content)
|
8
13
|
Dir.mktmpdir do |dir|
|
@@ -39,18 +44,36 @@ describe 'git-gsub' do
|
|
39
44
|
Git::Gsub.run [%(<h1 class="foo">), %(<h1 class="bar">)]
|
40
45
|
expect(File.read('README.md')).to eq %(<h1 class="bar">)
|
41
46
|
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it do
|
50
|
+
run_in_directory_with_a_file 'README.md', %(Hello this is @git) do
|
51
|
+
Git::Gsub.run [%(@git), %(@@svn)]
|
52
|
+
expect(File.read('README.md')).to eq %(Hello this is @@svn)
|
53
|
+
end
|
54
|
+
end
|
42
55
|
|
43
|
-
|
44
|
-
|
45
|
-
|
56
|
+
it do
|
57
|
+
run_in_directory_with_a_file 'README.md', %(Hello this is "git") do
|
58
|
+
Git::Gsub.run [%("git"), %('svn')]
|
59
|
+
expect(File.read('README.md')).to eq %(Hello this is 'svn')
|
46
60
|
end
|
61
|
+
end
|
47
62
|
|
63
|
+
it do
|
48
64
|
run_in_directory_with_a_file 'README.md', %({git{svn}) do
|
49
65
|
Git::Gsub.run [%({git{svn}), %({hg{svn})]
|
50
66
|
expect(File.read('README.md')).to eq %({hg{svn})
|
51
67
|
end
|
52
68
|
end
|
53
69
|
|
70
|
+
it do
|
71
|
+
run_in_directory_with_a_file 'README.md', %(foo@example.com) do
|
72
|
+
Git::Gsub.run [%(@example), %(bar@example)]
|
73
|
+
expect(File.read('README.md')).to eq %(foobar@example.com)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
54
77
|
it 'should not create backup file' do
|
55
78
|
run_in_directory_with_a_file 'README.md', 'Git Subversion Bzr' do
|
56
79
|
Git::Gsub.run %w[Bzr Darcs]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-gsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fujimura Daisuke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.6
|
123
|
+
rubygems_version: 2.7.6
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: A Git subcommand to do gsub in a repository
|