Commit graph

67488 commits

Author SHA1 Message Date
David Rodríguez
41240ffee3 [rubygems/rubygems] Remove unused require
2ee3e78a7a
2021-08-31 19:06:14 +09:00
Keiko Kaneko
e841042070 [rubygems/rubygems] Add missing key branches:
ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags

Running jobs with only branch name, without `branches:`, CI fails

fcec167d61
2021-08-31 19:06:14 +09:00
Daniel Niknam
ceba866864 [rubygems/rubygems] Remove unnecessary tests
We will be passing string to this class so there is no need to be defensive about it.

30bd52a977
2021-08-31 19:06:14 +09:00
Daniel Niknam
1948ac20ce [rubygems/rubygems] Replacing clone with dup
30f5b3c027
2021-08-31 19:06:14 +09:00
Daniel Niknam
4715bbf7b3 [rubygems/rubygems] Remove returning self for Gem::PrintableUri#parse_uri
25c99d7f9d
2021-08-31 19:06:14 +09:00
Daniel Niknam
aa898b4206 [rubygems/rubygems] Remove @credential_redacted instance variable
c3bb52eb5c
2021-08-31 19:06:14 +09:00
Daniel Niknam
7067005f23 [rubygems/rubygems] Bring back the empty line that was removed previously by mistake
ffb480ca7a
2021-08-31 19:06:14 +09:00
Daniel Niknam
d73dc8e937 [rubygems/rubygems] Remove unused method
3a8486794e
2021-08-31 19:06:14 +09:00
Daniel Niknam
6d883b33ae [rubygems/rubygems] Remove ruby/uri requirement
For the purpose of this class, we need to make sure the return object by `Gem::UriParser.parse_uri` method will have the following method:
- user
- user=
- password
- password=
So we  can remove the the `uri` dependency and just look for the methods to exist.

241e093597
2021-08-31 19:06:14 +09:00
Daniel Niknam
589377fbdc [rubygems/rubygems] Refactor Gem::RemoteFetcher::FetchError.build back to its initialize method
21dcdd2dc5
2021-08-31 19:06:14 +09:00
Daniel Niknam
a508693f06 [rubygems/rubygems] Remove defensive guards
dba130cd80
2021-08-31 19:06:14 +09:00
Daniel Niknam
fafd9d280a [rubygems/rubygems] Rename Gem::PrintableUri#parsed_uri? to Gem::PrintableUri#valid_uri?
a5177709c9
2021-08-31 19:06:14 +09:00
Daniel Niknam
e3c319ad53 [rubygems/rubygems] Remove trailing if
5b6b649bba
2021-08-31 19:06:14 +09:00
Daniel Niknam
3adc141a79 [rubygems/rubygems] Refactor Gem::RemoteFetcher::FetchError initializer to build method
The `initialize` method is already doing a lot and by adding the `Gem::PrintableUri` to redact sensitive information, things are getting complicated and hard to read here. For the start, I have refactored the `initialize` method into a class method called `build`.

4312e8fdf5
2021-08-31 19:06:14 +09:00
Daniel Niknam
19e1d3cdce [rubygems/rubygems] Using Gem::PrintableUri in Gem::Request class
The `@uri` variable could be a source URI with a credential. Using `Gem::PrintableUri` to make sure we are redacting sensitive information from it when logging on verbose mode.

f566787211
2021-08-31 19:06:14 +09:00
Daniel Niknam
31c2e6c08e [rubygems/rubygems] Using Gem::PrintableUri in Gem::Commands::InstallCommand class
The `x.source.uri` could be a source URI with a credential. Using `Gem::PrintableUri` to make sure we are redacting sensitive information from it.

8755ee0aaa
2021-08-31 19:06:14 +09:00
Daniel Niknam
b41802421a [rubygems/rubygems] Introduce Gem::PrintableUri that would redact URIs to be used on outputs
We need to redact URI credential in several places and copy pasting the code into each part of it is not ideal. This class is responsible for parsing URI strings and redacting credential from it. Also, it will handle URI object in the same manner. We will be reusing this class whenever we need to print/display a URI to users.
URI with the following format will be redacted:
- Token: `http://my-secure-token@example.com` => `http://REDACTED@example.com`
- Username & Password: `http://my-username:my-secure-password@example.com` => `http://my-username:REDACTED@example.com`
- x-oauth-basic: `http://my-secure-token:x-oauth-basic@example.com` => `http://REDACTED:x-oauth-basic@example.com`

