gouteur 1.0.2 → 1.2.0

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: 9cced511802f382d5ebaf4035fd7b06e98f0eca07e72e29c08ddae2b8de01d2f
4
- data.tar.gz: 2854883c107ac874febb0e1aeb1c939d5c621bffed23feb38f22a63e1aaa0d0d
3
+ metadata.gz: ec10a96202fe527dacc5f4bf12342b15bd6f97e1ee34ea061ed09b9493185d56
4
+ data.tar.gz: df1daa88ea3074c2007573a76234c1db4e006e2d6c9994f65b585c070d739fd8
5
5
  SHA512:
6
- metadata.gz: 34a5301cfb9d2c421079334b0426763c70aeeffcd9e1f270385979403e0506d7753d7e1eba9db1a3741b636154861fb0833c3945a6c1fe60c0bf0ecf3d5410c6
7
- data.tar.gz: 066d049552256df89bede60548f584e5806cfbe4f6d0a470f23ed40d5fb8c0c1554c7f9ef6cf75c6360e7c77d21adc2ac2d4c22e15df71c94d82cb9a8811ce95
6
+ metadata.gz: edfc25b8299250c7770d68745b17df443d5757a01234eae0d826efa6232a14faacc10ced6bceaf982a0a7749fcfd5e9cfe734bdd3bcee10cc8e9ae41e3523274
7
+ data.tar.gz: 4cedcee12cf24b8318567df163f7a9ebb6617124185564d0568dad4a11f180b6a81967e409ee1c642bc68557303f585f3c52100ac6e020a874d9e4b73cc62f18
@@ -8,10 +8,10 @@ jobs:
8
8
 
9
9
  strategy:
10
10
  matrix:
11
- ruby: [ '2.6', '3.0', 'ruby-head' ]
11
+ ruby: [ '3.5', '4.0' ]
12
12
 
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v4
15
15
  - name: Set up Ruby ${{ matrix.ruby }}
16
16
  uses: ruby/setup-ruby@v1
17
17
  with:
@@ -21,8 +21,11 @@ jobs:
21
21
  git config --global init.defaultBranch main
22
22
  git config --global user.email "testuser@example.com"
23
23
  git config --global user.name "Test User"
24
- gem install bundler -v 2.2.8
24
+ gem update --system
25
+ gem install bundler -v 4.0.9
25
26
  bundle install --jobs 4
26
- - name: Run the specs
27
+ - name: Build
27
28
  run: |
28
- bundle exec rspec
29
+ bundle exec rake
30
+ - uses: codecov/codecov-action@v3
31
+ if: matrix.ruby == '4.0'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.2.0] - 2026-04-04
4
+
5
+ ### Added
6
+
7
+ - Support for repos where the bundle is in a subdirectory
8
+
9
+ ## [1.1.0] - 2023-02-21
10
+
11
+ ### Added
12
+
13
+ - Added force flag to force testing, irrespective of version constraints
14
+ - Support passing dotfile repo names to CLI
15
+ - Support setting custom names for repos in dotfile
16
+ - Support git SSH/SCP addresses
17
+
3
18
  ## [1.0.2] - 2022-09-24
4
19
 
5
20
  ### Fixed
data/Gemfile CHANGED
@@ -3,14 +3,12 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in gouteur.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'debug'
7
+ gem 'example_repo', '0.1.0', path: './spec/gouteur/example_repo'
6
8
  gem 'rake', '~> 13.0'
7
-
9
+ gem 'relaxed-rubocop'
8
10
  gem 'rspec', '~> 3.0'
9
-
10
11
  gem 'rubocop', '~> 1.7'
11
-
12
- gem 'relaxed-rubocop'
13
-
14
- gem 'example_repo', '0.1.0', path: './spec/gouteur/example_repo'
15
-
16
- gem 'debug'
12
+ if RUBY_VERSION.to_f >= 3.0
13
+ gem "simplecov-cobertura"
14
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gouteur (1.0.2)
4
+ gouteur (1.1.0)
5
5
 
6
6
  PATH
7
7
  remote: spec/gouteur/example_repo
@@ -11,52 +11,88 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- ast (2.4.2)
15
- debug (1.6.2)
16
- irb (>= 1.3.6)
17
- reline (>= 0.3.1)
18
- diff-lcs (1.5.0)
19
- io-console (0.5.11)
20
- irb (1.4.1)
21
- reline (>= 0.3.0)
22
- json (2.6.2)
23
- parallel (1.22.1)
24
- parser (3.1.2.1)
14
+ ast (2.4.3)
15
+ date (3.5.1)
16
+ debug (1.11.1)
17
+ irb (~> 1.10)
18
+ reline (>= 0.3.8)
19
+ diff-lcs (1.6.2)
20
+ docile (1.4.1)
21
+ erb (6.0.2)
22
+ io-console (0.8.2)
23
+ irb (1.17.0)
24
+ pp (>= 0.6.0)
25
+ prism (>= 1.3.0)
26
+ rdoc (>= 4.0.0)
27
+ reline (>= 0.4.2)
28
+ json (2.19.3)
29
+ language_server-protocol (3.17.0.5)
30
+ lint_roller (1.1.0)
31
+ parallel (1.28.0)
32
+ parser (3.3.11.1)
25
33
  ast (~> 2.4.1)
34
+ racc
35
+ pp (0.6.3)
36
+ prettyprint
37
+ prettyprint (0.2.0)
38
+ prism (1.9.0)
39
+ psych (5.3.1)
40
+ date
41
+ stringio
42
+ racc (1.8.1)
26
43
  rainbow (3.1.1)
27
- rake (13.0.6)
28
- regexp_parser (2.5.0)
44
+ rake (13.3.1)
45
+ rdoc (7.2.0)
46
+ erb
47
+ psych (>= 4.0.0)
48
+ tsort
49
+ regexp_parser (2.12.0)
29
50
  relaxed-rubocop (2.5)
30
- reline (0.3.1)
51
+ reline (0.6.3)
31
52
  io-console (~> 0.5)
32
- rexml (3.2.5)
33
- rspec (3.11.0)
34
- rspec-core (~> 3.11.0)
35
- rspec-expectations (~> 3.11.0)
36
- rspec-mocks (~> 3.11.0)
37
- rspec-core (3.11.0)
38
- rspec-support (~> 3.11.0)
39
- rspec-expectations (3.11.1)
53
+ rexml (3.4.4)
54
+ rspec (3.13.2)
55
+ rspec-core (~> 3.13.0)
56
+ rspec-expectations (~> 3.13.0)
57
+ rspec-mocks (~> 3.13.0)
58
+ rspec-core (3.13.6)
59
+ rspec-support (~> 3.13.0)
60
+ rspec-expectations (3.13.5)
40
61
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.11.0)
42
- rspec-mocks (3.11.1)
62
+ rspec-support (~> 3.13.0)
63
+ rspec-mocks (3.13.8)
43
64
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.11.0)
45
- rspec-support (3.11.1)
46
- rubocop (1.36.0)
65
+ rspec-support (~> 3.13.0)
66
+ rspec-support (3.13.7)
67
+ rubocop (1.86.0)
47
68
  json (~> 2.3)
69
+ language_server-protocol (~> 3.17.0.2)
70
+ lint_roller (~> 1.1.0)
48
71
  parallel (~> 1.10)
49
- parser (>= 3.1.2.1)
72
+ parser (>= 3.3.0.2)
50
73
  rainbow (>= 2.2.2, < 4.0)
51
- regexp_parser (>= 1.8, < 3.0)
52
- rexml (>= 3.2.5, < 4.0)
53
- rubocop-ast (>= 1.20.1, < 2.0)
74
+ regexp_parser (>= 2.9.3, < 3.0)
75
+ rubocop-ast (>= 1.49.0, < 2.0)
54
76
  ruby-progressbar (~> 1.7)
55
- unicode-display_width (>= 1.4.0, < 3.0)
56
- rubocop-ast (1.21.0)
57
- parser (>= 3.1.1.0)
58
- ruby-progressbar (1.11.0)
59
- unicode-display_width (2.3.0)
77
+ unicode-display_width (>= 2.4.0, < 4.0)
78
+ rubocop-ast (1.49.1)
79
+ parser (>= 3.3.7.2)
80
+ prism (~> 1.7)
81
+ ruby-progressbar (1.13.0)
82
+ simplecov (0.22.0)
83
+ docile (~> 1.1)
84
+ simplecov-html (~> 0.11)
85
+ simplecov_json_formatter (~> 0.1)
86
+ simplecov-cobertura (3.1.0)
87
+ rexml
88
+ simplecov (~> 0.19)
89
+ simplecov-html (0.13.2)
90
+ simplecov_json_formatter (0.1.4)
91
+ stringio (3.2.0)
92
+ tsort (0.2.0)
93
+ unicode-display_width (3.2.0)
94
+ unicode-emoji (~> 4.1)
95
+ unicode-emoji (4.2.0)
60
96
 
