master_to_main 0.0.4 → 0.0.5
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/CHANGELOG.md +6 -0
- data/Gemfile.lock +5 -2
- data/README.md +3 -3
- data/lib/master_to_main/cli.rb +34 -7
- data/lib/master_to_main/repo.rb +6 -2
- data/lib/master_to_main/version.rb +1 -1
- data/master_to_main.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ceb01120a7bf45cda06d052fad7981953dff2e229591b233e5194bd009691fe5
|
4
|
+
data.tar.gz: d3596aada72baf60721a28784837ac82b6de77f4b24c936448336aea30654477
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 859e90c468edf7217a9d573d870a3859013e65a7c3a9f2ab1462df42b366c099b6795a16a468406fbd680920bbaa4a91c2e75db0cad31235c7755f008edbc7ad
|
7
|
+
data.tar.gz: 18bc616948989e6a3a185ed7f410b11ad21a105c2746bf184f7685e59ca8a0185020ac5e08e134e81e1e549a6524652b76c4b7384858cab604acefeff0e801fb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 0.0.5 - 2020-06-19
|
2
|
+
|
3
|
+
- Add `find_references` for finding non doc references
|
4
|
+
- Provide better explanation that you are updating docs only
|
5
|
+
- Rescue from branch protection errors like in personal private repos
|
6
|
+
|
1
7
|
# 0.0.4 - 2020-06-18
|
2
8
|
|
3
9
|
- Change `github` to `update`
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
master_to_main (0.
|
4
|
+
master_to_main (0.0.5)
|
5
5
|
octokit (~> 4.0)
|
6
6
|
thor (~> 1.0.1)
|
7
7
|
|
@@ -41,7 +41,10 @@ PLATFORMS
|
|
41
41
|
ruby
|
42
42
|
|
43
43
|
DEPENDENCIES
|
44
|
-
bundler (~>
|
44
|
+
bundler (~> 2.0)
|
45
45
|
master_to_main!
|
46
46
|
rake (~> 13.0)
|
47
47
|
rspec (~> 3.0)
|
48
|
+
|
49
|
+
BUNDLED WITH
|
50
|
+
2.1.4
|
data/README.md
CHANGED
@@ -6,9 +6,9 @@ enterprise to a new branch. For example, if you wanted to change `master` to
|
|
6
6
|
|
7
7
|
While `master` does have meanings that connote expertise or original record, it also
|
8
8
|
has meanings that have much more oppressive and violent histories. Whether or not the
|
9
|
-
original meaning of `master` branch was in reference to original record or
|
10
|
-
matters less than what it may mean to a reader who doesn't want to bother with
|
11
|
-
history of git.
|
9
|
+
original meaning of `master` branch was in reference to original record or the opposite
|
10
|
+
of slave matters less than what it may mean to a reader who doesn't want to bother with
|
11
|
+
the history of git.
|
12
12
|
|
13
13
|
Per the twitter thread below, maybe we can just think of it as:
|
14
14
|
|
data/lib/master_to_main/cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "thor"
|
2
|
+
require "pry"
|
2
3
|
require "octokit"
|
3
4
|
|
4
5
|
module MasterToMain
|
@@ -22,12 +23,19 @@ module MasterToMain
|
|
22
23
|
change_origin
|
23
24
|
delete_local_old_branch
|
24
25
|
ask_update_docs
|
26
|
+
ask_find_references
|
25
27
|
end
|
26
28
|
|
27
|
-
desc "update_docs", "update local docs to use
|
29
|
+
desc "update_docs", "update local docs to use MAIN"
|
28
30
|
def update_docs
|
29
31
|
prompt_info
|
30
|
-
|
32
|
+
_update_docs
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "find_references", "find references to github urls with MAIN"
|
36
|
+
def find_references
|
37
|
+
prompt_info
|
38
|
+
_find_references
|
31
39
|
end
|
32
40
|
|
33
41
|
desc "update_local", "point local clone to new branch"
|
@@ -124,7 +132,12 @@ module MasterToMain
|
|
124
132
|
end
|
125
133
|
|
126
134
|
def clone_branch_protections
|
127
|
-
|
135
|
+
begin
|
136
|
+
repo = @client.repo(@repo.name)
|
137
|
+
options = @client.branch_protection(@repo.name, @repo.old_branch)
|
138
|
+
rescue Octokit::Forbidden
|
139
|
+
return
|
140
|
+
end
|
128
141
|
|
129
142
|
if options && yes?("Would you like to clone branch protections from '#{@repo.old_branch}'?")
|
130
143
|
updates = BranchProtectionParams.build(options.to_h)
|
@@ -169,18 +182,32 @@ module MasterToMain
|
|
169
182
|
end
|
170
183
|
|
171
184
|
def ask_update_docs
|
172
|
-
|
173
|
-
|
185
|
+
say("We can update #{@repo.github} references in '.md' files that include master in your repo")
|
186
|
+
say("For example: https://#{@repo.github}/#{@repo.name}/(tree|blob)/master")
|
187
|
+
if yes?("Would you like to update these references?")
|
188
|
+
_update_docs
|
189
|
+
say("You should consider searching for other references not in markdown files.")
|
190
|
+
say("We don't want to automatically change those in case something breaks.")
|
191
|
+
say("But you can use `master_to_main find_references` to show you where they are")
|
174
192
|
end
|
175
193
|
end
|
176
194
|
|
177
|
-
def
|
195
|
+
def ask_find_references
|
196
|
+
_find_references if yes?("Would you like to display other URL references?")
|
197
|
+
end
|
198
|
+
|
199
|
+
def _update_docs
|
178
200
|
say "This will update all references of #{@repo.old_branch} to #{@repo.new_branch} in the following lines in this repo:"
|
179
201
|
say "https://#{@repo.github}/#{@repo.name}/<tree|blob>/#{@repo.old_branch}"
|
180
202
|
Dir.glob(File.expand_path("**/*.md", Dir.pwd)).each do |path|
|
181
|
-
gsub_file path, @repo.old_branch_regex
|
203
|
+
gsub_file path, /#{@repo.old_branch_regex}/, @repo.new_branch_replacement, verbose: false
|
182
204
|
end
|
183
205
|
end
|
206
|
+
|
207
|
+
def _find_references
|
208
|
+
say "Here are the references to urls with #{@repo.old_branch}:\n\n"
|
209
|
+
puts `git grep -E '#{@repo.old_branch_regex}'`
|
210
|
+
end
|
184
211
|
end
|
185
212
|
end
|
186
213
|
end
|
data/lib/master_to_main/repo.rb
CHANGED
@@ -19,15 +19,19 @@ module MasterToMain
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def old_branch_regex
|
22
|
-
|
22
|
+
"(http[s]?:\/\/#{github}\/#{user}\/#{repo_name}\)/(tree|blob)\/#{old_branch}"
|
23
23
|
end
|
24
24
|
|
25
25
|
def new_branch_replacement
|
26
|
-
"
|
26
|
+
"\\1/\\2/#{new_branch}"
|
27
27
|
end
|
28
28
|
|
29
29
|
def new_branch_url
|
30
30
|
"https://#{github}/#{name}/tree/#{new_branch}"
|
31
31
|
end
|
32
|
+
|
33
|
+
def public_github?
|
34
|
+
@github == "github.com"
|
35
|
+
end
|
32
36
|
end
|
33
37
|
end
|
data/master_to_main.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
36
|
spec.require_paths = ["lib"]
|
37
37
|
|
38
|
-
spec.add_development_dependency "bundler", "~>
|
38
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
39
39
|
spec.add_development_dependency "rake", "~> 13.0"
|
40
40
|
spec.add_development_dependency "rspec", "~> 3.0"
|
41
41
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: master_to_main
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John DeWyze
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
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: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|