ninny 0.1.15 → 0.1.19

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: 1c01f0689e01c71df928ec993bf38c3be68321b1389ef4db7c1ca0c601d0fd02
4
- data.tar.gz: 60d84b30dcfe5e8da077e12f59dac45085c94e10d6a060d5d44fa205bbd9196a
3
+ metadata.gz: eb06f88a85ed100c85f035dfd512eab3a653ce976e4fccfcb75972b94b62a941
4
+ data.tar.gz: 624b6561506f6431afbf5e0b63963c056d028ddfaa4499397a0a943d0cafe221
5
5
  SHA512:
6
- metadata.gz: 051ef3ceebdc3934e5e2438c25020cc2b7ff8cb1c5428746005c0138658682c8934207fbddb605b03b7f7458ac79d018a56d380bfb8b971075e8c9229642b67a
7
- data.tar.gz: 7f3cb4b1f7857bb0380de618016c3d17cd29f9dbdfec9a5d3c1ead4110adaa596a390afae4933b71ef5a9aeca8c9e464878d80c2233149b835bb2660e39d425d
6
+ metadata.gz: b984582630919dc9b6ae834d113e3ff3adea6402cacc0051201985021634baf6b7e7aaae0987acd5a03753d29066786fd469356ab4d77f4bdb09deada6aa684c
7
+ data.tar.gz: 7ca0603113e71a573636d6efe74e9960d8cabbb6cbc43ed9ad25b5bc84c18dcd658098adeee60bd99b5fd81904822049ae647677e76a266fe11bc207f1c7c6a3
@@ -0,0 +1,33 @@
1
+ name: Build
2
+ on:
3
+ push:
4
+ branches: [ main ]
5
+ workflow_dispatch:
6
+
7
+ env:
8
+ REGISTRY: ghcr.io
9
+ IMAGE_NAME: ${{ github.repository }}
10
+
11
+ jobs:
12
+ docker-build:
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ packages: write
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
20
+ with:
21
+ registry: ${{ env.REGISTRY }}
22
+ username: ${{ github.actor }}
23
+ password: ${{ secrets.GITHUB_TOKEN }}
24
+ - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
25
+ id: meta
26
+ with:
27
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
28
+ - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
29
+ with:
30
+ context: .
31
+ push: true
32
+ tags: ${{ steps.meta.outputs.tags }}
33
+ labels: ${{ steps.meta.outputs.labels }}
@@ -0,0 +1,8 @@
1
+ [allowlist]
2
+ description = 'A list of commits and secrets to skip when scanning for secrets'
3
+ commits = [
4
+ 'ExampleCommit'
5
+ ]
6
+ regexes = [
7
+ 'ExampleSecret'
8
+ ]
@@ -5,7 +5,6 @@ on:
5
5
 
6
6
  jobs:
7
7
  bundler-audit:
8
- if:
9
8
  runs-on: ubuntu-latest
10
9
  steps:
11
10
  - uses: actions/checkout@v2
@@ -13,8 +12,7 @@ jobs:
13
12
  fetch-depth: 0
14
13
  - uses: ruby/setup-ruby@v1
15
14
  with:
16
- ruby-version: 2.7.2
17
- bundler: 1.17.3
15
+ ruby-version: 3.0
18
16
  bundler-cache: true
19
17
  - run: |
20
18
  gem install bundler-audit
@@ -22,7 +20,7 @@ jobs:
22
20
  bundler-audit
23
21
 
24
22
  if [ $? -eq 0 ]; then
25
- echo "No vulnerabilities found."
23
+ echo "No gem vulnerabilities found."
26
24
  else
27
25
  echo "Gem vulnerabilities found!"
28
26
  exit 1
@@ -35,8 +33,7 @@ jobs:
35
33
  fetch-depth: 0
36
34
  - uses: ruby/setup-ruby@v1
37
35
  with:
38
- ruby-version: 2.7.2
39
- bundler: 1.17.3
36
+ ruby-version: 3.0
40
37
  bundler-cache: true
41
38
  - run: |
42
39
  bundle outdated --strict
@@ -0,0 +1,65 @@
1
+ name: Test
2
+ on:
3
+ push:
4
+ branches: [ main ]
5
+ pull_request:
6
+ branches: [ main ]
7
+
8
+ env:
9
+ GITLEAKS_REF: f15b4e408b12fda7e2833f8a32c0d8a045bd48a0
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby: [2.6, 2.7, 3.0]
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ with:
21
+ fetch-depth: 0
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - run: bundle exec rake
27
+ pronto:
28
+ if: github.EVENT_NAME == 'pull_request'
29
+ runs-on: ubuntu-latest
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ with:
33
+ fetch-depth: 0
34
+ - uses: HeRoMo/pronto-action@v1.13.0
35
+ with:
36
+ github_token: ${{ secrets.GITHUB_TOKEN }}
37
+ gitleaks:
38
+ if: github.EVENT_NAME == 'pull_request'
39
+ runs-on: ubuntu-latest
40
+ steps:
41
+ - uses: actions/checkout@v2
42
+ with:
43
+ fetch-depth: 0
44
+ - run: |
45
+ curl -H "Accept: application/vnd.github.v3.raw" \
46
+ -L "https://api.github.com/repos/zricethezav/gitleaks/contents/config/gitleaks.toml?ref=${{ env.GITLEAKS_REF }}" \
47
+ >> ${{ github.WORKSPACE }}/.github/workflows/original.toml
48
+ sed "/\[allowlist\]/,/^$/d" ${{ github.WORKSPACE }}/.github/workflows/original.toml >> ${{ github.WORKSPACE }}/.github/workflows/official.toml
49
+ cat .github/workflows/gitleaks.toml >> .github/workflows/official.toml
50
+ if [[ ${{ github.REF }} == 'refs/heads/main' ]]; then
51
+ CURRENT_COMMIT="${{ github.SHA }}"
52
+ else
53
+ CURRENT_COMMIT="${{ github.EVENT.PULL_REQUEST.HEAD.SHA }}"
54
+ fi
55
+ echo "LOG_OPTS='^origin/main $CURRENT_COMMIT'" >> $GITHUB_ENV
56
+ - name: GitLeaks
57
+ uses: addnab/docker-run-action@v3
58
+ with:
59
+ image: zricethezav/gitleaks:v8.0.4
60
+ options: -v ${{ github.WORKSPACE }}:/app
61
+ run: |
62
+ cd /app
63
+ gitleaks detect --verbose --source='./' \
64
+ --config='.github/workflows/official.toml' \
65
+ --log-opts=${{ env.LOG_OPTS }}
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
3
  SuggestExtensions: false
4
- TargetRubyVersion: 2.7
4
+ TargetRubyVersion: 3.0
5
5
  Exclude:
6
6
  - vendor/**/*
7
7
 
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.2
1
+ 3.0.2
data/Dockerfile ADDED
@@ -0,0 +1,3 @@
1
+ FROM ruby:3.0.2-alpine
2
+ RUN apk add git
3
+ RUN gem install ninny
data/README.md CHANGED
@@ -72,7 +72,6 @@ $ ninny staging_branch
72
72
 
73
73
  # To merge the current branch into the current/latest staging branch
74
74
  $ ninny stage_up
