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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56d7234fe688a9cb73ee0f4bf9de42557a08cd624fb55ebcc58d7d7dce01ad39
4
- data.tar.gz: bb95dc6da0715587d1e4b261264af6622ecdf033d4d2060575367c4d43703422
3
+ metadata.gz: ceb01120a7bf45cda06d052fad7981953dff2e229591b233e5194bd009691fe5
4
+ data.tar.gz: d3596aada72baf60721a28784837ac82b6de77f4b24c936448336aea30654477
5
5
  SHA512:
6
- metadata.gz: 3249fc202c04c40b2cc42bca971c7361af721888274422da55a79f9bef4d2732573609cea26c7e102a138464320c18fd8f806324585801bc7f503f2e533c219a
7
- data.tar.gz: 44b8bb73c65c95b8e3d6bcf51e869f08a9d9596721753d64ef0f2e56b5b88eaa0f4a9dd8f2731c25b32c786dd119e8ec4dd0c1980f44b015468671f5039d0762
6
+ metadata.gz: 859e90c468edf7217a9d573d870a3859013e65a7c3a9f2ab1462df42b366c099b6795a16a468406fbd680920bbaa4a91c2e75db0cad31235c7755f008edbc7ad
7
+ data.tar.gz: 18bc616948989e6a3a185ed7f410b11ad21a105c2746bf184f7685e59ca8a0185020ac5e08e134e81e1e549a6524652b76c4b7384858cab604acefeff0e801fb
@@ -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`
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- master_to_main (0.1.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 (~> 1.17)
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 slave
10
- matters less than what it may mean to a reader who doesn't want to bother with the
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
 
@@ -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 master"
29
+ desc "update_docs", "update local docs to use MAIN"
28
30
  def update_docs
29
31
  prompt_info
30
- gsub_docs
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
- options = @client.branch_protection(@repo.name, @repo.old_branch)
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
- if yes?("Would you like to update commit and branch references in your repo?")
173
- gsub_docs
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 gsub_docs
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, @repo.new_branch_replacement, verbose: false
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
@@ -19,15 +19,19 @@ module MasterToMain
19
19
  end
20
20
 
21
21
  def old_branch_regex
22
- /https:\/\/#{github}\/#{user}\/#{repo_name}\/(tree|blob)\/#{old_branch}/
22
+ "(http[s]?:\/\/#{github}\/#{user}\/#{repo_name}\)/(tree|blob)\/#{old_branch}"
23
23
  end
24
24
 
25
25
  def new_branch_replacement
26
- "https://#{github}/#{user}/#{repo_name}/\\1/#{new_branch}"
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
@@ -1,3 +1,3 @@
1
1
  module MasterToMain
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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", "~> 1.17"
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
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: '1.17'
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: '1.17'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement