unwrappr 0.3.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +23 -0
- data/.gitignore +2 -3
- data/.rubocop.yml +2 -1
- data/.tool-versions +1 -0
- data/CHANGELOG.md +95 -7
- data/README.md +6 -7
- data/lib/unwrappr/cli.rb +26 -9
- data/lib/unwrappr/gem_change.rb +6 -0
- data/lib/unwrappr/gem_version.rb +9 -1
- data/lib/unwrappr/git_command_runner.rb +12 -12
- data/lib/unwrappr/github/client.rb +16 -10
- data/lib/unwrappr/github/pr_source.rb +3 -2
- data/lib/unwrappr/lock_file_annotator.rb +4 -2
- data/lib/unwrappr/lock_file_comparator.rb +3 -1
- data/lib/unwrappr/lock_file_diff.rb +1 -1
- data/lib/unwrappr/researchers/github_repo.rb +4 -1
- data/lib/unwrappr/researchers/ruby_gems_info.rb +3 -1
- data/lib/unwrappr/ruby_gems.rb +3 -7
- data/lib/unwrappr/version.rb +1 -1
- data/lib/unwrappr/writers/version_change.rb +14 -4
- data/unwrappr.gemspec +13 -10
- metadata +23 -22
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 197b63d85c71cc3d7701f8f22cd1a0c305bf07a6eade0c5e7c8ca52ec0538bb3
|
4
|
+
data.tar.gz: 07546ef3c1f66c5a6e9dd632d0f1ac07a5bae6c56897ec6908b9f5ae360dc682
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0eb4bed6b570378cc213667250f9fbca23e3a25ac84779d8ec2d54ebe4c7fb1cd601c1bac84a92ebff2861a52950f9c048f7c79fb947001c259289ca54272bd
|
7
|
+
data.tar.gz: 2ccbd4e9c68b2d38746b5a88bd37730f1bd211d65d94ceed575b6573e151d733cc7dae0dc4331dd9381d1b8084a05d92d932ad6800d83e726ed456dc4bcce2f1
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
ruby: ['2.5', '2.6', '2.7', '3.0']
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- name: Checkout
|
15
|
+
uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
- name: Install dependencies
|
21
|
+
run: bundle install
|
22
|
+
- name: Run tests
|
23
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.0.0
|
data/CHANGELOG.md
CHANGED
@@ -6,19 +6,107 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
[Unreleased]: https://github.com/envato/unwrappr/compare/v0.6.0...HEAD
|
10
|
+
|
11
|
+
## [0.6.0] 2021-05-12
|
12
|
+
|
13
|
+
### Add
|
14
|
+
- Allow specification of Gemfile lock files to annotate. ([#86])
|
15
|
+
|
16
|
+
[0.6.0]: https://github.com/envato/unwrappr/compare/v0.5.0..v0.6.0
|
17
|
+
[#86]: https://github.com/envato/unwrappr/pull/86
|
18
|
+
|
19
|
+
## [0.5.0] 2021-01-04
|
20
|
+
|
21
|
+
### Add
|
22
|
+
- Support for Ruby 3. ([#79])
|
23
|
+
- Allow specification of base branch, upon which to base the pull-request
|
24
|
+
([#80], [#84])
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
- Moved CI to GitHub Actions ([#78])
|
28
|
+
- Fixed homepage URL in gemspec ([#77])
|
29
|
+
- Default branch is now `main`([#81])
|
30
|
+
- Rename private predicate methods in GitCommandRunner to be more descriptive.
|
31
|
+
([#82])
|
32
|
+
- Upgrade Faraday dependency to version 1 ([#85])
|
33
|
+
|
34
|
+
[0.5.0]: https://github.com/envato/unwrappr/compare/v0.4.0..v0.5.0
|
35
|
+
[#77]: https://github.com/envato/unwrappr/pull/77
|
36
|
+
[#78]: https://github.com/envato/unwrappr/pull/78
|
37
|
+
[#79]: https://github.com/envato/unwrappr/pull/79
|
38
|
+
[#80]: https://github.com/envato/unwrappr/pull/80
|
39
|
+
[#81]: https://github.com/envato/unwrappr/pull/81
|
40
|
+
[#82]: https://github.com/envato/unwrappr/pull/82
|
41
|
+
[#84]: https://github.com/envato/unwrappr/pull/84
|
42
|
+
[#85]: https://github.com/envato/unwrappr/pull/85
|
43
|
+
|
44
|
+
## [0.4.0] 2020-04-14
|
45
|
+
### Changed
|
46
|
+
- `bundler-audit` limited to `>= 0.6.0` ([#71])
|
47
|
+
|
48
|
+
### Removed
|
49
|
+
- Support for Ruby 2.3 and 2.4 ([#73])
|
50
|
+
|
51
|
+
### Added
|
52
|
+
- Rake vulnerability CVE-2020-8130 fixes ([#72])
|
53
|
+
- Support for Ruby 2.6 and 2.7 ([#73])
|
54
|
+
- Support for version numbers including a fourth segment (_e.g._ "6.0.2.2") ([#74])
|
55
|
+
- Support for GitHub URIs including anchors ([#75])
|
56
|
+
|
57
|
+
[0.4.0]: https://github.com/envato/unwrappr/compare/v0.3.5..v0.4.0
|
58
|
+
[#71]: https://github.com/envato/unwrappr/pull/71
|
59
|
+
[#72]: https://github.com/envato/unwrappr/pull/72
|
60
|
+
[#73]: https://github.com/envato/unwrappr/pull/73
|
61
|
+
[#74]: https://github.com/envato/unwrappr/pull/74
|
62
|
+
[#75]: https://github.com/envato/unwrappr/pull/75
|
63
|
+
|
64
|
+
## [0.3.5] 2019-11-28
|
65
|
+
### Changed
|
66
|
+
- ISO 8601 Date and time format for branch name ([#68])
|
67
|
+
### Fixed
|
68
|
+
- Changelog and source links in PR annotation are specific to the version
|
69
|
+
used in the project, not just the latest available on Rubygems.org ([#69]).
|
70
|
+
|
71
|
+
[0.3.5]: https://github.com/envato/unwrappr/compare/v0.3.4...v0.3.5
|
72
|
+
[#68]: https://github.com/envato/unwrappr/pull/68
|
73
|
+
[#69]: https://github.com/envato/unwrappr/pull/69
|
74
|
+
|
75
|
+
## [0.3.4] 2019-10-24
|
76
|
+
### Fixed
|
77
|
+
- Fix failure to annotate gem change with '.' in its name ([#65]).
|
78
|
+
|
79
|
+
[0.3.4]: https://github.com/envato/unwrappr/compare/v0.3.3...v0.3.4
|
80
|
+
[#65]: https://github.com/envato/unwrappr/pull/65
|
81
|
+
|
9
82
|
## [0.3.3] 2019-06-07
|
10
|
-
|
83
|
+
### Fixed
|
84
|
+
- Fix issue where gem install will now work on RubyGems v3 ([#61]).
|
85
|
+
|
86
|
+
[0.3.3]: https://github.com/envato/unwrappr/compare/v0.3.2...v0.3.3
|
87
|
+
[#61]: https://github.com/envato/unwrappr/pull/61
|
11
88
|
|
12
89
|
## [0.3.2] 2018-11-13
|
13
90
|
### Added
|
14
|
-
- Specify Ruby and RubyGems requirements in gemspec.
|
15
|
-
- Clone one git repository or more and create an annotated bundle update PR for each.
|
91
|
+
- Specify Ruby and RubyGems requirements in gemspec ([#56]).
|
92
|
+
- Clone one git repository or more and create an annotated bundle update PR for each ([#52]).
|
93
|
+
|
94
|
+
[0.3.2]: https://github.com/envato/unwrappr/compare/v0.3.1...v0.3.2
|
95
|
+
[#56]: https://github.com/envato/unwrappr/pull/56
|
96
|
+
[#52]: https://github.com/envato/unwrappr/pull/52
|
16
97
|
|
17
98
|
## [0.3.1] 2018-11-12
|
18
99
|
### Changed
|
19
|
-
- Travis CI enabled
|
20
|
-
- Ensure we are protected against CVE-2017-8418
|
21
|
-
- RubyGems metadata includes a description
|
100
|
+
- Travis CI enabled ([#55]).
|
101
|
+
- Ensure we are protected against CVE-2017-8418 ([#54]).
|
102
|
+
- RubyGems metadata includes a description ([#49]).
|
103
|
+
|
104
|
+
[0.3.1]: https://github.com/envato/unwrappr/compare/v0.3.0...v0.3.1
|
105
|
+
[#55]: https://github.com/envato/unwrappr/pull/55
|
106
|
+
[#54]: https://github.com/envato/unwrappr/pull/54
|
107
|
+
[#49]: https://github.com/envato/unwrappr/pull/49
|
22
108
|
|
23
109
|
## [0.3.0] 2018-11-12
|
24
|
-
|
110
|
+
### Initial Release
|
111
|
+
|
112
|
+
[0.3.0]: https://github.com/envato/unwrappr/releases/tag/v0.3.0
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ to get regular dependency updates into production.
|
|
16
16
|
- Vulnerability advisory information using [bundler-audit](https://github.com/rubysec/bundler-audit)
|
17
17
|
- Links to the home page, source code and change log (where available) of each gem
|
18
18
|
|
19
|
-
## Development status [![
|
19
|
+
## Development status [![CI Status](https://github.com/envato/unwrappr/workflows/CI/badge.svg)](https://github.com/envato/unwrappr/actions?query=workflow%3ACI)
|
20
20
|
|
21
21
|
`unwrappr` is used in many projects around [Envato][envato]
|
22
22
|
However, it is still undergoing development and features are likely to change
|
@@ -63,13 +63,12 @@ See https://github.com/settings/tokens to set up personal access tokens.
|
|
63
63
|
|
64
64
|
## Requirements
|
65
65
|
|
66
|
-
- Ruby (tested against v2.
|
66
|
+
- Ruby (tested against v2.5 and above)
|
67
67
|
- GitHub access (see Configuration section)
|
68
68
|
|
69
|
-
## Contact
|
69
|
+
## Contact
|
70
70
|
|
71
71
|
- [GitHub project](https://github.com/envato/unwrappr)
|
72
|
-
- [Gitter chat room](https://gitter.im/envato/unwrappr)
|
73
72
|
- Bug reports and feature requests are welcome via [GitHub Issues](https://github.com/envato/unwrappr/issues)
|
74
73
|
|
75
74
|
## Maintainers
|
@@ -86,16 +85,16 @@ See https://github.com/settings/tokens to set up personal access tokens.
|
|
86
85
|
- [Em Esc](https://github.com/emesc)
|
87
86
|
- [Chun-wei Kuo](https://github.com/Domon)
|
88
87
|
|
89
|
-
## License [![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/envato/unwrappr/blob/
|
88
|
+
## License [![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/envato/unwrappr/blob/HEAD/LICENSE.txt)
|
90
89
|
|
91
90
|
`unwrappr` uses MIT license. See
|
92
|
-
[`LICENSE.txt`](https://github.com/envato/unwrappr/blob/
|
91
|
+
[`LICENSE.txt`](https://github.com/envato/unwrappr/blob/HEAD/LICENSE.txt) for
|
93
92
|
details.
|
94
93
|
|
95
94
|
## Code of Conduct
|
96
95
|
|
97
96
|
We welcome contribution from everyone. Read more about it in
|
98
|
-
[`CODE_OF_CONDUCT.md`](https://github.com/envato/unwrappr/blob/
|
97
|
+
[`CODE_OF_CONDUCT.md`](https://github.com/envato/unwrappr/blob/HEAD/CODE_OF_CONDUCT.md)
|
99
98
|
|
100
99
|
## Contributing [![PRs welcome](https://img.shields.io/badge/PRs-welcome-orange.svg?style=flat-square)](https://github.com/envato/unwrappr/issues)
|
101
100
|
|
data/lib/unwrappr/cli.rb
CHANGED
@@ -8,6 +8,22 @@ module Unwrappr
|
|
8
8
|
class CLI < Clamp::Command
|
9
9
|
self.default_subcommand = 'all'
|
10
10
|
|
11
|
+
option(['-b', '--base'],
|
12
|
+
'BRANCH',
|
13
|
+
<<~DESCRIPTION,
|
14
|
+
the branch upon which to base the pull-request. Omit this option
|
15
|
+
to use the current branch, or repository's default branch
|
16
|
+
(typically 'origin/main') on clone.
|
17
|
+
DESCRIPTION
|
18
|
+
attribute_name: :base_branch)
|
19
|
+
|
20
|
+
option ['-f', '--lock-file'],
|
21
|
+
'LOCK_FILE1 [-f LOCK_FILE2] [-f LOCK_FILE3] [-f ...]',
|
22
|
+
'The Gemfile.lock files to annotate. Useful when working with multiple lock files.',
|
23
|
+
multivalued: true,
|
24
|
+
default: ['Gemfile.lock'],
|
25
|
+
attribute_name: :lock_files
|
26
|
+
|
11
27
|
option ['-v', '--version'], :flag, 'Show version' do
|
12
28
|
puts "unwrappr v#{Unwrappr::VERSION}"
|
13
29
|
exit(0)
|
@@ -16,7 +32,7 @@ module Unwrappr
|
|
16
32
|
subcommand 'all', 'run bundle update, push to github, '\
|
17
33
|
'create a pr and annotate changes' do
|
18
34
|
def execute
|
19
|
-
Unwrappr.run_unwapper_in_pwd
|
35
|
+
Unwrappr.run_unwapper_in_pwd(base_branch: base_branch, lock_files: lock_files)
|
20
36
|
end
|
21
37
|
end
|
22
38
|
|
@@ -33,7 +49,8 @@ module Unwrappr
|
|
33
49
|
def execute
|
34
50
|
LockFileAnnotator.annotate_github_pull_request(
|
35
51
|
repo: repo,
|
36
|
-
pr_number: pr.to_i
|
52
|
+
pr_number: pr.to_i,
|
53
|
+
lock_files: lock_files
|
37
54
|
)
|
38
55
|
end
|
39
56
|
end
|
@@ -59,24 +76,24 @@ module Unwrappr
|
|
59
76
|
)
|
60
77
|
end
|
61
78
|
|
62
|
-
Dir.chdir(repo) { Unwrappr.run_unwapper_in_pwd }
|
79
|
+
Dir.chdir(repo) { Unwrappr.run_unwapper_in_pwd(base_branch: base_branch, lock_files: lock_files) }
|
63
80
|
end
|
64
81
|
end
|
65
82
|
end
|
66
83
|
end
|
67
84
|
|
68
|
-
def self.run_unwapper_in_pwd
|
69
|
-
return unless
|
85
|
+
def self.run_unwapper_in_pwd(base_branch:, lock_files:)
|
86
|
+
return unless any_lockfile_present?(lock_files)
|
70
87
|
|
71
88
|
puts "Doing the unwrappr thing in #{Dir.pwd}"
|
72
89
|
|
73
|
-
GitCommandRunner.create_branch!
|
90
|
+
GitCommandRunner.create_branch!(base_branch: base_branch)
|
74
91
|
BundlerCommandRunner.bundle_update!
|
75
92
|
GitCommandRunner.commit_and_push_changes!
|
76
|
-
GitHub::Client.make_pull_request!
|
93
|
+
GitHub::Client.make_pull_request!(lock_files)
|
77
94
|
end
|
78
95
|
|
79
|
-
def self.
|
80
|
-
GitCommandRunner.file_exist?(
|
96
|
+
def self.any_lockfile_present?(lock_files)
|
97
|
+
lock_files.any? { |lock_file| GitCommandRunner.file_exist?(lock_file) }
|
81
98
|
end
|
82
99
|
end
|
data/lib/unwrappr/gem_change.rb
CHANGED
@@ -18,6 +18,7 @@ module Unwrappr
|
|
18
18
|
end
|
19
19
|
|
20
20
|
attr_reader :name, :head_version, :base_version, :line_number
|
21
|
+
|
21
22
|
def_delegators :@lock_file_diff, :filename, :sha
|
22
23
|
|
23
24
|
def added?
|
@@ -43,6 +44,11 @@ module Unwrappr
|
|
43
44
|
head_version.patch_difference?(base_version)
|
44
45
|
end
|
45
46
|
|
47
|
+
def hotfix?
|
48
|
+
head_version && base_version &&
|
49
|
+
head_version.hotfix_difference?(base_version)
|
50
|
+
end
|
51
|
+
|
46
52
|
def upgrade?
|
47
53
|
head_version && base_version && (head_version > base_version)
|
48
54
|
end
|
data/lib/unwrappr/gem_version.rb
CHANGED
@@ -13,9 +13,10 @@ module Unwrappr
|
|
13
13
|
@major = segment(0)
|
14
14
|
@minor = segment(1)
|
15
15
|
@patch = segment(2)
|
16
|
+
@hotfix = segment(3)
|
16
17
|
end
|
17
18
|
|
18
|
-
attr_reader :major, :minor, :patch, :version
|
19
|
+
attr_reader :major, :minor, :patch, :hotfix, :version
|
19
20
|
|
20
21
|
def major_difference?(other)
|
21
22
|
(major != other.major)
|
@@ -32,6 +33,13 @@ module Unwrappr
|
|
32
33
|
(patch != other.patch)
|
33
34
|
end
|
34
35
|
|
36
|
+
def hotfix_difference?(other)
|
37
|
+
(major == other.major) &&
|
38
|
+
(minor == other.minor) &&
|
39
|
+
(patch == other.patch) &&
|
40
|
+
(hotfix != other.hotfix)
|
41
|
+
end
|
42
|
+
|
35
43
|
def <=>(other)
|
36
44
|
@version <=> other.version
|
37
45
|
end
|
@@ -7,15 +7,15 @@ module Unwrappr
|
|
7
7
|
# Runs Git commands
|
8
8
|
module GitCommandRunner
|
9
9
|
class << self
|
10
|
-
def create_branch!
|
10
|
+
def create_branch!(base_branch:)
|
11
11
|
raise 'Not a git working dir' unless git_dir?
|
12
|
-
raise
|
12
|
+
raise "failed to create branch from '#{base_branch}'" unless checkout_target_branch(base_branch: base_branch)
|
13
13
|
end
|
14
14
|
|
15
15
|
def commit_and_push_changes!
|
16
|
-
raise 'failed to add git changes' unless
|
17
|
-
raise 'failed to commit changes' unless
|
18
|
-
raise 'failed to push changes' unless
|
16
|
+
raise 'failed to add git changes' unless stage_all_changes
|
17
|
+
raise 'failed to commit changes' unless commit_staged_changes
|
18
|
+
raise 'failed to push changes' unless push_current_branch_to_origin
|
19
19
|
end
|
20
20
|
|
21
21
|
def reset_client
|
@@ -50,23 +50,23 @@ module Unwrappr
|
|
50
50
|
git_wrap { !current_branch_name.empty? }
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
54
|
-
timestamp = Time.now.strftime('%Y%d
|
53
|
+
def checkout_target_branch(base_branch:)
|
54
|
+
timestamp = Time.now.strftime('%Y%m%d-%H%M').freeze
|
55
55
|
git_wrap do
|
56
|
-
git.checkout(
|
56
|
+
git.checkout(base_branch) unless base_branch.nil?
|
57
57
|
git.branch("auto_bundle_update_#{timestamp}").checkout
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def stage_all_changes
|
62
62
|
git_wrap { git.add(all: true) }
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def commit_staged_changes
|
66
66
|
git_wrap { git.commit('Automatic Bundle Update') }
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def push_current_branch_to_origin
|
70
70
|
git_wrap { git.push('origin', current_branch_name) }
|
71
71
|
end
|
72
72
|
|
@@ -80,7 +80,7 @@ module Unwrappr
|
|
80
80
|
|
81
81
|
def log_options
|
82
82
|
{}.tap do |opt|
|
83
|
-
opt[:log] = Logger.new(
|
83
|
+
opt[:log] = Logger.new($stdout) if ENV['DEBUG']
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -12,8 +12,8 @@ module Unwrappr
|
|
12
12
|
@github_token = nil
|
13
13
|
end
|
14
14
|
|
15
|
-
def make_pull_request!
|
16
|
-
create_and_annotate_pull_request
|
15
|
+
def make_pull_request!(lock_files)
|
16
|
+
create_and_annotate_pull_request(lock_files)
|
17
17
|
rescue Octokit::ClientError => e
|
18
18
|
raise "Failed to create and annotate pull request: #{e}"
|
19
19
|
end
|
@@ -27,15 +27,20 @@ module Unwrappr
|
|
27
27
|
[m[:org], m[:repo]].join('/')
|
28
28
|
end
|
29
29
|
|
30
|
-
def create_and_annotate_pull_request
|
30
|
+
def create_and_annotate_pull_request(lock_files)
|
31
31
|
pr = git_client.create_pull_request(
|
32
32
|
repo_name_and_org,
|
33
|
-
|
33
|
+
repo_default_branch,
|
34
34
|
Unwrappr::GitCommandRunner.current_branch_name,
|
35
35
|
'Automated Bundle Update',
|
36
36
|
pull_request_body
|
37
37
|
)
|
38
|
-
annotate_pull_request(pr.number)
|
38
|
+
annotate_pull_request(pr.number, lock_files)
|
39
|
+
end
|
40
|
+
|
41
|
+
def repo_default_branch
|
42
|
+
git_client.repository(repo_name_and_org)
|
43
|
+
.default_branch
|
39
44
|
end
|
40
45
|
|
41
46
|
def pull_request_body
|
@@ -45,10 +50,11 @@ module Unwrappr
|
|
45
50
|
BODY
|
46
51
|
end
|
47
52
|
|
48
|
-
def annotate_pull_request(pr_number)
|
53
|
+
def annotate_pull_request(pr_number, lock_files)
|
49
54
|
LockFileAnnotator.annotate_github_pull_request(
|
50
55
|
repo: repo_name_and_org,
|
51
56
|
pr_number: pr_number,
|
57
|
+
lock_files: lock_files,
|
52
58
|
client: git_client
|
53
59
|
)
|
54
60
|
end
|
@@ -58,16 +64,16 @@ module Unwrappr
|
|
58
64
|
end
|
59
65
|
|
60
66
|
def github_token
|
61
|
-
@github_token ||= ENV.fetch('GITHUB_TOKEN')
|
62
|
-
|
67
|
+
@github_token ||= ENV.fetch('GITHUB_TOKEN')
|
68
|
+
rescue KeyError
|
69
|
+
raise %(
|
63
70
|
Missing environment variable GITHUB_TOKEN.
|
64
71
|
See https://github.com/settings/tokens to set up personal access tokens.
|
65
72
|
Add to the environment:
|
66
73
|
|
67
74
|
export GITHUB_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
68
75
|
|
69
|
-
)
|
70
|
-
end
|
76
|
+
)
|
71
77
|
end
|
72
78
|
end
|
73
79
|
end
|
@@ -9,9 +9,10 @@ module Unwrappr
|
|
9
9
|
# Implements the `lock_file_diff_source` interface as defined by the
|
10
10
|
# LockFileAnnotator.
|
11
11
|
class PrSource
|
12
|
-
def initialize(repo, pr_number, client)
|
12
|
+
def initialize(repo, pr_number, lock_files, client)
|
13
13
|
@repo = repo
|
14
14
|
@pr_number = pr_number
|
15
|
+
@lock_files = lock_files
|
15
16
|
@client = client
|
16
17
|
end
|
17
18
|
|
@@ -33,7 +34,7 @@ module Unwrappr
|
|
33
34
|
@lock_file_diffs ||= @client
|
34
35
|
.pull_request_files(@repo, @pr_number)
|
35
36
|
.select do |file|
|
36
|
-
File.basename(file.filename)
|
37
|
+
@lock_files.include?(File.basename(file.filename))
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -18,10 +18,10 @@ module Unwrappr
|
|
18
18
|
class LockFileAnnotator
|
19
19
|
# rubocop:disable Metrics/MethodLength
|
20
20
|
def self.annotate_github_pull_request(
|
21
|
-
repo:, pr_number:, client: Octokit.client
|
21
|
+
repo:, pr_number:, lock_files:, client: Octokit.client
|
22
22
|
)
|
23
23
|
new(
|
24
|
-
lock_file_diff_source: Github::PrSource.new(repo, pr_number, client),
|
24
|
+
lock_file_diff_source: Github::PrSource.new(repo, pr_number, lock_files, client),
|
25
25
|
annotation_sink: Github::PrSink.new(repo, pr_number, client),
|
26
26
|
annotation_writer: Writers::Composite.new(
|
27
27
|
Writers::Title,
|
@@ -54,6 +54,8 @@ module Unwrappr
|
|
54
54
|
|
55
55
|
def annotate
|
56
56
|
@lock_file_diff_source.each_file do |lock_file_diff|
|
57
|
+
puts "Annotating #{lock_file_diff.filename}"
|
58
|
+
|
57
59
|
lock_file_diff.each_gem_change do |gem_change|
|
58
60
|
gem_change_info = @gem_researcher.research(gem_change, {})
|
59
61
|
message = @annotation_writer.write(gem_change, gem_change_info)
|
@@ -63,7 +63,7 @@ module Unwrappr
|
|
63
63
|
# '+ websocket-driver (0.6.5)'
|
64
64
|
# Careful not to match this (note the wider indent):
|
65
65
|
# '+ websocket-extensions (>= 0.1.0)'
|
66
|
-
pattern = /^(?<change_type>[
|
66
|
+
pattern = /^(?<change_type>[+\-]) (?<gem_name>\S+) \(\d/
|
67
67
|
match = pattern.match(line)
|
68
68
|
return match[:gem_name], match[:change_type] unless match.nil?
|
69
69
|
end
|
@@ -7,7 +7,10 @@ module Unwrappr
|
|
7
7
|
# Implements the `gem_researcher` interface required by the
|
8
8
|
# LockFileAnnotator.
|
9
9
|
class GithubRepo
|
10
|
-
GITHUB_URI_PATTERN = %r{^https?://
|
10
|
+
GITHUB_URI_PATTERN = %r{^https?://
|
11
|
+
github.com/
|
12
|
+
(?<repo>[^/]+/[[:alnum:]_.-]+)
|
13
|
+
}ix.freeze
|
11
14
|
|
12
15
|
def research(_gem_change, gem_change_info)
|
13
16
|
repo = match_repo(gem_change_info, :source_code_uri) ||
|
@@ -9,7 +9,9 @@ module Unwrappr
|
|
9
9
|
class RubyGemsInfo
|
10
10
|
def research(gem_change, gem_change_info)
|
11
11
|
gem_change_info.merge(
|
12
|
-
ruby_gems: ::Unwrappr::RubyGems.gem_info(
|
12
|
+
ruby_gems: ::Unwrappr::RubyGems.gem_info(
|
13
|
+
gem_change.name, gem_change.head_version
|
14
|
+
)
|
13
15
|
)
|
14
16
|
end
|
15
17
|
end
|
data/lib/unwrappr/ruby_gems.rb
CHANGED
@@ -6,15 +6,11 @@ module Unwrappr
|
|
6
6
|
# A wrapper around RubyGems' API
|
7
7
|
module RubyGems
|
8
8
|
SERVER = 'https://rubygems.org'
|
9
|
-
GET_GEM = '/api/
|
9
|
+
GET_GEM = '/api/v2/rubygems/%s/versions/%s.json'
|
10
10
|
|
11
11
|
class << self
|
12
|
-
def gem_info(name)
|
13
|
-
parse(Faraday.get(SERVER + GET_GEM
|
14
|
-
end
|
15
|
-
|
16
|
-
def try_get_source_code_uri(gem_name)
|
17
|
-
Unwrappr::RubyGems.gem_info(gem_name)&.source_code_uri
|
12
|
+
def gem_info(name, version)
|
13
|
+
parse(Faraday.get(SERVER + format(GET_GEM, name, version)), name)
|
18
14
|
end
|
19
15
|
|
20
16
|
private
|
data/lib/unwrappr/version.rb
CHANGED
@@ -27,18 +27,28 @@ module Unwrappr
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def_delegators(:@gem_change,
|
30
|
-
:added?, :removed?, :major?, :minor?, :patch?,
|
30
|
+
:added?, :removed?, :major?, :minor?, :patch?, :hotfix?,
|
31
31
|
:upgrade?, :downgrade?, :base_version, :head_version)
|
32
32
|
|
33
33
|
def change_description
|
34
|
-
if added?
|
35
|
-
|
36
|
-
elsif
|
34
|
+
if added?
|
35
|
+
'Gem added :snowman:'
|
36
|
+
elsif removed?
|
37
|
+
'Gem removed :fire:'
|
38
|
+
else
|
39
|
+
version_description
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def version_description
|
44
|
+
if major?
|
37
45
|
"**Major** version #{grade}:exclamation: #{version_diff}"
|
38
46
|
elsif minor?
|
39
47
|
"**Minor** version #{grade}:large_orange_diamond: #{version_diff}"
|
40
48
|
elsif patch?
|
41
49
|
"**Patch** version #{grade}:small_blue_diamond: #{version_diff}"
|
50
|
+
elsif hotfix?
|
51
|
+
"**Hotfix** version #{grade}:small_red_triangle: #{version_diff}"
|
42
52
|
end
|
43
53
|
end
|
44
54
|
|
data/unwrappr.gemspec
CHANGED
@@ -12,6 +12,9 @@ AUTHORS = {
|
|
12
12
|
'vladimir.chervanev@envato.com' => 'Vladimir Chervanev'
|
13
13
|
}.freeze
|
14
14
|
|
15
|
+
GITHUB_URL = 'https://github.com/envato/unwrappr'
|
16
|
+
HOMEPAGE_URL = 'https://opensource.envato.com/projects/unwrappr.html'
|
17
|
+
|
15
18
|
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength:
|
16
19
|
spec.name = 'unwrappr'
|
17
20
|
spec.version = Unwrappr::VERSION
|
@@ -20,9 +23,9 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength:
|
|
20
23
|
|
21
24
|
spec.summary = "A tool to unwrap your gems and see what's changed easily"
|
22
25
|
spec.description = 'bundle update PRs: Automated. Annotated.'
|
23
|
-
spec.homepage =
|
26
|
+
spec.homepage = HOMEPAGE_URL
|
24
27
|
spec.license = 'MIT'
|
25
|
-
spec.required_ruby_version = '
|
28
|
+
spec.required_ruby_version = '>= 2.5'
|
26
29
|
spec.required_rubygems_version = '>= 2.7'
|
27
30
|
|
28
31
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -33,9 +36,9 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength:
|
|
33
36
|
spec.require_paths = ['lib']
|
34
37
|
|
35
38
|
spec.add_dependency 'bundler', '< 3'
|
36
|
-
spec.add_dependency 'bundler-audit', '
|
39
|
+
spec.add_dependency 'bundler-audit', '>= 0.6.0'
|
37
40
|
spec.add_dependency 'clamp', '~> 1'
|
38
|
-
spec.add_dependency 'faraday', '~>
|
41
|
+
spec.add_dependency 'faraday', '~> 1'
|
39
42
|
spec.add_dependency 'git', '~> 1'
|
40
43
|
spec.add_dependency 'octokit', '~> 4.0'
|
41
44
|
spec.add_dependency 'safe_shell', '~> 1'
|
@@ -43,16 +46,16 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength:
|
|
43
46
|
spec.add_development_dependency 'guard', '~> 2'
|
44
47
|
spec.add_development_dependency 'guard-rspec', '~> 4'
|
45
48
|
spec.add_development_dependency 'pry', '~> 0'
|
46
|
-
spec.add_development_dependency 'rake', '
|
49
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
47
50
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
48
51
|
spec.add_development_dependency 'rspec-its', '~> 1'
|
49
52
|
spec.add_development_dependency 'rubocop', '>= 0.49.0'
|
50
53
|
|
51
54
|
spec.metadata = {
|
52
|
-
'bug_tracker_uri' =>
|
53
|
-
'changelog_uri' =>
|
54
|
-
'documentation_uri' =>
|
55
|
-
'homepage_uri' =>
|
56
|
-
'source_code_uri' =>
|
55
|
+
'bug_tracker_uri' => "#{GITHUB_URL}/issues",
|
56
|
+
'changelog_uri' => "#{GITHUB_URL}/blob/HEAD/CHANGELOG.md",
|
57
|
+
'documentation_uri' => "#{GITHUB_URL}/blob/HEAD/README.md",
|
58
|
+
'homepage_uri' => HOMEPAGE_URL,
|
59
|
+
'source_code_uri' => GITHUB_URL
|
57
60
|
}
|
58
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unwrappr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emilyn Escabarte
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
- Orien Madgwick
|
10
10
|
- Pete Johns
|
11
11
|
- Vladimir Chervanev
|
12
|
-
autorequire:
|
12
|
+
autorequire:
|
13
13
|
bindir: exe
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bundler
|
@@ -32,16 +32,16 @@ dependencies:
|
|
32
32
|
name: bundler-audit
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
|
-
- - "
|
35
|
+
- - ">="
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 0.6.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- - "
|
42
|
+
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
44
|
+
version: 0.6.0
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: clamp
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,14 +62,14 @@ dependencies:
|
|
62
62
|
requirements:
|
63
63
|
- - "~>"
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: '
|
65
|
+
version: '1'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
70
|
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
72
|
+
version: '1'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: git
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,16 +158,16 @@ dependencies:
|
|
158
158
|
name: rake
|
159
159
|
requirement: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
|
-
- - "
|
161
|
+
- - ">="
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version:
|
163
|
+
version: 12.3.3
|
164
164
|
type: :development
|
165
165
|
prerelease: false
|
166
166
|
version_requirements: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
|
-
- - "
|
168
|
+
- - ">="
|
169
169
|
- !ruby/object:Gem::Version
|
170
|
-
version:
|
170
|
+
version: 12.3.3
|
171
171
|
- !ruby/object:Gem::Dependency
|
172
172
|
name: rspec
|
173
173
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,10 +225,11 @@ files:
|
|
225
225
|
- ".buildkite/pipeline.yml"
|
226
226
|
- ".buildkite/steps/rspec.sh"
|
227
227
|
- ".buildkite/steps/rubocop.sh"
|
228
|
+
- ".github/workflows/ci.yml"
|
228
229
|
- ".gitignore"
|
229
230
|
- ".rspec"
|
230
231
|
- ".rubocop.yml"
|
231
|
-
- ".
|
232
|
+
- ".tool-versions"
|
232
233
|
- CHANGELOG.md
|
233
234
|
- CODE_OF_CONDUCT.md
|
234
235
|
- Gemfile
|
@@ -267,32 +268,32 @@ files:
|
|
267
268
|
- lib/unwrappr/writers/title.rb
|
268
269
|
- lib/unwrappr/writers/version_change.rb
|
269
270
|
- unwrappr.gemspec
|
270
|
-
homepage:
|
271
|
+
homepage: https://opensource.envato.com/projects/unwrappr.html
|
271
272
|
licenses:
|
272
273
|
- MIT
|
273
274
|
metadata:
|
274
275
|
bug_tracker_uri: https://github.com/envato/unwrappr/issues
|
275
|
-
changelog_uri: https://github.com/envato/unwrappr/blob/
|
276
|
-
documentation_uri: https://github.com/envato/unwrappr/blob/
|
276
|
+
changelog_uri: https://github.com/envato/unwrappr/blob/HEAD/CHANGELOG.md
|
277
|
+
documentation_uri: https://github.com/envato/unwrappr/blob/HEAD/README.md
|
277
278
|
homepage_uri: https://opensource.envato.com/projects/unwrappr.html
|
278
279
|
source_code_uri: https://github.com/envato/unwrappr
|
279
|
-
post_install_message:
|
280
|
+
post_install_message:
|
280
281
|
rdoc_options: []
|
281
282
|
require_paths:
|
282
283
|
- lib
|
283
284
|
required_ruby_version: !ruby/object:Gem::Requirement
|
284
285
|
requirements:
|
285
|
-
- - "
|
286
|
+
- - ">="
|
286
287
|
- !ruby/object:Gem::Version
|
287
|
-
version: '2.
|
288
|
+
version: '2.5'
|
288
289
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
289
290
|
requirements:
|
290
291
|
- - ">="
|
291
292
|
- !ruby/object:Gem::Version
|
292
293
|
version: '2.7'
|
293
294
|
requirements: []
|
294
|
-
rubygems_version: 3.
|
295
|
-
signing_key:
|
295
|
+
rubygems_version: 3.2.11
|
296
|
+
signing_key:
|
296
297
|
specification_version: 4
|
297
298
|
summary: A tool to unwrap your gems and see what's changed easily
|
298
299
|
test_files: []
|