61
97
  PLATFORMS
62
98
  ruby
@@ -69,6 +105,7 @@ DEPENDENCIES
69
105
  relaxed-rubocop
70
106
  rspec (~> 3.0)
71
107
  rubocop (~> 1.7)
108
+ simplecov-cobertura
72
109
 
73
110
  BUNDLED WITH
74
- 2.2.8
111
+ 4.0.9
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/gouteur.svg)](http://badge.fury.io/rb/gouteur)
4
4
  [![Build Status](https://github.com/jaynetics/gouteur/workflows/build/badge.svg)](https://github.com/jaynetics/gouteur/actions)
5
+ [![Coverage](https://codecov.io/gh/jaynetics/gouteur/branch/main/graph/badge.svg?token=519NAAEQFC)](https://codecov.io/gh/jaynetics/gouteur)
5
6
 
6
7
  Treat the people that use your gem like royalty! Send for a [gouteur](https://en.wikipedia.org/wiki/Food_taster) before serving them something new!
7
8
 
@@ -29,15 +30,12 @@ Add `gouteur` to the development dependencies of your gem.
29
30
 
30
31
  ### Recommended usage
31
32
 
32
- Create a `.gouteur.yml` in the root of your project:
33
+ Create a `.gouteur.yml` in the root of your project and add the gems you want to test against:
33
34
 
34
35
  ```yml
35
36
  repos:
36
37
  - uri: https://github.com/someone/some_gem
37
- ref: some_specific_branch # optional, default is the default branch
38
- before: setup_special_dependency # optional, bundle is always installed
39
- tasks: ['rspec', 'rake foo'] # optional, default is `rake`
40
- locked: true # optional, prevents setting an incompatible VERSION
38
+ - uri: https://github.com/someone/another_gem
41
39
  ```
42
40
 
43
41
  Then simply `bundle exec gouteur` or add the rake task to your Rakefile:
@@ -50,13 +48,30 @@ Gouteur::RakeTask.new
50
48
  task default: %i[rspec gouteur]
51
49
  ```
52
50
 
53
- Pro tip: for large repos, running only relevant specs can speed up things a lot, e.g.:
51
+ Pro tip: gouteur executes the default rake task of each gem by default, but for large repos, running only relevant specs can speed up things a lot, e.g.:
54
52
 
55
53
  ```yml
56
- tasks: 'rspec spec/known_relevant_spec.rb'
54
+ repos:
55
+ - uri: some_gem_uri
56
+ tasks: 'rspec spec/known_relevant_spec.rb'
57
+ - uri: some_other_uri
58
+ tasks: 'rspec --pattern "**/{,*}{keyword1,keyword2}{,*,*/**/*}_spec.rb"'`
57
59
  ```
60
+
61
+ ### Other configuration options
62
+
63
+ There are many other configuration options. All except the `uri` are optional.
64
+
58
65
  ```yml
59
- tasks: 'rspec --pattern "**/{,*}{keyword1,keyword2}{,*,*/**/*}_spec.rb"'`
66
+ repos:
67
+ - uri: https://github.com/someone/some_gem
68
+ ref: some_specific_branch # default is the default branch
69
+ subdir: the_actual_gem # if gem is in a subdir of the repo
70
+ before: setup_special_dependency # bundle is always installed
71
+ tasks: ['rspec', 'rake foo'] # default is `rake`
72
+ name: cool_gem # defaults to repo name from uri, e.g. `some_gem`
73
+ locked: true # prevents setting an incompatible VERSION
74
+ force: true # forces test even if VERSION is incompatible
60
75
  ```
61
76
 
62
77
  ### Manual usage
@@ -64,7 +79,11 @@ tasks: 'rspec --pattern "**/{,*}{keyword1,keyword2}{,*,*/**/*}_spec.rb"'`
64
79
  From the shell:
65
80
 
66
81
  ```shell
82
+ # example: check one dependent repo
67
83
  gouteur 'https://github.com/foo/bar'
84
+
85
+ # see other usage options:
86
+ gouteur --help
68
87
  ```
69
88
 
70
89
  From Ruby:
@@ -82,11 +101,11 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/jaynet
82
101
 
83
102
  Possible future improvements:
84
103
 
104
+ - verbose mode
85
105
  - consider caching of dependent repositories in CI, e.g. in GitHub workflows
86
106
  - support more sources of code, e.g. latest release, private GitHub repositories
87
107
  - improve performance by tracing & rerunning only specs/tests that use the gem
88
108
  - save time in MiniTest by forcing it to run in fail-fast mode like RSpec
89
- - add help output and more options to the CLI executable
90
109
  - other ideas? open an issue!
91
110
 
92
111
  ## License
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rubocop/rake_task'
7
7
 
8
8
  RuboCop::RakeTask.new
9
9
 
10
- task default: %i[spec rubocop]
10
+ task default: %i[rubocop spec]
11
11
 
12
12
  require_relative 'lib/gouteur/rake_task'
13
13
  Gouteur::RakeTask.new
@@ -16,7 +16,7 @@ module Gouteur
16
16
  end
17
17
 
18
18
  def exec(task, env: {})
19
- name = task.sub(/bundle exec +/, '')
19
+ name = task.sub(/bundle +exec +/, '')
20
20
  Shell.run(%W[bundle exec #{name}], pwd: path, env: env)
21
21
  end
22
22
 
@@ -3,15 +3,16 @@ require 'yaml'
3
3
  module Gouteur
4
4
  # main process class
5
5
  class Checker
6
- attr_reader :repo
6
+ attr_reader :repo, :force
7
7
 
8
- def self.call(repo, silent: false)
9
- new(repo, silent: silent).call
8
+ def self.call(repo, silent: false, force: repo&.force?)
9
+ new(repo, silent: silent, force: force).call
10
10
  end
11
11
 
12
- def initialize(repo, silent: false)
12
+ def initialize(repo, silent: false, force: repo&.force?)
13
13
  @repo = repo
14
14
  @silent = silent
15
+ @force = force
15
16
  end
16
17
 
17
18
  def call
@@ -21,7 +22,8 @@ module Gouteur
21
22
 
22
23
  run_tasks(adapted: false)
23
24
 
24
- create_adapted_gemfile
25
+ repo.gemfile.create_adapted(drop_version_constraint: force)
26
+ repo.remove_host_from_gemspecs if force
25
27
  install_adapted_bundle or return handle_incompatible_semver
26
28
 
27
29
  run_tasks(adapted: true)
@@ -58,36 +60,6 @@ module Gouteur
58
60
  )
59
61
  end
60
62
 
61
- def create_adapted_gemfile
62
- content = File.exist?(gemfile_path) ? File.read(gemfile_path) : ''
63
- adapted_content = adapt_gemfile_content(content)
64
- File.open(adapted_gemfile_path, 'w') { |f| f.puts(adapted_content) }
65
- end
66
-
67
- def adapt_gemfile_content(content)
68
- new_entry = "gem '#{Host.name}', path: '#{Host.root}' # set by gouteur "
69
-
70
- existing_ref_pattern =
71
- /^ *gem +(?<q>'|")#{Host.name}\k<q>(?<v> *,\s*(?<q2>'|")[^'"]+\k<q2>*)?/
72
-
73
- if content =~ existing_ref_pattern
74
- content.gsub(existing_ref_pattern) do
75
- # keep version specification if there was one
76
- new_entry.sub(/(?=, path:)/, Regexp.last_match[:v].to_s)
77
- end
78
- else
79
- "#{content}\n#{new_entry}\n"
80
- end
81
- end
82
-
83
- def gemfile_path
84
- repo.bundle.gemfile_path
85
- end
86
-
87
- def adapted_gemfile_path
88
- "#{repo.bundle.gemfile_path}.gouteur"
89
- end
90
-
91
63
  def install_adapted_bundle
92
64
  result = repo.bundle.install(env: adaptation_env)
93
65
  if result.success?
@@ -116,7 +88,7 @@ module Gouteur
116
88
 
117
89
  def adaptation_env
118
90
  {
119
- 'BUNDLE_GEMFILE' => adapted_gemfile_path,
91
+ 'BUNDLE_GEMFILE' => repo.gemfile.adapted_path,
120
92
  'SPEC_OPTS' => '--fail-fast', # saves time with rspec tasks
121
93
  }
122
94
  end
data/lib/gouteur/cli.rb CHANGED
@@ -1,9 +1,13 @@
1
+ require 'optparse'
2
+
1
3
  module Gouteur
2
4
  # command line interface - prints to stdout and returns true or false
3
5
  module CLI
4
6
  module_function
5
7
 
6
- def call(args = ARGV)
8
+ def call(argv = ARGV)
9
+ args = option_parser.parse!(argv)
10
+
7
11
  repos = pick_repos(args)
8
12
  if repos.empty?
9
13
  puts '', Message.no_repos, ''
@@ -11,16 +15,54 @@ module Gouteur
11
15
  end
12
16
 
13
17
  repos.all? do |repo|
14
- success, message = Gouteur::Checker.call(repo)
18
+ success, message = Gouteur::Checker.call(repo, force: !!@force)
15
19
  puts '', message, ''
16
20
  success
17
21
  end
18
22
  end
19
23
 
24
+ def option_parser
25
+ @force = false
26
+
27
+ OptionParser.new do |opts|
28
+ opts.banner = <<~SH
29
+ Usage: gouteur [repos] [options]
30
+
31
+ Examples:
32
+ gouteur https://github.com/me/my_repo
33
+ gouteur my_repo # my_repo must be listed in .gouteur.yml
34
+
35
+ SH
36
+
37
+ opts.separator 'Options:'
38
+
39
+ opts.on("-f", "--force", "Force tests, override version constraints") do
40
+ @force = true
41
+ end
42
+
43
+ opts.on("-v", "--version", "Show gouteur version") do
44
+ puts "gouteur #{Gouteur::VERSION}"
45
+ exit
46
+ end
47
+
48
+ opts.on("-h", "--help", "Show this help") do
49
+ puts opts
50
+ exit
51
+ end
52
+ end
53
+ end
54
+
20
55
  def pick_repos(args)
21
- repos = args.map { |arg| Gouteur::Repo.new(uri: arg) }
22
- repos = Dotfile.repos if repos.empty?
23
- repos
56
+ dotfile_repos = Dotfile.repos
57
+ return dotfile_repos if args.empty?
58
+
59
+ args.map do |arg|
60
+ if dotfile_repo = dotfile_repos.find { |r| r.name == arg }
61
+ dotfile_repo
62
+ else
63
+ Gouteur::Repo.new(uri: arg)
64
+ end
65
+ end
24
66
  end
25
67
  end
26
68
  end
@@ -0,0 +1,66 @@
1
+ module Gouteur
2
+ # Gemfile of a repository that depends on the library under test
3
+ class Gemfile
4
+ attr_reader :original_path
5
+
6
+ def initialize(original_path)
7
+ @original_path = original_path
8
+ end
9
+
10
+ def adapted_path
11
+ "#{original_path}.gouteur"
12
+ end
13
+
14
+ def content
15
+ File.exist?(original_path) ? File.read(original_path) : ''
16
+ end
17
+
18
+ def create_adapted(drop_version_constraint: false)
19
+ adapted_content = self.class.adapt(
20
+ content,
21
+ drop_version_constraint: drop_version_constraint,
22
+ )
23
+ File.open(adapted_path, 'w') { |f| f.puts(adapted_content) }
24
+ end
25
+
26
+ def self.adapt(content, drop_version_constraint: false)
27
+ new_entry = "gem '#{Host.name}', path: '#{Host.root}' # set by gouteur "
28
+
29
+ existing_ref_pattern =
30
+ /
31
+ ^\s*gem\W+#{Host.name}\W
32
+ (?<version>
33
+ \s*,\s*
34
+ (?:
35
+ #{VERSION_NUMBER_PATTERN}
36
+ |
37
+ \[(?:\s*#{VERSION_NUMBER_PATTERN}\s*,?\s*)+\]
38
+ )
39
+ )?
40
+ /x
41
+
42
+ return "#{content}\n#{new_entry}\n" unless content =~ existing_ref_pattern
43
+
44
+ content.gsub(existing_ref_pattern) do
45
+ if drop_version_constraint
46
+ new_entry
47
+ else
48
+ # keep version specification if there was one
49
+ new_entry.sub(/(?=, path:)/, Regexp.last_match[:version].to_s)
50
+ end
51
+ end
52
+ end
53
+
54
+ VERSION_NUMBER_PATTERN =
55
+ /
56
+ \d+\.\d+ # float
57
+ |
58
+ \d+ # int
59
+ |
60
+ (?:%[qQ]?)?
61
+ (?:
62
+ '[^']+'|"[^"]+"|\[[^\]]+\]|\{[^}]+\}|\([^)]+\)|<[^>]+>
63
+ ) # string literal
64
+ /x.freeze
65
+ end
66
+ end
@@ -14,7 +14,7 @@ module Gouteur
14
14
 
15
15
  def success(repo:)
16
16
  <<~MSG
17
- 👨‍🍳 #{random_word_for_tasty.capitalize}!
17
+ 👨‍🍳👍 #{random_word_for_tasty.capitalize}!
18
18
 
19
19
  Your changes to `#{Host.name}` are fine for `#{repo}`. All tasks succeeded.
20
20
  MSG
@@ -58,7 +58,7 @@ module Gouteur
58
58
 
59
59
  def broken_after_update(repo:, task:, output:, error:)
60
60
  <<~MSG
61
- 👨‍🍳 #{random_word_for_disgusting.capitalize}!
61
+ 👨‍🍳👎 #{random_word_for_disgusting.capitalize}!
62
62
 
63
63
  Task `#{task}` failed for `#{repo}` after inserting the new code of `#{Host.name}`.
64
64
 
@@ -75,6 +75,8 @@ module Gouteur
75
75
  The new version number of `#{Host.name}` is incompatible with the version requirements specified by `#{repo}`.
76
76
 
77
77
  Releasing incompatible versions is considered OK by default, so tasks will be SKIPPED in this case. If you want gouteur to FAIL in this case, set the `locked` flag.
78
+
79
+ Use the `force` flag to override this version constraint and run the tests anyway.
78
80
  MSG
79
81
  end
80
82
 
@@ -84,7 +86,7 @@ module Gouteur
84
86
 
85
87
  The new version number of `#{Host.name}` is incompatible with the version requirements specified by `#{repo}`.
86
88
 
87
- Incompatible version numbers can be allowed by removing the `locked` flag. This will make gouteur SKIP the tasks in this case.
89
+ Incompatible version numbers can be allowed by removing the `locked` flag. This will make gouteur SKIP the tasks in this case unless the `force` flag is set.
88
90
  MSG
89
91
  end
90
92
 
data/lib/gouteur/repo.rb CHANGED
@@ -3,20 +3,32 @@ require 'uri'
3
3
  module Gouteur
4
4
  # a repository of code that depends on the library under test
5
5
  class Repo
6
- attr_reader :uri, :name, :ref, :tasks
6
+ attr_reader :uri, :name, :ref, :tasks, :subdir
7
7
  alias to_s name
8
8
 
9
- def initialize(uri:, ref: nil, before: [], tasks: 'rake', locked: false)
10
- @uri = URI.parse(uri)
11
- @name = extract_name_from_uri(uri)
9
+ def initialize(
10
+ uri:,
11
+ name: nil,
12
+ ref: nil,
13
+ before: [],
14
+ tasks: 'rake',
15
+ locked: false,
16
+ force: false,
17
+ subdir: nil
18
+ )
19
+ @uri = uri
20
+ @name = name || extract_name_from_uri(uri)
12
21
  @ref = ref
13
22
  @before = Array(before)
14
23
  @tasks = Array(tasks)
15
24
  @locked = !!locked
25
+ @force = !!force
26
+ @subdir = subdir
16
27
  end
17
28
 
18
29
  def fetch
19
30
  cloned? ? pull : clone
31
+ validate_subdir if subdir
20
32
  end
21
33
 
22
34
  def prepare
@@ -31,16 +43,41 @@ module Gouteur
31
43
  File.join(store_dir, name)
32
44
  end
33
45
 
46
+ def bundle_path
47
+ subdir ? File.join(clone_path, subdir) : clone_path
48
+ end
49
+
34
50
  def bundle
35
- @bundle ||= Gouteur::Bundle.new(clone_path)
51
+ @bundle ||= Gouteur::Bundle.new(bundle_path)
52
+ end
53
+
54
+ def gemfile
55
+ @gemfile ||= Gouteur::Gemfile.new(bundle.gemfile_path)
36
56
  end
37
57
 
38
58
  def locked?
39
59
  @locked
40
60
  end
41
61
 
62
+ def force?
63
+ @force
64
+ end
65
+
66
+ def remove_host_from_gemspecs
67
+ Dir[File.join(bundle_path, '*.gemspec')].each do |gemspec_path|
68
+ content = File.read(gemspec_path)
69
+ new_content = content.gsub(/^.+_dependency.+\b#{Host.name}\b.+$/, '')
70
+ File.write(gemspec_path, new_content)
71
+ end
72
+ end
73
+
42
74
  private
43
75
 
76
+ def validate_subdir
77
+ File.directory?(bundle_path) ||
78
+ raise(Error, "subdirectory `#{subdir}` not found in `#{name}`")
79
+ end
80
+
44
81
  def extract_name_from_uri(uri)
45
82
  uri[%r{git(?:hub|lab)\.com/[^/]+/([^/]+)}, 1] ||
46
83
  uri.split('/').last.to_s[/[a-z0-9\-_]+/i] ||
@@ -1,3 +1,3 @@
1
1
  module Gouteur
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
data/lib/gouteur.rb CHANGED
@@ -4,6 +4,7 @@ require 'gouteur/bundle'
4
4
  require 'gouteur/checker'
5
5
  require 'gouteur/cli'
6
6
  require 'gouteur/dotfile'
7
+ require 'gouteur/gemfile'
7
8
  require 'gouteur/host'
8
9
  require 'gouteur/message'
9
10
  require 'gouteur/repo'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gouteur
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janosch Müller
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-09-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Run tests of dependent gems against your changes.
14
13
  email:
@@ -19,7 +18,6 @@ extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
20
  - ".github/workflows/build.yml"
22
- - ".github/workflows/lint.yml"
23
21
  - ".gitignore"
24
22
  - ".gouteur.yml"
25
23
  - ".rspec"
@@ -39,6 +37,7 @@ files:
39
37
  - lib/gouteur/checker.rb
40
38
  - lib/gouteur/cli.rb
41
39
  - lib/gouteur/dotfile.rb
40
+ - lib/gouteur/gemfile.rb
42
41
  - lib/gouteur/host.rb
43
42
  - lib/gouteur/message.rb
44
43
  - lib/gouteur/rake_task.rb
@@ -52,7 +51,6 @@ metadata:
52
51
  homepage_uri: https://github.com/jaynetics/gouteur
53
52
  source_code_uri: https://github.com/jaynetics/gouteur
54
53
  changelog_uri: https://github.com/jaynetics/gouteur/blob/master/CHANGELOG.md
55
- post_install_message:
56
54
  rdoc_options: []
57
55
  require_paths:
58
56
  - lib
@@ -67,8 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
65
  - !ruby/object:Gem::Version
68
66
  version: '0'
69
67
  requirements: []
70
- rubygems_version: 3.4.0.dev
71
- signing_key:
68
+ rubygems_version: 4.0.3
72
69
  specification_version: 4
73
70
  summary: See if your lib is still digestible.
74
71
  test_files: []
@@ -1,29 +0,0 @@
1
- # based on https://github.com/rails/rails/blob/4a78dcb/.github/workflows/rubocop.yml
2
-
3
- name: rubocop linting
4
-
5
- on: [push, pull_request]
6
-
7
- jobs:
8
- build:
9
- runs-on: ubuntu-latest
10
-
11
- steps:
12
- - uses: actions/checkout@v2
13
- - name: Set up Ruby
14
- uses: ruby/setup-ruby@v1
15
- with:
16
- ruby-version: 3.0
17
- - name: Cache gems
18
- uses: actions/cache@v1
19
- with:
20
- path: vendor/bundle
21
- key: ${{ runner.os }}-rubocop-${{ hashFiles('**/Gemfile.lock') }}
22
- restore-keys: |
23
- ${{ runner.os }}-rubocop-
24
- - name: Install gems
25
- run: |
26
- bundle config path vendor/bundle
27
- bundle install --jobs 4 --retry 3
28
- - name: Run rubocop
29
- run: bundle exec rubocop