ninny 0.1.10 → 0.1.15
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/.github/workflows/scheduled.yml +49 -0
- data/.rubocop.yml +21 -0
- data/README.md +9 -3
- data/lib/ninny/cli.rb +1 -0
- data/lib/ninny/commands/create_dated_branch.rb +2 -1
- data/lib/ninny/commands/pull_request_merge.rb +2 -0
- data/lib/ninny/commands/setup.rb +35 -7
- data/lib/ninny/git.rb +46 -9
- data/lib/ninny/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c01f0689e01c71df928ec993bf38c3be68321b1389ef4db7c1ca0c601d0fd02
|
4
|
+
data.tar.gz: 60d84b30dcfe5e8da077e12f59dac45085c94e10d6a060d5d44fa205bbd9196a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 051ef3ceebdc3934e5e2438c25020cc2b7ff8cb1c5428746005c0138658682c8934207fbddb605b03b7f7458ac79d018a56d380bfb8b971075e8c9229642b67a
|
7
|
+
data.tar.gz: 7f3cb4b1f7857bb0380de618016c3d17cd29f9dbdfec9a5d3c1ead4110adaa596a390afae4933b71ef5a9aeca8c9e464878d80c2233149b835bb2660e39d425d
|
@@ -0,0 +1,49 @@
|
|
1
|
+
name: Scheduled
|
2
|
+
on:
|
3
|
+
schedule:
|
4
|
+
- cron: "0 4 * * 1" # 4am UTC on Mondays (10pm/11pm CT on Sundays)
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
bundler-audit:
|
8
|
+
if:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
with:
|
13
|
+
fetch-depth: 0
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 2.7.2
|
17
|
+
bundler: 1.17.3
|
18
|
+
bundler-cache: true
|
19
|
+
- run: |
|
20
|
+
gem install bundler-audit
|
21
|
+
bundler-audit update
|
22
|
+
bundler-audit
|
23
|
+
|
24
|
+
if [ $? -eq 0 ]; then
|
25
|
+
echo "No vulnerabilities found."
|
26
|
+
else
|
27
|
+
echo "Gem vulnerabilities found!"
|
28
|
+
exit 1
|
29
|
+
fi
|
30
|
+
bundle-outdated:
|
31
|
+
runs-on: ubuntu-latest
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v2
|
34
|
+
with:
|
35
|
+
fetch-depth: 0
|
36
|
+
- uses: ruby/setup-ruby@v1
|
37
|
+
with:
|
38
|
+
ruby-version: 2.7.2
|
39
|
+
bundler: 1.17.3
|
40
|
+
bundler-cache: true
|
41
|
+
- run: |
|
42
|
+
bundle outdated --strict
|
43
|
+
|
44
|
+
if [ $? -eq 0 ]; then
|
45
|
+
echo "No outdated gems found."
|
46
|
+
else
|
47
|
+
echo "Outdated gems found!"
|
48
|
+
exit 1
|
49
|
+
fi
|
data/.rubocop.yml
CHANGED
@@ -11,6 +11,10 @@ Gemspec/RequiredRubyVersion:
|
|
11
11
|
Style/Documentation:
|
12
12
|
Enabled: false
|
13
13
|
|
14
|
+
Layout/LineLength:
|
15
|
+
Exclude:
|
16
|
+
- spec/**/*
|
17
|
+
|
14
18
|
Lint/EmptyClass:
|
15
19
|
Enabled: false
|
16
20
|
|
@@ -20,5 +24,22 @@ Lint/EmptyBlock:
|
|
20
24
|
Lint/MissingSuper:
|
21
25
|
Enabled: false
|
22
26
|
|
27
|
+
Metrics/BlockLength:
|
28
|
+
Enabled: true
|
29
|
+
Exclude:
|
30
|
+
- spec/**/*
|
31
|
+
- ninny.gemspec
|
32
|
+
|
33
|
+
Metrics/MethodLength:
|
34
|
+
Max: 15
|
35
|
+
|
36
|
+
Style/AccessModifierDeclarations:
|
37
|
+
EnforcedStyle: inline
|
38
|
+
|
39
|
+
Style/BlockDelimiters:
|
40
|
+
Enabled: true
|
41
|
+
Exclude:
|
42
|
+
- spec/**/*
|
43
|
+
|
23
44
|
Style/OptionalBooleanParameter:
|
24
45
|
Enabled: false
|
data/README.md
CHANGED
@@ -42,9 +42,15 @@ Then, each developer on the project should set up a file at `~/.ninny.yml` on th
|
|
42
42
|
|
43
43
|
```bash
|
44
44
|
$ ninny setup
|
45
|
-
Do you have a new GitLab private token? (Y/n)
|
45
|
+
Do you have a new GitLab private token? (Y/n) Yes # enter 'y'
|
46
46
|
Enter private token: abc123def456ghi789jk # enter your private token
|
47
|
-
User config updated
|
47
|
+
User config updated!
|
48
|
+
```
|
49
|
+
|
50
|
+
Or, you can pass the private token in as part of the command:
|
51
|
+
```bash
|
52
|
+
$ ninny setup --token abc123def456ghi789jk # or '-t abc123def456ghi789jk' for short
|
53
|
+
User config updated!
|
48
54
|
```
|
49
55
|
|
50
56
|
The private token should be a personal access token for that person's GitLab account (generated [here](https://gitlab.com/-/profile/personal_access_tokens)).
|
@@ -83,7 +89,7 @@ At any point, `ninny help` will show the help screen.
|
|
83
89
|
* Run `bundle exec guard` to run tests continuously as you develop
|
84
90
|
6. Test the gem locally
|
85
91
|
* Run `gem build *.gemspec` to build the gem locally
|
86
|
-
* Run `gem install --local ninny-
|
92
|
+
* Run `gem install --local ninny-X.X.X.gem` to install the gem locally
|
87
93
|
7. Make a pull request back to this repository
|
88
94
|
|
89
95
|
### Releasing
|
data/lib/ninny/cli.rb
CHANGED
@@ -54,6 +54,7 @@ module Ninny
|
|
54
54
|
|
55
55
|
desc 'setup', 'Interactively setup configuration'
|
56
56
|
method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
|
57
|
+
method_option :token, aliases: '-t', type: :string, desc: 'The GitLab token to add to the ~/.ninny.yml file'
|
57
58
|
def setup(*)
|
58
59
|
if options[:help]
|
59
60
|
invoke :help, ['setup']
|
@@ -13,11 +13,12 @@ module Ninny
|
|
13
13
|
def execute(output: $stdout)
|
14
14
|
create_branch
|
15
15
|
delete_old_branches
|
16
|
-
output.puts "#{branch_name} created"
|
16
|
+
output.puts "Branch #{branch_name} successfully created."
|
17
17
|
end
|
18
18
|
|
19
19
|
# Public: Create the desired branch
|
20
20
|
def create_branch
|
21
|
+
prompt.say "Attempting to create branch #{branch_name}."
|
21
22
|
Ninny.git.new_branch(branch_name, Ninny.project_config.deploy_branch)
|
22
23
|
end
|
23
24
|
|
@@ -35,6 +35,7 @@ module Ninny
|
|
35
35
|
|
36
36
|
# Public: Check out the branch
|
37
37
|
def check_out_branch
|
38
|
+
prompt.say "Checking out #{branch_to_merge_into}."
|
38
39
|
Ninny.git.check_out(branch_to_merge_into, false)
|
39
40
|
Ninny.git.track_current_branch
|
40
41
|
rescue Ninny::Git::NoBranchOfType
|
@@ -44,6 +45,7 @@ module Ninny
|
|
44
45
|
|
45
46
|
# Public: Merge the pull request's branch into the checked-out branch
|
46
47
|
def merge_pull_request
|
48
|
+
prompt.say "Merging #{pull_request.branch} to #{branch_to_merge_into}."
|
47
49
|
Ninny.git.merge(pull_request.branch)
|
48
50
|
end
|
49
51
|
|
data/lib/ninny/commands/setup.rb
CHANGED
@@ -5,21 +5,29 @@ require_relative '../command'
|
|
5
5
|
module Ninny
|
6
6
|
module Commands
|
7
7
|
class Setup < Ninny::Command
|
8
|
-
attr_reader :config
|
8
|
+
attr_reader :config, :private_token
|
9
9
|
|
10
10
|
def initialize(options)
|
11
11
|
@options = options
|
12
|
+
@private_token = options[:token]
|
12
13
|
@config = Ninny.user_config
|
13
14
|
end
|
14
15
|
|
15
16
|
def execute(output: $stdout)
|
16
17
|
try_reading_user_config
|
17
18
|
|
18
|
-
|
19
|
+
unless @private_token
|
20
|
+
@private_token = prompt_for_gitlab_private_token
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
unless @private_token
|
23
|
+
output.puts "Please create a private token on GitLab and then rerun 'ninny setup'."
|
24
|
+
return
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
set_response = config_set_gitlab_private_token(@private_token)
|
29
|
+
write_gitlab_private_token(@private_token, set_response)
|
30
|
+
output.puts "User config #{@result}!"
|
23
31
|
end
|
24
32
|
|
25
33
|
def try_reading_user_config
|
@@ -29,6 +37,27 @@ module Ninny
|
|
29
37
|
@result = 'created'
|
30
38
|
end
|
31
39
|
|
40
|
+
def config_set_gitlab_private_token(private_token)
|
41
|
+
# TODO: This only works with thor gem < 1. So, we need to make this work when TTY
|
42
|
+
# releases versions compatible with thor versions >= 1 as well.
|
43
|
+
config.set(:gitlab_private_token, value: private_token)
|
44
|
+
:success
|
45
|
+
rescue ArgumentError
|
46
|
+
puts ' Unable to set new token via TTY... continuing anyway...'
|
47
|
+
:failed
|
48
|
+
end
|
49
|
+
|
50
|
+
def write_gitlab_private_token(private_token, set_response)
|
51
|
+
raise StandardError unless set_response == :success
|
52
|
+
|
53
|
+
# TODO: This only works with thor gem < 1. So, we need to make this work when TTY
|
54
|
+
# releases versions compatible with thor versions >= 1 as well.
|
55
|
+
config.write(force: true)
|
56
|
+
rescue StandardError
|
57
|
+
puts ' Unable to write config file via TTY... continuing anyway...'
|
58
|
+
File.open("#{ENV['HOME']}/.ninny.yml", 'w') { |file| file.puts "gitlab_private_token: #{private_token}" }
|
59
|
+
end
|
60
|
+
|
32
61
|
def prompt_for_gitlab_private_token
|
33
62
|
begin
|
34
63
|
new_token_text = config.gitlab_private_token ? ' new' : ''
|
@@ -38,8 +67,7 @@ module Ninny
|
|
38
67
|
|
39
68
|
return unless prompt.yes?("Do you have a#{new_token_text} GitLab private token?")
|
40
69
|
|
41
|
-
|
42
|
-
config.set(:gitlab_private_token, value: private_token)
|
70
|
+
prompt.ask('Enter private token:', required: true)
|
43
71
|
end
|
44
72
|
end
|
45
73
|
end
|
data/lib/ninny/git.rb
CHANGED
@@ -38,7 +38,7 @@ module Ninny
|
|
38
38
|
|
39
39
|
def merge(branch_name)
|
40
40
|
if_clean do
|
41
|
-
git.fetch
|
41
|
+
git.fetch('-p')
|
42
42
|
command 'merge', ['--no-ff', "origin/#{branch_name}"]
|
43
43
|
raise MergeFailed unless clean?
|
44
44
|
|
@@ -65,8 +65,8 @@ module Ninny
|
|
65
65
|
# branch_name - The name of the branch to check out
|
66
66
|
# do_after_pull - Should a pull be done after checkout?
|
67
67
|
def check_out(branch, do_after_pull = true)
|
68
|
-
git.fetch
|
69
|
-
|
68
|
+
git.fetch('-p')
|
69
|
+
git.checkout(branch)
|
70
70
|
pull if do_after_pull
|
71
71
|
raise CheckoutFailed, "Failed to check out '#{branch}'" unless current_branch.name == branch.name
|
72
72
|
end
|
@@ -84,11 +84,20 @@ module Ninny
|
|
84
84
|
# new_branch_name - The name of the branch to create
|
85
85
|
# source_branch_name - The name of the branch to branch from
|
86
86
|
def new_branch(new_branch_name, source_branch_name)
|
87
|
-
git.fetch
|
88
|
-
command('branch', ['--
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
git.fetch('-p')
|
88
|
+
remote_branches = command('branch', ['--remote'])
|
89
|
+
|
90
|
+
if remote_branches.include?("origin/#{new_branch_name}")
|
91
|
+
ask_to_recreate_branch(new_branch_name, source_branch_name)
|
92
|
+
else
|
93
|
+
create_branch(new_branch_name, source_branch_name)
|
94
|
+
end
|
95
|
+
rescue ::Git::GitExecuteError => e
|
96
|
+
if e.message.include?(':fatal: A branch named') && e.message.include?(' already exists')
|
97
|
+
puts "The local branch #{new_branch_name} already exists." \
|
98
|
+
' Please delete it manually and then run this command again.'
|
99
|
+
exit 1
|
100
|
+
end
|
92
101
|
end
|
93
102
|
|
94
103
|
# Public: Delete the given branch
|
@@ -98,13 +107,17 @@ module Ninny
|
|
98
107
|
branch = branch_name.is_a?(::Git::Branch) ? branch_name : git.branch(branch_name)
|
99
108
|
git.push('origin', ":#{branch}")
|
100
109
|
branch.delete
|
110
|
+
rescue ::Git::GitExecuteError => e
|
111
|
+
if e.message.include?(':error: branch') && e.message.include?(' not found.')
|
112
|
+
puts 'Could not delete local branch, but the remote branch was deleted.'
|
113
|
+
end
|
101
114
|
end
|
102
115
|
|
103
116
|
# Public: The list of branches on GitHub
|
104
117
|
#
|
105
118
|
# Returns an Array of Strings containing the branch names
|
106
119
|
def remote_branches
|
107
|
-
git.fetch
|
120
|
+
git.fetch('-p')
|
108
121
|
git.branches.remote.map { |branch| git.branch(branch.name) }.sort_by(&:name)
|
109
122
|
end
|
110
123
|
|
@@ -159,6 +172,30 @@ module Ninny
|
|
159
172
|
TTY::Prompt.new(options)
|
160
173
|
end
|
161
174
|
|
175
|
+
# Private: Ask the user if they wish to delete and recreate a branch
|
176
|
+
#
|
177
|
+
# new_branch_name: the name of the branch in question
|
178
|
+
# source_branch_name: the name of the branch the new branch is supposed to be based off of
|
179
|
+
private def ask_to_recreate_branch(new_branch_name, source_branch_name)
|
180
|
+
if prompt.yes?("The branch #{new_branch_name} already exists. Do you wish to delete and recreate?")
|
181
|
+
delete_branch(new_branch_name)
|
182
|
+
new_branch(new_branch_name, source_branch_name)
|
183
|
+
else
|
184
|
+
exit 1
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# Private: Create a branch
|
189
|
+
#
|
190
|
+
# new_branch_name: the name of the branch in question
|
191
|
+
# source_branch_name: the name of the branch the new branch is supposed to be based off of
|
192
|
+
private def create_branch(new_branch_name, source_branch_name)
|
193
|
+
command('branch', ['--no-track', new_branch_name, "origin/#{source_branch_name}"])
|
194
|
+
new_branch = branch(new_branch_name)
|
195
|
+
new_branch.checkout
|
196
|
+
command('push', ['-u', 'origin', new_branch_name])
|
197
|
+
end
|
198
|
+
|
162
199
|
# Exceptions
|
163
200
|
CheckoutFailed = Class.new(StandardError)
|
164
201
|
NotOnBranch = Class.new(StandardError)
|
data/lib/ninny/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ninny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dispatch Engineers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -286,6 +286,7 @@ extra_rdoc_files: []
|
|
286
286
|
files:
|
287
287
|
- ".github/pull_request_template.md"
|
288
288
|
- ".github/workflows/main.yml"
|
289
|
+
- ".github/workflows/scheduled.yml"
|
289
290
|
- ".gitignore"
|
290
291
|
- ".rspec"
|
291
292
|
- ".rubocop.yml"
|