master_to_main 0.0.1
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +47 -0
- data/LICENSE +21 -0
- data/README.md +93 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/master_to_main +5 -0
- data/lib/master_to_main.rb +5 -0
- data/lib/master_to_main/branch_protection_params.rb +64 -0
- data/lib/master_to_main/cli.rb +150 -0
- data/lib/master_to_main/repo.rb +29 -0
- data/lib/master_to_main/version.rb +3 -0
- data/master_to_main.gemspec +44 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 71e3451ce977f600d84510976915b39c28d18a68596b2a9118731fde10d9d4d9
|
4
|
+
data.tar.gz: 9b73f2ec8d863bf86fa4b763f07fddd662676a351f17c5d845767c61bca05a6c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34ef7eab028716de82af81e41154ea9e4a0cc963c720c84d9aae6e2118391357e411e6c796d12c8fbce514ada5d145f18575fe0f79c5b76c108a12e60c98453a
|
7
|
+
data.tar.gz: bffc48a13f395255bc403bb8c0270007bd997edd2afd2dede41668bf86387fe7166edd29021785789526b6ba43ff4ed7d5bba1c60fc9ea4b1493900bb3a95e78
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at john@dewyze.dev. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
master_to_main (0.1.0)
|
5
|
+
octokit (~> 4.0)
|
6
|
+
thor (~> 1.0.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
faraday (1.0.1)
|
15
|
+
multipart-post (>= 1.2, < 3)
|
16
|
+
multipart-post (2.1.1)
|
17
|
+
octokit (4.18.0)
|
18
|
+
faraday (>= 0.9)
|
19
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
20
|
+
public_suffix (4.0.5)
|
21
|
+
rake (10.5.0)
|
22
|
+
rspec (3.9.0)
|
23
|
+
rspec-core (~> 3.9.0)
|
24
|
+
rspec-expectations (~> 3.9.0)
|
25
|
+
rspec-mocks (~> 3.9.0)
|
26
|
+
rspec-core (3.9.2)
|
27
|
+
rspec-support (~> 3.9.3)
|
28
|
+
rspec-expectations (3.9.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-mocks (3.9.1)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.9.0)
|
34
|
+
rspec-support (3.9.3)
|
35
|
+
sawyer (0.8.2)
|
36
|
+
addressable (>= 2.3.5)
|
37
|
+
faraday (> 0.8, < 2.0)
|
38
|
+
thor (1.0.1)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
bundler (~> 1.17)
|
45
|
+
master_to_main!
|
46
|
+
rake (~> 10.0)
|
47
|
+
rspec (~> 3.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 John DeWyze
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# MasterToMain
|
2
|
+
|
3
|
+
`MasterToMain` lets you change an old default branch on github or github
|
4
|
+
enterprise to a new branch. For example, if you wanted to change `master` to
|
5
|
+
`main`.
|
6
|
+
|
7
|
+
Thanks to [@shanselman](https://github.com/shanselman) for [the
|
8
|
+
suggestion](https://twitter.com/shanselman/status/1269838158650195968).
|
9
|
+
|
10
|
+
## Functionality
|
11
|
+
|
12
|
+
`MasterToMain` has 2 actions for now:
|
13
|
+
|
14
|
+
1. `github`
|
15
|
+
2. `update_local`
|
16
|
+
|
17
|
+
## Github
|
18
|
+
|
19
|
+
### Usage
|
20
|
+
|
21
|
+
```
|
22
|
+
master_to_main github
|
23
|
+
```
|
24
|
+
|
25
|
+
After filling out the relevant prompts you will be able to:
|
26
|
+
|
27
|
+
1. Create a new branch (e.g. `main`) if it does not exist.
|
28
|
+
1. Clone all branch protections from an old branch.
|
29
|
+
- Caveat: This does not include the signed commit requirement
|
30
|
+
1. Change the default branch of your repository
|
31
|
+
1. Rebase all pull requests based on your old branch to your new branch
|
32
|
+
1. Change the local `origin` remote value in github.
|
33
|
+
|
34
|
+
You will be prompted for:
|
35
|
+
|
36
|
+
1. Your "github" (e.g. "github.com" or "github.mycompany.com", default is based
|
37
|
+
on Fetch URL of `origin` or "github.com")
|
38
|
+
1. Your user (default is based on Fetch URL of `origin` or `whoami`)
|
39
|
+
1. The repository you want to update (default is based on Fetch URL of `origin`
|
40
|
+
or `pwd`)
|
41
|
+
1. The current default branch (default is `master`)
|
42
|
+
1. The desired default branch (default is `main`)
|
43
|
+
|
44
|
+
## Update Local Clone
|
45
|
+
|
46
|
+
### Usage
|
47
|
+
|
48
|
+
```
|
49
|
+
master_to_main update_local
|
50
|
+
```
|
51
|
+
|
52
|
+
This will perform the following (assuming "master" and "main")
|
53
|
+
|
54
|
+
```
|
55
|
+
$ git checkout master
|
56
|
+
$ git branch -m master main
|
57
|
+
$ git fetch
|
58
|
+
$ git branch --unset-upstream
|
59
|
+
$ git branch -u origin/main
|
60
|
+
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
|
61
|
+
```
|
62
|
+
|
63
|
+
All credit for this goes to "Brad from XUnit.net!" per [Scott's
|
64
|
+
Blog](https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx).
|
65
|
+
|
66
|
+
|
67
|
+
## Installation
|
68
|
+
|
69
|
+
Add this line to your application's Gemfile:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
gem 'master_to_main'
|
73
|
+
```
|
74
|
+
|
75
|
+
And then execute:
|
76
|
+
|
77
|
+
$ bundle
|
78
|
+
|
79
|
+
Or install it yourself as:
|
80
|
+
|
81
|
+
$ gem install master_to_main
|
82
|
+
|
83
|
+
## TODO
|
84
|
+
|
85
|
+
- Testing would be nice
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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
|
+
|
91
|
+
## Code of Conduct
|
92
|
+
|
93
|
+
Everyone interacting in the MasterToMain project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/master_to_main/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "master_to_main"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/master_to_main
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
module MasterToMain
|
2
|
+
class BranchProtectionParams
|
3
|
+
def self.build(current)
|
4
|
+
params = {}
|
5
|
+
|
6
|
+
params[:required_status_checks] = build_required_status_checks(current)
|
7
|
+
params[:required_pull_request_reviews] = build_required_pull_request_reviews(current)
|
8
|
+
params[:restrictions] = build_restrictions(current)
|
9
|
+
params[:enforce_admins] = current.dig(:enforce_admins, :enabled)
|
10
|
+
params[:required_linear_history] = current.dig(:required_linear_history, :enabled)
|
11
|
+
params[:allow_force_pushes] = current.dig(:allow_force_pushes, :enabled)
|
12
|
+
params[:allow_deletions] = current.dig(:allow_deletions, :enabled)
|
13
|
+
|
14
|
+
params
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
private
|
19
|
+
|
20
|
+
def build_required_status_checks(current)
|
21
|
+
config = current[:required_status_checks]
|
22
|
+
return nil unless config
|
23
|
+
|
24
|
+
{
|
25
|
+
strict: config[:strict],
|
26
|
+
contexts: config[:contexts]
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_required_pull_request_reviews(current)
|
31
|
+
config = current[:required_pull_request_reviews]
|
32
|
+
return nil unless config
|
33
|
+
|
34
|
+
{
|
35
|
+
dismiss_stale_reviews: config[:dismiss_stale_reviews],
|
36
|
+
require_code_owner_reviews: config[:require_code_owner_reviews],
|
37
|
+
required_approving_review_count: config[:required_approving_review_count],
|
38
|
+
dismissal_restrictions: build_dismissal_restrictions(config),
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_dismissal_restrictions(current)
|
43
|
+
config = current[:dismissal_restrictions]
|
44
|
+
return nil unless config
|
45
|
+
|
46
|
+
{
|
47
|
+
users: config[:users].map {|user| user[:login]},
|
48
|
+
teams: config[:teams].map {|team| team[:slug]},
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_restrictions(current)
|
53
|
+
config = current[:restrictions]
|
54
|
+
return nil unless config
|
55
|
+
|
56
|
+
{
|
57
|
+
users: config[:users].map {|user| user[:login]},
|
58
|
+
teams: config[:teams].map {|team| team[:slug]},
|
59
|
+
apps: config[:apps].map {|app| app[:slug]},
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "octokit"
|
3
|
+
|
4
|
+
module MasterToMain
|
5
|
+
class CLI < Thor
|
6
|
+
def self.exit_on_failure?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "github", "rebase PRs to the main branch"
|
11
|
+
def github
|
12
|
+
|
13
|
+
prompt_info
|
14
|
+
|
15
|
+
create_client
|
16
|
+
ensure_old_branch_exists
|
17
|
+
ensure_new_branch_exists
|
18
|
+
clone_branch_protections
|
19
|
+
change_default_branch
|
20
|
+
rebase_pull_requests
|
21
|
+
change_origin
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "update_local", "point local clone to new branch"
|
25
|
+
def update_local
|
26
|
+
prompt_info
|
27
|
+
|
28
|
+
`git checkout #{@repo.old_branch}`
|
29
|
+
`git branch -m #{@repo.old_branch} #{@repo.new_branch}`
|
30
|
+
`git fetch`
|
31
|
+
`git branch --unset-upstream`
|
32
|
+
`git branch -u origin/#{@repo.new_branch}`
|
33
|
+
`git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/#{@repo.new_branch}`
|
34
|
+
end
|
35
|
+
|
36
|
+
no_commands do
|
37
|
+
def create_client
|
38
|
+
Octokit.configure do |c|
|
39
|
+
c.api_endpoint = @repo.api_endpoint
|
40
|
+
end
|
41
|
+
token = ask("What is your GitHub Personal Access Token?")
|
42
|
+
|
43
|
+
@client = Octokit::Client.new(access_token: token)
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def get_github_info
|
48
|
+
fetch_url = `git remote show origin | grep "Fetch URL"`
|
49
|
+
if fetch_url != ""
|
50
|
+
base = fetch_url.split("github.")[1]
|
51
|
+
github_suffix, user_repo = base.split(":")
|
52
|
+
user, repo = user_repo.split("/")
|
53
|
+
|
54
|
+
{
|
55
|
+
github: "github." + github_suffix,
|
56
|
+
user: user,
|
57
|
+
repo: repo.chomp,
|
58
|
+
}
|
59
|
+
else
|
60
|
+
{
|
61
|
+
github: "github.com",
|
62
|
+
user: `whoami`.chomp,
|
63
|
+
repo: `pwd`.split("/")[-1].chomp,
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def prompt_info
|
69
|
+
github_info = get_github_info
|
70
|
+
github_url = ask("What is your github url?", default: github_info[:github]).gsub(/https:\/\//, "")
|
71
|
+
user = ask("What is your github user?", default: github_info[:user])
|
72
|
+
github_repo = ask("What is your github repo?", default: github_info[:repo])
|
73
|
+
old_branch = ask("What is your current primary branch?", default: "master")
|
74
|
+
new_branch = ask("What is your desired primary branch?", default: "main")
|
75
|
+
|
76
|
+
@repo = MasterToMain::Repo.new(github_url, user, github_repo, old_branch, new_branch)
|
77
|
+
end
|
78
|
+
|
79
|
+
def ensure_old_branch_exists
|
80
|
+
@client.branch(@repo.name, @repo.old_branch)
|
81
|
+
rescue Octokit::NotFound
|
82
|
+
say "The current primary branch does not exist, or do you not have access. Was there a typo?", :red
|
83
|
+
say "-----------------------"
|
84
|
+
say "CURRENT PRIMARY BRANCH: #{@repo.old_branch}", :green
|
85
|
+
exit 1
|
86
|
+
end
|
87
|
+
|
88
|
+
def ensure_new_branch_exists
|
89
|
+
unless new_branch_exists?
|
90
|
+
if yes?("The #{@repo.new_branch} branch does not exist, would you like me to create it for you?")
|
91
|
+
create_new_branch
|
92
|
+
say "The #{@repo.new_branch} has been created. You can see it at: #{@repo.new_branch_url}", :green
|
93
|
+
else
|
94
|
+
say "Okay then, goodbye."
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def new_branch_exists?
|
101
|
+
@client.branch(@repo.name, @repo.new_branch)
|
102
|
+
rescue Octokit::NotFound
|
103
|
+
false
|
104
|
+
end
|
105
|
+
|
106
|
+
def old_branch_sha
|
107
|
+
old_branch = @client.branch(@repo.name, @repo.old_branch)[:commit][:sha]
|
108
|
+
end
|
109
|
+
|
110
|
+
def create_new_branch
|
111
|
+
@client.create_ref(@repo.name, "refs/heads/#{@repo.new_branch}", old_branch_sha)
|
112
|
+
end
|
113
|
+
|
114
|
+
def clone_branch_protections
|
115
|
+
options = @client.branch_protection(@repo.name, @repo.old_branch)
|
116
|
+
|
117
|
+
if options && yes?("Would you like to clone branch protections from '#{@repo.old_branch}'?")
|
118
|
+
updates = BranchProtectionParams.build(options.to_h)
|
119
|
+
@client.protect_branch(@repo.name, @repo.new_branch, updates)
|
120
|
+
say "NOTE: Cannot clone Signed Commit Requirement, please recreate if necessary", :green
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def rebase_pull_requests
|
125
|
+
if yes?("Would you like to rebase all requests based on #{@repo.old_branch} to #{@repo.new_branch}?")
|
126
|
+
prs = @client.pull_requests(@repo.name)
|
127
|
+
prs.each do |pr|
|
128
|
+
if pr[:base][:ref] == @repo.old_branch
|
129
|
+
@client.update_pull_request(@repo.name, pr.number, base: @repo.new_branch)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
else
|
133
|
+
say "Be sure to update pull requests to point to the new branch!"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def change_default_branch
|
138
|
+
@client.update_repository(@repo.name, default_branch: @repo.new_branch)
|
139
|
+
end
|
140
|
+
|
141
|
+
def change_origin
|
142
|
+
if yes?("Would you like to change origin to point to #{@repo.new_branch}?")
|
143
|
+
`git push -u origin master`
|
144
|
+
else
|
145
|
+
say "Be sure to change your local `origin` setting"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module MasterToMain
|
2
|
+
class Repo
|
3
|
+
attr_accessor :github, :user, :repo_name, :old_branch, :new_branch
|
4
|
+
|
5
|
+
def initialize(github, user, repo_name, old_branch, new_branch)
|
6
|
+
@github = github
|
7
|
+
@user = user
|
8
|
+
@repo_name = repo_name
|
9
|
+
@old_branch = old_branch
|
10
|
+
@new_branch = new_branch
|
11
|
+
end
|
12
|
+
|
13
|
+
def api_endpoint
|
14
|
+
"https://" + github + "/api/v3/"
|
15
|
+
end
|
16
|
+
|
17
|
+
def name
|
18
|
+
"#{user}/#{repo_name}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def old_branch_url
|
22
|
+
"https://#{github}/tree/#{old_branch}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def new_branch_url
|
26
|
+
"https://#{github}/tree/#{new_branch}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "master_to_main/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "master_to_main"
|
8
|
+
spec.version = MasterToMain::VERSION
|
9
|
+
spec.authors = ["John DeWyze"]
|
10
|
+
spec.email = ["john@dewyze.dev"]
|
11
|
+
|
12
|
+
spec.summary = %q{Change master to main}
|
13
|
+
spec.description = %q{Change master to main}
|
14
|
+
spec.homepage = "https://github.com/dewyze/master_to_main"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = "https://github.com/dewyze/master_to_main"
|
23
|
+
spec.metadata["changelog_uri"] = "https://github.com/dewyze/master_to_main/CHANGELOG.md"
|
24
|
+
else
|
25
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
"public gem pushes."
|
27
|
+
end
|
28
|
+
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = "exe"
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ["lib"]
|
37
|
+
|
38
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
39
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
40
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
41
|
+
|
42
|
+
spec.add_dependency "thor", "~> 1.0.1"
|
43
|
+
spec.add_dependency "octokit", "~> 4.0"
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: master_to_main
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John DeWyze
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: octokit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
83
|
+
description: Change master to main
|
84
|
+
email:
|
85
|
+
- john@dewyze.dev
|
86
|
+
executables:
|
87
|
+
- master_to_main
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- CHANGELOG.md
|
94
|
+
- CODE_OF_CONDUCT.md
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- bin/console
|
101
|
+
- bin/setup
|
102
|
+
- exe/master_to_main
|
103
|
+
- lib/master_to_main.rb
|
104
|
+
- lib/master_to_main/branch_protection_params.rb
|
105
|
+
- lib/master_to_main/cli.rb
|
106
|
+
- lib/master_to_main/repo.rb
|
107
|
+
- lib/master_to_main/version.rb
|
108
|
+
- master_to_main.gemspec
|
109
|
+
homepage: https://github.com/dewyze/master_to_main
|
110
|
+
licenses: []
|
111
|
+
metadata:
|
112
|
+
allowed_push_host: https://rubygems.org
|
113
|
+
homepage_uri: https://github.com/dewyze/master_to_main
|
114
|
+
source_code_uri: https://github.com/dewyze/master_to_main
|
115
|
+
changelog_uri: https://github.com/dewyze/master_to_main/CHANGELOG.md
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubygems_version: 3.1.2
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Change master to main
|
135
|
+
test_files: []
|