75
-
76
75
  ```
77
76
 
78
77
  At any point, `ninny help` will show the help screen.
data/lib/ninny/cli.rb CHANGED
@@ -31,6 +31,8 @@ module Ninny
31
31
 
32
32
  desc 'stage_up [PULL_REQUEST_ID]', 'Merges PR/MR into the staging branch'
33
33
  method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
34
+ method_option :username, aliases: '-u', type: :string,
35
+ desc: "The name of the user who is staging up; defaults to the local git config's user"
34
36
  def stage_up(pull_request_id = nil)
35
37
  if options[:help]
36
38
  invoke :help, ['stage_up']
data/lib/ninny/command.rb CHANGED
@@ -83,7 +83,7 @@ module Ninny
83
83
  # @api public
84
84
  def prompt(**options)
85
85
  require 'tty-prompt'
86
- TTY::Prompt.new(options)
86
+ TTY::Prompt.new(*options)
87
87
  end
88
88
 
89
89
  # Get terminal screen properties
@@ -6,7 +6,7 @@ module Ninny
6
6
  module Commands
7
7
  class PullRequestMerge < Ninny::Command
8
8
  attr_accessor :pull_request_id, :options, :pull_request
9
- attr_reader :branch_type
9
+ attr_reader :branch_type, :username
10
10
 
11
11
  def initialize(pull_request_id, options)
12
12
  @branch_type = options[:branch_type] || Ninny::Git::STAGING_PREFIX
@@ -22,6 +22,8 @@ module Ninny
22
22
 
23
23
  self.pull_request_id ||= select_pull_request
24
24
 
25
+ return nil if pull_request_id.nil?
26
+
25
27
  check_out_branch
26
28
  merge_pull_request
27
29
  comment_about_merge
@@ -29,7 +31,12 @@ module Ninny
29
31
 
30
32
  def select_pull_request
31
33
  choices = Ninny.repo.open_pull_requests.map { |pr| { name: pr.title, value: pr.number } }
32
- prompt.select("Which #{Ninny.repo.pull_request_label}?", choices)
34
+
35
+ if choices.empty?
36
+ prompt.say "There don't seem to be any open merge requests."
37
+ else
38
+ prompt.select("Which #{Ninny.repo.pull_request_label}?", choices)
39
+ end
33
40
  end
34
41
  private :select_pull_request
35
42
 
@@ -58,7 +65,10 @@ module Ninny
58
65
  #
59
66
  # Returns a String
60
67
  def comment_body
61
- "Merged into #{branch_to_merge_into}."
68
+ user = username || determine_local_user
69
+ body = "Merged into #{branch_to_merge_into}".dup
70
+ body << " by #{user}" if user
71
+ body << '.'
62
72
  end
63
73
 
64
74
  # Public: Find the pull request
@@ -76,6 +86,11 @@ module Ninny
76
86
  def branch_to_merge_into
77
87
  @branch_to_merge_into ||= Ninny.git.latest_branch_for(branch_type)
78
88
  end
89
+
90
+ def determine_local_user
91
+ local_user_name = `git config user.name`.strip
92
+ local_user_name.empty? ? nil : local_user_name
93
+ end
79
94
  end
80
95
  end
81
96
  end
@@ -9,6 +9,7 @@ module Ninny
9
9
  def initialize(pull_request_id, options)
10
10
  super
11
11
  @branch_type = Ninny::Git::STAGING_PREFIX
12
+ @username = options[:username]
12
13
  end
13
14
  end
14
15
  end
data/lib/ninny/git.rb CHANGED
@@ -95,7 +95,7 @@ module Ninny
95
95
  rescue ::Git::GitExecuteError => e
96
96
  if e.message.include?(':fatal: A branch named') && e.message.include?(' already exists')
97
97
  puts "The local branch #{new_branch_name} already exists." \
98
- ' Please delete it manually and then run this command again.'
98
+ ' Please delete it manually and then run this command again.'
99
99
  exit 1
100
100
  end
101
101
  end
@@ -169,7 +169,7 @@ module Ninny
169
169
 
170
170
  def prompt(**options)
171
171
  require 'tty-prompt'
172
- TTY::Prompt.new(options)
172
+ TTY::Prompt.new(*options)
173
173
  end
174
174
 
175
175
  # Private: Ask the user if they wish to delete and recreate a branch
@@ -17,8 +17,12 @@ module Ninny
17
17
  to_pr(
18
18
  gitlab.merge_requests(
19
19
  project_id,
20
- { source_branch: Ninny.git.current_branch.name, target_branch: Ninny.project_config.deploy_branch }
21
- ).last
20
+ {
21
+ source_branch: Ninny.git.current_branch.name,
22
+ target_branch: Ninny.project_config.deploy_branch,
23
+ state: 'opened'
24
+ }
25
+ ).auto_paginate.last
22
26
  )
23
27
  end
24
28
 
@@ -27,7 +31,7 @@ module Ninny
27
31
  end
28
32
 
29
33
  def open_pull_requests
30
- gitlab.merge_requests(project_id, { state: 'opened' }).map { |mr| to_pr(mr) }
34
+ gitlab.merge_requests(project_id, { state: 'opened' }).auto_paginate.map { |mr| to_pr(mr) }
31
35
  end
32
36
 
33
37
  def pull_request(id)
data/lib/ninny/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ninny
4
- VERSION = '0.1.15'
4
+ VERSION = '0.1.19'
5
5
  end
data/ninny.gemspec CHANGED
@@ -25,17 +25,16 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_dependency 'git', '~> 1.5.0'
28
+ spec.add_dependency 'git', '~> 1.5'
29
29
  spec.add_dependency 'gitlab', '~> 4.11'
30
- spec.add_dependency 'pastel', '~> 0.7.2'
30
+ spec.add_dependency 'pastel', '~> 0.8'
31
31
  spec.add_dependency 'thor', '< 2'
32
- spec.add_dependency 'tty-box', '~> 0.3.0'
32
+ spec.add_dependency 'tty-box', '~> 0.3'
33
33
  spec.add_dependency 'tty-color', '~> 0.4'
34
- spec.add_dependency 'tty-command', '~> 0.8.0'
35
- spec.add_dependency 'tty-config', '~> 0.3.0'
36
- spec.add_dependency 'tty-prompt', '~> 0.18.0'
34
+ spec.add_dependency 'tty-command', '~> 0.10'
35
+ spec.add_dependency 'tty-config', '~> 0.3'
36
+ spec.add_dependency 'tty-prompt', '~> 0.23'
37
37
 
38
- spec.add_development_dependency 'bundler', '~> 1.17'
39
38
  spec.add_development_dependency 'byebug', '~> 11.1'
40
39
  spec.add_development_dependency 'guard-rspec', '~> 4.3'
41
40
  spec.add_development_dependency 'pronto', '~> 0.11'
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.15
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dispatch Engineers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.0
19
+ version: '1.5'
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: 1.5.0
26
+ version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gitlab
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.7.2
47
+ version: '0.8'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.7.2
54
+ version: '0.8'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: thor
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.3.0
75
+ version: '0.3'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.3.0
82
+ version: '0.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: tty-color
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,56 +100,42 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.8.0
103
+ version: '0.10'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.8.0
110
+ version: '0.10'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: tty-config
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.3.0
117
+ version: '0.3'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.3.0
124
+ version: '0.3'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: tty-prompt
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.18.0
131
+ version: '0.23'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.18.0
139
- - !ruby/object:Gem::Dependency
140
- name: bundler
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '1.17'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '1.17'
138
+ version: '0.23'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: byebug
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -285,13 +271,16 @@ extensions: []
285
271
  extra_rdoc_files: []
286
272
  files:
287
273
  - ".github/pull_request_template.md"
288
- - ".github/workflows/main.yml"
274
+ - ".github/workflows/build.yml"
275
+ - ".github/workflows/gitleaks.toml"
289
276
  - ".github/workflows/scheduled.yml"
277
+ - ".github/workflows/test.yml"
290
278
  - ".gitignore"
291
279
  - ".rspec"
292
280
  - ".rubocop.yml"
293
281
  - ".ruby-gemset"
294
282
  - ".ruby-version"
283
+ - Dockerfile
295
284
  - Gemfile
296
285
  - Guardfile
297
286
  - LICENSE.txt
@@ -325,7 +314,7 @@ homepage: https://github.com/dispatchinc/ninny
325
314
  licenses:
326
315
  - MIT
327
316
  metadata: {}
328
- post_install_message:
317
+ post_install_message:
329
318
  rdoc_options: []
330
319
  require_paths:
331
320
  - lib
@@ -340,8 +329,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
340
329
  - !ruby/object:Gem::Version
341
330
  version: '0'
342
331
  requirements: []
343
- rubygems_version: 3.1.4
344
- signing_key:
332
+ rubygems_version: 3.2.22
333
+ signing_key:
345
334
  specification_version: 4
346
335
  summary: 'ninny (n): an foolish person, see: git'
347
336
  test_files: []
@@ -1,34 +0,0 @@
1
- name: Main
2
- on:
3
- push:
4
- branches: [ main ]
5
- pull_request:
6
- branches: [ main ]
7
-
8
- jobs:
9
- test:
10
- runs-on: ubuntu-latest
11
- strategy:
12
- fail-fast: false
13
- matrix:
14
- ruby: [2.6.3, 2.6.6, 2.7.0, 2.7.2]
15
- steps:
16
- - uses: actions/checkout@v2
17
- with:
18
- fetch-depth: 0
19
- - uses: ruby/setup-ruby@v1
20
- with:
21
- ruby-version: ${{ matrix.ruby }}
22
- bundler: 1.17.3
23
- bundler-cache: true
24
- - run: bundle exec rake
25
- pronto:
26
- if: github.EVENT_NAME == 'pull_request'
27
- runs-on: ubuntu-latest
28
- steps:
29
- - uses: actions/checkout@v2
30
- with:
31
- fetch-depth: 0
32
- - uses: HeRoMo/pronto-action@v1.13.0
33
- with:
34
- github_token: ${{ secrets.GITHUB_TOKEN }}