master_to_main 0.0.3 → 0.0.4
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 +5 -0
- data/README.md +30 -8
- data/lib/master_to_main/cli.rb +26 -3
- data/lib/master_to_main/repo.rb +7 -3
- data/lib/master_to_main/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56d7234fe688a9cb73ee0f4bf9de42557a08cd624fb55ebcc58d7d7dce01ad39
|
4
|
+
data.tar.gz: bb95dc6da0715587d1e4b261264af6622ecdf033d4d2060575367c4d43703422
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3249fc202c04c40b2cc42bca971c7361af721888274422da55a79f9bef4d2732573609cea26c7e102a138464320c18fd8f806324585801bc7f503f2e533c219a
|
7
|
+
data.tar.gz: 44b8bb73c65c95b8e3d6bcf51e869f08a9d9596721753d64ef0f2e56b5b88eaa0f4a9dd8f2731c25b32c786dd119e8ec4dd0c1980f44b015468671f5039d0762
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,29 +4,40 @@
|
|
4
4
|
enterprise to a new branch. For example, if you wanted to change `master` to
|
5
5
|
`main`.
|
6
6
|
|
7
|
+
While `master` does have meanings that connote expertise or original record, it also
|
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.
|
12
|
+
|
13
|
+
Per the twitter thread below, maybe we can just think of it as:
|
14
|
+
|
15
|
+
> Agreed. All it does is make the world a tiny bit more welcoming.
|
16
|
+
|
7
17
|
Thanks to [@shanselman](https://github.com/shanselman) for [the
|
8
18
|
suggestion](https://twitter.com/shanselman/status/1269838158650195968).
|
9
19
|
|
10
20
|
## Functionality
|
11
21
|
|
12
|
-
`MasterToMain` has
|
22
|
+
`MasterToMain` has 1 actions for now:
|
13
23
|
|
14
|
-
1. `
|
15
|
-
|
24
|
+
1. `update`
|
25
|
+
1. `update_local`
|
26
|
+
1. `update_docs`
|
16
27
|
|
17
|
-
##
|
28
|
+
## `update`
|
18
29
|
|
19
30
|
### Usage
|
20
31
|
|
21
32
|
```
|
22
|
-
master_to_main
|
33
|
+
master_to_main update
|
23
34
|
```
|
24
35
|
|
25
36
|
After filling out the relevant prompts you will be able to:
|
26
37
|
|
27
38
|
1. Create a new branch (e.g. `main`) if it does not exist.
|
28
39
|
1. Clone all branch protections from an old branch.
|
29
|
-
|
40
|
+
- Caveat: This does not include the signed commit requirement
|
30
41
|
1. Change the default branch of your repository
|
31
42
|
1. Rebase all pull requests based on your old branch to your new branch
|
32
43
|
1. Change the local `origin` remote value in github.
|
@@ -40,8 +51,9 @@ on Fetch URL of `origin` or "github.com")
|
|
40
51
|
or `pwd`)
|
41
52
|
1. The current default branch (default is `master`)
|
42
53
|
1. The desired default branch (default is `main`)
|
54
|
+
1. Your personal access token (instructions for settings one can be found [here](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line))
|
43
55
|
|
44
|
-
##
|
56
|
+
## `update_local`
|
45
57
|
|
46
58
|
### Usage
|
47
59
|
|
@@ -63,6 +75,16 @@ $ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
|
|
63
75
|
All credit for this goes to "Brad from XUnit.net!" per [Scott's
|
64
76
|
Blog](https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx).
|
65
77
|
|
78
|
+
## `update_docs`
|
79
|
+
|
80
|
+
### Usage
|
81
|
+
|
82
|
+
```
|
83
|
+
master_to_main update_docs
|
84
|
+
```
|
85
|
+
|
86
|
+
This will attempt to update all references to commits on the master branch with
|
87
|
+
commits on the main branch.
|
66
88
|
|
67
89
|
## Installation
|
68
90
|
|
@@ -86,7 +108,7 @@ Or install it yourself as:
|
|
86
108
|
|
87
109
|
## Contributing
|
88
110
|
|
89
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
111
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dewyze/master_to_main. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
90
112
|
|
91
113
|
## Code of Conduct
|
92
114
|
|
data/lib/master_to_main/cli.rb
CHANGED
@@ -3,13 +3,14 @@ require "octokit"
|
|
3
3
|
|
4
4
|
module MasterToMain
|
5
5
|
class CLI < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
6
8
|
def self.exit_on_failure?
|
7
9
|
true
|
8
10
|
end
|
9
11
|
|
10
|
-
desc "
|
11
|
-
def
|
12
|
-
|
12
|
+
desc "update", "rebase PRs to the main branch"
|
13
|
+
def update
|
13
14
|
prompt_info
|
14
15
|
create_client
|
15
16
|
|
@@ -20,6 +21,13 @@ module MasterToMain
|
|
20
21
|
rebase_pull_requests
|
21
22
|
change_origin
|
22
23
|
delete_local_old_branch
|
24
|
+
ask_update_docs
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "update_docs", "update local docs to use master"
|
28
|
+
def update_docs
|
29
|
+
prompt_info
|
30
|
+
gsub_docs
|
23
31
|
end
|
24
32
|
|
25
33
|
desc "update_local", "point local clone to new branch"
|
@@ -32,6 +40,7 @@ module MasterToMain
|
|
32
40
|
`git branch --unset-upstream`
|
33
41
|
`git branch -u origin/#{@repo.new_branch}`
|
34
42
|
`git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/#{@repo.new_branch}`
|
43
|
+
`git pull`
|
35
44
|
end
|
36
45
|
|
37
46
|
no_commands do
|
@@ -158,6 +167,20 @@ module MasterToMain
|
|
158
167
|
say "In order to ensure no builds or deployments break, please delete your remote #{@repo.old_branch} on github", :green
|
159
168
|
say "----------------"
|
160
169
|
end
|
170
|
+
|
171
|
+
def ask_update_docs
|
172
|
+
if yes?("Would you like to update commit and branch references in your repo?")
|
173
|
+
gsub_docs
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def gsub_docs
|
178
|
+
say "This will update all references of #{@repo.old_branch} to #{@repo.new_branch} in the following lines in this repo:"
|
179
|
+
say "https://#{@repo.github}/#{@repo.name}/<tree|blob>/#{@repo.old_branch}"
|
180
|
+
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
|
182
|
+
end
|
183
|
+
end
|
161
184
|
end
|
162
185
|
end
|
163
186
|
end
|
data/lib/master_to_main/repo.rb
CHANGED
@@ -18,12 +18,16 @@ module MasterToMain
|
|
18
18
|
"#{user}/#{repo_name}"
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
21
|
+
def old_branch_regex
|
22
|
+
/https:\/\/#{github}\/#{user}\/#{repo_name}\/(tree|blob)\/#{old_branch}/
|
23
|
+
end
|
24
|
+
|
25
|
+
def new_branch_replacement
|
26
|
+
"https://#{github}/#{user}/#{repo_name}/\\1/#{new_branch}"
|
23
27
|
end
|
24
28
|
|
25
29
|
def new_branch_url
|
26
|
-
"https://#{github}/tree/#{new_branch}"
|
30
|
+
"https://#{github}/#{name}/tree/#{new_branch}"
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John DeWyze
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|