f1e45d3a89
2021-08-31 19:06:14 +09:00
Daniel Niknam
14a9e24f7e [rubygems/rubygems] Add a few tests for Gem::UriParser.parse_uri
1ea73df161
2021-08-31 19:06:14 +09:00
Matt Larraz
5f205073d2 [rubygems/rubygems] Pass second argument to Array#split to ensure only two values returned
601b5553bb
2021-08-31 19:06:14 +09:00
David Rodríguez
c119dd2b5a [rubygems/rubygems] Fix bundle plugin install misdetection of installed versions
9c88db949d
2021-08-31 19:06:14 +09:00
David Rodríguez
c044f818ca [rubygems/rubygems] Move Bundler.rubygems.clear_paths to a better place
Since it clears both home and path.

fadf5e03ea
2021-08-31 19:06:14 +09:00
David Rodríguez
8c79486e7e [rubygems/rubygems] Bundle path is already expanded
a296052670
2021-08-31 19:06:14 +09:00
David Rodríguez
71b937d3d7 [rubygems/rubygems] Normalize setting GEM_PATH
4188ebd568
2021-08-31 19:06:14 +09:00
David Rodríguez
d0da3a2a7f [rubygems/rubygems] Remove more unused code
986e889a79
2021-08-31 19:06:14 +09:00
David Rodríguez
8d32f46d04 [rubygems/rubygems] Remove unnecessary line
a7023c6c21
2021-08-31 19:06:14 +09:00
David Rodríguez
f934096638 [rubygems/rubygems] Make plugin installation idempotent
The error had not be caught be specs because `bundle install` was
returning a zero exit code when plugin installation errors happened. So
I fixed that issue too.

90cde87856
2021-08-31 19:06:14 +09:00
David Rodríguez
3a9dd795a7 [rubygems/rubygems] Move some logic to a save_plugin method
9620bee2a5
2021-08-31 19:06:14 +09:00
Matt Larraz
2aed061384 [rubygems/rubygems] Correctly redact credentials when using x-oauth-basic
290b6ab078
2021-08-31 19:06:14 +09:00
Daniel Niknam
f212b9d4f2 [rubygems/rubygems] Refactor Ruby platform priority condition to its own method
The `Gem::Platform::RUBY ? -1 : 1` has been used multiple times in different places and could be refactored to a method (DRY).

9d43ca8f0c
2021-08-31 19:06:14 +09:00
Daniel Niknam
c71d1a26ef [rubygems/rubygems] Pick the last founded gems when fetching metadata
e3d150d822

Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
2021-08-31 19:06:14 +09:00
David Rodríguez
54ae3f587e [rubygems/rubygems] Prefer require_relative to require for internal requires
c74fc58695
2021-08-31 19:06:14 +09:00
David Rodríguez
f6803d2411 [rubygems/rubygems] Fix bundle check showing duplicated gems
If the lockfile contains multiple platforms, `bundle check` would show
duplicated missing gems.

6ac5931783
2021-08-31 19:06:14 +09:00
David Rodríguez
e70419d608 [rubygems/rubygems] Explicitly set allow_cached to false when setting local mode
1b8139e9d3
2021-08-31 19:06:14 +09:00
David Rodríguez
3683781f53 [rubygems/rubygems] Restore working bundle check behaviour
As part of a recent bug fix where bundler was accidentally hitting the
network when not supposed to, I made some refactoring, and the commit I'm
reverting here
(d74830d00b)
was some cleanup that those refactorings allowed according to "past me".

That was completely wrong, `bundle check` should never consider cached
gems, only installed gems, so the code that was removed was necessary.

5483e98305
2021-08-31 19:06:14 +09:00
Jun Aruga
71f6711351 [rubygems/rubygems] Fix some failing Bundler tests with old Git.
Use the `git branch --list` rather than the `git branch -l` for better
compatibility. Because the `git branch -l` is used to create a new branch in
Git version < 2.20.0.

eac5be7d06
2021-08-31 19:06:14 +09:00
David Rodríguez
907fa88a76 [rubygems/rubygems] Remove unused file
No longer used since
b7f6270b9e.

76803894a0
2021-08-31 19:06:14 +09:00
David Rodríguez
590d2222a0 [rubygems/rubygems] Remove helper method not buying us much
81dc685d20
2021-08-31 19:06:14 +09:00
David Rodríguez
d01c3111c2 [rubygems/rubygems] Remove MacOS specific extra GEM_PATH
They should properly configure `GEM_PATH` instead.

3bd9ae33ca
2021-08-31 19:06:14 +09:00
David Rodríguez
afabef5a5a [rubygems/rubygems] Remove MacOS specific gem layout
MacOS should properly configure Ruby. They should not expect us to
maintain a different layout just for them.

ecad900925
2021-08-31 19:06:14 +09:00
Daniel Niknam
717ad64f41 [rubygems/rubygems] Replace StandardError with Exception
We think it's unlikely that `rubygems/defaults/operating_system` could be shipped with a SyntaxError so StandardError could be better choice to prevent "false positives" errors.

1f73e784dd
2021-08-31 19:06:14 +09:00
Daniel Niknam
34e073c0ca [rubygems/rubygems] Reword the message
For errors that could happened while loading `rubygems/defaults/operating_system`

6e1e2141f8
2021-08-31 19:06:14 +09:00
David Rodríguez
7d859489e1 [rubygems/rubygems] Bring --jobs documentation up to date
58da501e5d
2021-08-31 19:06:14 +09:00
David Rodríguez
890b261154 [rubygems/rubygems] See if parallel installation on Windows works better now
0822e1c260
2021-08-31 19:06:14 +09:00
Daniel Niknam
744e128ed9 [rubygems/rubygems] Exclude truffleruby from the test for failure of operating_system.rb
truffleruby does not raise any error when requiring `rubygems`.

21e2fcd0b2
2021-08-31 19:06:14 +09:00
Daniel Niknam
aafc615b4a [rubygems/rubygems] Enhance error handling when loading the rubygems/defaults/operating_system file
When loading `rubygems/defaults/operating_system`
- we want to keep it silent if the raised exception is a LoadError
- we want to print a message in other cases and ask users to report the issue to their OS support.

Ruby 3 comes with special error handling for loading `rubygems` and it will show a warning when LoadError exception raised for requiring 'rubygem'.
Because of that, we decided to leave the LoadError scenario as it is.
Reference: d1998d8767/gem_prelude.rb (L1-L5)

0a97e12fe1
2021-08-31 19:06:14 +09:00
David Rodríguez
9fa5c4cd07 [rubygems/rubygems] Also load user installed rubygems plugins
82960c262f
2021-08-31 19:06:14 +09:00
David Rodríguez
21db5876ca [rubygems/rubygems] Respect BUNDLE_USER_HOME for global config location
58fc31442f
2021-08-31 19:06:14 +09:00
David Rodríguez
ea16a0df80 [rubygems/rubygems] Disable RUBYGEMS_GEMDEPS for bundler spec run
Running `bundler` specs using `bundler` is not supported.

cc97b6773d
2021-08-31 19:06:14 +09:00
David Rodríguez
5aee962fe3 [rubygems/rubygems] Remove RUBYGEMS_GEMDEPS warning
When setting the `RUBYGEMS_GEMDEPS` environment variable to allow
skipping `bundle exec`, `bundler` will print a warning about potential
incompatibility.

Initially the `RUBYGEMS_GEMDEPS` variable used a completely different
(re)implementation of `bundler` functionality. That implementation was
not battle tested and could potentially differ in behaviour from what
`bundler` does. That's why print a warning.

However, these days, all `rubygems` does when `RUBYGEMS_GEMDEPS` is set
is to require `bundler/setup`, so there's no risk of any
incompatibility, since that's just plain `bundler`.

bbddc27016
2021-08-31 19:06:14 +09:00
David Rodríguez
ab1edc75f8 [rubygems/rubygems] Expect the right permissions on Windows
Given Windows doesn't have executable bit.

35dc3fa845
2021-08-31 19:06:14 +09:00