tworingtools 4.5.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bumpr +1 -1
- data/bin/changetag +1 -1
- data/bin/migrate-changelog +6 -3
- data/bin/prerelease-podspec +7 -3
- data/bin/release-podspec +8 -4
- data/bin/sync-git-remotes +67 -0
- data/lib/git_helpers.rb +77 -0
- metadata +8 -7
- data/bin/sync-forks +0 -90
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e106dbdd5ffeac3ac9461297fb97b4657447a2fa1dffd251018f0a167face95
|
4
|
+
data.tar.gz: b2f66ebcb62c823c22bafed9f3f443dcd9c0caeea2f2234b2d31de81453e5add
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a64f4e1edbcd3e44801794f5f4c8f528d77fff6c1c234d4855365097e4ebf59a0df8d3927ed7a508b60937e0c4dd321031a4929078e886266cd772e31df92e
|
7
|
+
data.tar.gz: d49e55978131717d3452a2eb7e6862120281bdd6b9ef4dd310b3eae62a97ac13a219377bf69b3661ba5a855b356a541c3f15f242ccd01d23d484eb432419f610
|
data/bin/bumpr
CHANGED
@@ -18,7 +18,7 @@ parser = OptionParser.new do |opts|
|
|
18
18
|
|
19
19
|
BANNER
|
20
20
|
opts.on('-n', '--no-commit', 'Leave changes in the git working index instead of committing them.') do |no_commit| options[:no_commit] = true end
|
21
|
-
opts.on('-
|
21
|
+
opts.on('-cCUSTOM', '--custom=CUSTOM', 'Custom version to use for semantic component (or build number for "build" component).') do |custom| options[:custom] = custom end
|
22
22
|
opts.on('-h', '--help', 'Print this help message.') do
|
23
23
|
puts opts
|
24
24
|
exit
|
data/bin/changetag
CHANGED
data/bin/migrate-changelog
CHANGED
@@ -13,7 +13,8 @@ parser = OptionParser.new do |opts|
|
|
13
13
|
Move any contents in Unreleased under a new heading for the specified version with current date.
|
14
14
|
|
15
15
|
BANNER
|
16
|
-
|
16
|
+
opts.on('-n', '--no-commit', 'Leave changes in the git working index instead of committing them.') do |no_commit| options[:no_commit] = true end
|
17
|
+
opts.on('-h', '--help', 'Print this help message.') do
|
17
18
|
puts opts
|
18
19
|
exit
|
19
20
|
end
|
@@ -39,5 +40,7 @@ File.open(changelog_path, 'w+') do |writable_changelog|
|
|
39
40
|
writable_changelog << changelog_contents.join('')
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
-
`git
|
43
|
+
unless options[:no_commit] then
|
44
|
+
`git add #{changelog_path}`
|
45
|
+
`git commit --message "chore(changelog): moved Unreleased entries to #{version}"`
|
46
|
+
end
|
data/bin/prerelease-podspec
CHANGED
@@ -31,6 +31,7 @@ parser = OptionParser.new do |opts|
|
|
31
31
|
opts.on('-tTAG', '--tag=TAG', 'Override for the name of the git tag to form. If set, --podspec-name-in-tag is ignored.') do |tag| options[:tag] = tag end
|
32
32
|
opts.on('-t', '--no-tag', 'Don\'t create a git tag to push. Usually used if this will be invoked again for another spec that will create and use the same tag.') do |no_tag| options[:no_tag] = true end
|
33
33
|
opts.on('-rRC', '--release-candidate=RC', 'Override for the release candidate number, which is otherwise formulated by counting the previous amount of tags with the same version number and incrementing by one.') do |rc| options[:rc] = rc end
|
34
|
+
opts.on('-q', '--quick', 'Perform quick podspec lint only.') do |quick| options[:quick] = true end
|
34
35
|
opts.on('-h', '--help', 'Print this help message.') do
|
35
36
|
puts opts
|
36
37
|
exit
|
@@ -81,15 +82,18 @@ end
|
|
81
82
|
|
82
83
|
puts "About to lint the podspec. This takes a while... (it is now #{Time.now})"
|
83
84
|
spec_lint_flags = Array.new
|
84
|
-
if options[:allow_warnings]
|
85
|
+
if options[:allow_warnings] then
|
85
86
|
spec_lint_flags << '--allow-warnings'
|
86
87
|
end
|
87
|
-
if options[:verbose]
|
88
|
+
if options[:verbose] then
|
88
89
|
spec_lint_flags << '--verbose'
|
89
90
|
end
|
90
|
-
if options[:skip_tests]
|
91
|
+
if options[:skip_tests] then
|
91
92
|
spec_lint_flags << '--skip-tests'
|
92
93
|
end
|
94
|
+
if options[:quick] then
|
95
|
+
spec_lint_flags << '--quick'
|
96
|
+
end
|
93
97
|
stdout, stderr, status = Open3.capture3 "rbenv exec bundle exec pod spec lint #{version_file} #{spec_lint_flags.join ' '}"
|
94
98
|
|
95
99
|
puts "stdout: #{stdout}"
|
data/bin/release-podspec
CHANGED
@@ -28,7 +28,8 @@ parser = OptionParser.new do |opts|
|
|
28
28
|
opts.on('-rREPO', '--repo=REPO', 'By default, release-podspec pushes the podspec to CocoaPods trunk. By supplying this argument, instead of \`pod trunk push\`, \`pod repo push\` is used instead.') do |repo| options[:repo] = repo end
|
29
29
|
opts.on('-cCHANGELOG_PATH', '--changelog-path=CHANGELOG_PATH', 'Location of a CHANGELOG document adhering to https://keepachangelog.com/en/1.0.0/ whose version entry should be extracted into an annotated tag for this release candidate. By default, release-podspec looks for //CHANGELOG.md. You can specify another location with this option.') do |changelog_path| options[:changelog_path] = changelog_path end
|
30
30
|
opts.on('-tTAG', '--tag=TAG', 'Override for the name of the git tag to form. If set, --podspec-name-in-tag is ignored.') do |tag| options[:tag] = tag end
|
31
|
-
opts.on('
|
31
|
+
opts.on('-e', '--changelog-entry=CHANGELOG_ENTRY', 'The name of the changelog entry, if it differs from the tag name.') do |changelog_entry_name_override| options[:changelog_entry_name_override] = changelog_entry_name_override end
|
32
|
+
opts.on('-i', '--skip-import-validation', 'Skip building/testing importability of podspec as part of pushing it to source.') do |skip_import_validation| options[:skip_import_validation] = true end
|
32
33
|
opts.on('-h', '--help', 'Print this help message.') do
|
33
34
|
puts opts
|
34
35
|
exit
|
@@ -63,15 +64,18 @@ end
|
|
63
64
|
echo_and_exec 'git push --tags'
|
64
65
|
|
65
66
|
spec_lint_flags = Array.new
|
66
|
-
if options[:allow_warnings]
|
67
|
+
if options[:allow_warnings] then
|
67
68
|
spec_lint_flags << '--allow-warnings'
|
68
69
|
end
|
69
|
-
if options[:verbose]
|
70
|
+
if options[:verbose] then
|
70
71
|
spec_lint_flags << '--verbose'
|
71
72
|
end
|
72
|
-
if options[:skip_tests]
|
73
|
+
if options[:skip_tests] then
|
73
74
|
spec_lint_flags << '--skip-tests'
|
74
75
|
end
|
76
|
+
if options[:skip_import_validation] then
|
77
|
+
spec_lint_flags << '--skip-import-validation'
|
78
|
+
end
|
75
79
|
|
76
80
|
command = String.new
|
77
81
|
if options[:repo] != nil then
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'octokit'
|
4
|
+
require 'json'
|
5
|
+
require 'optparse'
|
6
|
+
require_relative '../lib/echoexec'
|
7
|
+
require_relative '../lib/git_helpers'
|
8
|
+
|
9
|
+
options = {}
|
10
|
+
parser = OptionParser.new do |opts|
|
11
|
+
opts.banner = <<~BANNER
|
12
|
+
|
13
|
+
Usage: sync-git-remotes [options] <directory>
|
14
|
+
|
15
|
+
For each of your GitHub forks, clone your forked version, then go in and add a remote
|
16
|
+
to the upstream version, and set up local tracking branches for both remotes' default
|
17
|
+
branches. Then fast-forward them both, fetch all tags etc.
|
18
|
+
|
19
|
+
<directory> is the path containing the directories holding your forks, and/or
|
20
|
+
to where those you don't yet have should be cloned.
|
21
|
+
|
22
|
+
Options:
|
23
|
+
|
24
|
+
BANNER
|
25
|
+
|
26
|
+
opts.on('-tTOKEN', '--token=TOKEN', 'GitHub personal access token.') do |t| options[:token] = t end
|
27
|
+
opts.on('-rREPO', '--repo-name=REPO', 'The name of a particular repository to sync.') do |repo| options[:repo] = repo end
|
28
|
+
opts.on('-v', '--verbose', 'Enable verbose logging.') do options[:verbose] = true end
|
29
|
+
end
|
30
|
+
parser.parse!
|
31
|
+
root_dir_path = ARGV[0]
|
32
|
+
|
33
|
+
# authenticate the github client, producing a token for callers to use if they try with user/pass, as that is rate limited
|
34
|
+
github = nil
|
35
|
+
if nil != options[:token] then
|
36
|
+
github = Octokit::Client.new(:access_token => options[:token])
|
37
|
+
puts 'Running with provided token...'
|
38
|
+
end
|
39
|
+
|
40
|
+
github.auto_paginate = true
|
41
|
+
|
42
|
+
repos = github.repos
|
43
|
+
|
44
|
+
# sync owned repos
|
45
|
+
owned_repos = repos.select {|x| !x.fork}
|
46
|
+
if options[:repo] != nil then
|
47
|
+
owned_repos.select! {|x| x.name == options[:repo]}
|
48
|
+
end
|
49
|
+
owned_repos.each do |owned_repo|
|
50
|
+
puts '---'
|
51
|
+
owned_repo_info = github.repo(owned_repo.id)
|
52
|
+
sync_repo(owned_repo_info, root_dir_path)
|
53
|
+
end
|
54
|
+
|
55
|
+
# get the list of forks to sync
|
56
|
+
forks = repos.select {|x| x.fork}
|
57
|
+
if options[:repo] != nil then
|
58
|
+
forks.select! {|x| x.name == options[:repo]}
|
59
|
+
end
|
60
|
+
|
61
|
+
# sync the forks
|
62
|
+
forks.each do |forked_repo|
|
63
|
+
puts '---'
|
64
|
+
|
65
|
+
forked_repo_info = github.repo(forked_repo.id)
|
66
|
+
sync_fork(forked_repo_info, root_dir_path)
|
67
|
+
end
|
data/lib/git_helpers.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
require_relative 'echoexec'
|
3
|
+
|
4
|
+
def sync_repo repo_info, root_dir_path
|
5
|
+
name = repo_info.name
|
6
|
+
ssh_url = repo_info.ssh_url
|
7
|
+
|
8
|
+
path = "#{root_dir_path}/#{name}"
|
9
|
+
already_cloned = Dir.exist?(path)
|
10
|
+
|
11
|
+
# clone any forks not already cloned
|
12
|
+
unless already_cloned then
|
13
|
+
echo_and_exec "git clone #{ssh_url} #{path}"
|
14
|
+
end
|
15
|
+
|
16
|
+
# for repos that were cloned previously, update them by fast-forwarding the default branch and fetch all tags
|
17
|
+
if already_cloned then
|
18
|
+
Dir.chdir path do
|
19
|
+
echo_and_exec "git fetch && git fetch --tags && git pull --ff-only"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def sync_fork forked_repo_info, root_dir_path
|
26
|
+
upstream_ssh_url = forked_repo_info.source.ssh_url
|
27
|
+
original_owner = forked_repo_info.source.owner.login
|
28
|
+
name = forked_repo_info.name
|
29
|
+
fork_ssh_url = forked_repo_info.ssh_url
|
30
|
+
|
31
|
+
upstream_remote_name = 'upstream'
|
32
|
+
fork_remote_name = 'fork'
|
33
|
+
path = "#{root_dir_path}/_Forks/#{original_owner}/#{name}"
|
34
|
+
already_cloned = Dir.exist?(path)
|
35
|
+
|
36
|
+
# clone any forks not already cloned
|
37
|
+
unless already_cloned then
|
38
|
+
echo_and_exec "git clone #{fork_ssh_url} #{path}"
|
39
|
+
end
|
40
|
+
|
41
|
+
Dir.chdir path do
|
42
|
+
# if we just cloned the repo locally, set up both remotes
|
43
|
+
unless already_cloned then
|
44
|
+
echo_and_exec "git remote add #{upstream_remote_name} #{upstream_ssh_url}"
|
45
|
+
echo_and_exec "git remote rename origin #{fork_remote_name}"
|
46
|
+
end
|
47
|
+
|
48
|
+
# get the names of the default branches
|
49
|
+
fork_default_branch_name = `git remote show #{fork_remote_name} | grep "HEAD branch" | cut -d ":" -f 2`.strip
|
50
|
+
fork_default_local_branch_name = "#{fork_remote_name}_#{fork_default_branch_name}"
|
51
|
+
upstream_default_branch_name = `git remote show #{upstream_remote_name} | grep "HEAD branch" | cut -d ":" -f 2`.strip
|
52
|
+
upstream_default_local_branch_name = "#{upstream_remote_name}_#{upstream_default_branch_name}"
|
53
|
+
|
54
|
+
# if we just cloned the repo locally, set local default tracking branches
|
55
|
+
unless already_cloned then
|
56
|
+
# rename the cloned local default branch to reflect that it's tracking the fork remote's version
|
57
|
+
echo_and_exec "git branch -m #{fork_default_branch_name} #{fork_default_local_branch_name}"
|
58
|
+
|
59
|
+
# set up a local branch to track the upstream remote's default branch
|
60
|
+
echo_and_exec "git fetch #{upstream_remote_name}"
|
61
|
+
echo_and_exec "git checkout -b #{upstream_default_local_branch_name} #{upstream_remote_name}/#{upstream_default_branch_name}"
|
62
|
+
|
63
|
+
# push the local upstream default tracking branch to the fork's remote, so it also has a copy alongside it's default branch
|
64
|
+
echo_and_exec "git push #{fork_remote_name} HEAD:#{upstream_default_local_branch_name}"
|
65
|
+
end
|
66
|
+
|
67
|
+
# for repos that were cloned previously, update them by fast-forwarding both default branches and fetch all tags
|
68
|
+
if already_cloned then
|
69
|
+
echo_and_exec "git checkout #{fork_default_local_branch_name}"
|
70
|
+
echo_and_exec "git pull --ff-only #{fork_remote_name}"
|
71
|
+
echo_and_exec "git fetch --tags #{fork_remote_name}"
|
72
|
+
|
73
|
+
echo_and_exec "git checkout #{upstream_default_local_branch_name}"
|
74
|
+
echo_and_exec "git pull --ff-only #{upstream_remote_name}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tworingtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew McKnight
|
@@ -11,19 +11,19 @@ cert_chain: []
|
|
11
11
|
date: 2020-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: octokit
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.20.0
|
20
20
|
type: :runtime
|
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: 4.20.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version: '2.1'
|
41
41
|
description: |2
|
42
42
|
- xcsims: Delete all simulators and recreate one for each compatible platform and device type pairing.
|
43
|
-
- sync-
|
43
|
+
- sync-git-remotes: Make sure all your GitHub repos are cloned into a given directory and keep them synced with upstream. Forks are maintained with a remote for both the fork and upstream, both remotes' default branches are tracked in local counterparts, and the upstream default branch is also pushed to the fork.
|
44
44
|
- changetag: Extract changelog entries to write into git tag annotation messages.
|
45
45
|
- prerelease-podspec: Branch and create/push a release candidate tag, modify the podspec to use that version tag, and try linting it.
|
46
46
|
- release-podspec: Create a tag with the version and push it to repo origin, push podspec to CocoaPods trunk.
|
@@ -52,7 +52,7 @@ email: andrew@tworingsoft.com
|
|
52
52
|
executables:
|
53
53
|
- clean-rc-tags
|
54
54
|
- xcsims
|
55
|
-
- sync-
|
55
|
+
- sync-git-remotes
|
56
56
|
- changetag
|
57
57
|
- prerelease-podspec
|
58
58
|
- release-podspec
|
@@ -69,11 +69,12 @@ files:
|
|
69
69
|
- bin/prerelease-podspec
|
70
70
|
- bin/release-podspec
|
71
71
|
- bin/revert-failed-release-tag
|
72
|
-
- bin/sync-
|
72
|
+
- bin/sync-git-remotes
|
73
73
|
- bin/xcsims
|
74
74
|
- lib/echoexec.rb
|
75
75
|
- lib/errors.rb
|
76
76
|
- lib/git_check.rb
|
77
|
+
- lib/git_helpers.rb
|
77
78
|
homepage: https://github.com/TwoRingSoft/tools
|
78
79
|
licenses:
|
79
80
|
- MIT
|
data/bin/sync-forks
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'github_api'
|
4
|
-
require 'json'
|
5
|
-
require 'optparse'
|
6
|
-
require_relative '../lib/echoexec'
|
7
|
-
|
8
|
-
# failure modes
|
9
|
-
FURTHER_REQUESTS_REQUIRE_TOKEN = 65
|
10
|
-
MISSING_REQUIRED_CREDENTIALS = 66
|
11
|
-
|
12
|
-
options = {}
|
13
|
-
parser = OptionParser.new do |opts|
|
14
|
-
opts.banner = <<~BANNER
|
15
|
-
|
16
|
-
Usage: sync-forks [options] <directory>
|
17
|
-
|
18
|
-
<directory> is the path containing the directories holding your forks, and/or
|
19
|
-
to where those you don't yet have should be cloned.
|
20
|
-
|
21
|
-
Examples:
|
22
|
-
|
23
|
-
sync-forks -u/--username <user> -p/--password <pass> [-o/--one-time-pw <otp>] .
|
24
|
-
sync-forks -u/--username <user> -t/--token <token> .
|
25
|
-
sync-forks -u/--username <user> -t/--token -n/--repo-name that-one-repo-I-forked <token> .
|
26
|
-
|
27
|
-
If you already have a Personal Access Token, provide it in the second form.
|
28
|
-
Otherwise, use the first form, which will register a new token for you named
|
29
|
-
“sync-forks”. Then use that to invoke the program again. This is because
|
30
|
-
requests using basic authentication (user/pass) are too rate limited.
|
31
|
-
|
32
|
-
Options:
|
33
|
-
|
34
|
-
BANNER
|
35
|
-
|
36
|
-
opts.on('-uUSERNAME', '--username=USERNAME', 'GitHub username. Required for all invocations.') do |user| options[:username] = user end
|
37
|
-
opts.on('-tTOKEN', '--token=TOKEN', 'GitHub personal access token. The primary way to use this program.') do |t| options[:token] = t end
|
38
|
-
opts.on('-pPASSWORD', '--password=PASSWORD', 'GitHub password.') do |pass| options[:password] = pass end
|
39
|
-
opts.on('-oOTP', '--one-time-pw=OTP', 'GitHub 2FA token, if you have it enabled.') do |otp| options[:otp] = otp end
|
40
|
-
opts.on('-rREPO', '--repo-name=REPO', 'The name of a particular repository to sync.') do |repo| options[:repo] = repo end
|
41
|
-
end
|
42
|
-
parser.parse!
|
43
|
-
|
44
|
-
github = nil
|
45
|
-
if nil != options[:token] && nil != options[:username] then
|
46
|
-
github = Github.new oauth_token: options[:token]
|
47
|
-
elsif nil != options[:username] && nil != options[:password]
|
48
|
-
github = Github.new do |config|
|
49
|
-
config.basic_auth = "#{options[:username]}:#{options[:password]}"
|
50
|
-
if nil != options[:otp] then
|
51
|
-
config.connection_options = {headers: {"X-GitHub-OTP" => options[:otp]}}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
token = github.auth.create scopes: ['repo'], note: 'sync-forks3'
|
55
|
-
puts "Created new token, use it to call sync-forks again:"
|
56
|
-
puts
|
57
|
-
puts "\tsync-forks -u #{user} -t #{token.token}"
|
58
|
-
puts
|
59
|
-
exit FURTHER_REQUESTS_REQUIRE_TOKEN
|
60
|
-
else
|
61
|
-
puts "Must provide either a username/token or username/password/otp combination to authenticate."
|
62
|
-
puts parser
|
63
|
-
exit MISSING_REQUIRED_CREDENTIALS
|
64
|
-
end
|
65
|
-
|
66
|
-
repos = github.repos.list user: options[:username], auto_pagination: true
|
67
|
-
forks = repos.select {|x| x.fork}
|
68
|
-
|
69
|
-
if options[:repo] != nil then
|
70
|
-
forks.select! {|x| x.name == options[:repo]}
|
71
|
-
end
|
72
|
-
|
73
|
-
current_dir = Dir.new(ARGV[0])
|
74
|
-
Dir.chdir current_dir
|
75
|
-
forks.each do |forked|
|
76
|
-
info = github.repos(user: options[:username], repo: forked.name).get
|
77
|
-
fork_url = info.source.ssh_url
|
78
|
-
name = forked.name
|
79
|
-
url = forked.ssh_url
|
80
|
-
|
81
|
-
puts '---'
|
82
|
-
if current_dir.entries.include? name then
|
83
|
-
puts "#{name} already exists."
|
84
|
-
else
|
85
|
-
echo_and_exec "git clone #{url}"
|
86
|
-
Dir.chdir "#{name}"
|
87
|
-
echo_and_exec "git remote add upstream #{fork_url}"
|
88
|
-
Dir.chdir ".."
|
89
|
-
end
|
90
|
-
end
|