Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle BUNDLED WITH deletion in windows #1108

Merged
merged 1 commit into from
Jan 15, 2021

Conversation

schneems
Copy link
Contributor

Windows Gemfile.lock uses \r\n instead of \n for newlines which can cause issues when matching regex. We are using regex to strip out BUNDLED WITH and were not previously handling windows Gemfile.lock by mistake.

There is other code that reads in the major version of BUNDLED WITH and it uses a read mode of rt which solves the problem.

The solution is to change this other location to also use a read mode of rt:

irb(main):009:0> !!File.read("./spec/fixtures/windows_lockfile/Gemfile.lock").match(/^BUNDLED WITH$(\r?\n)   (?<major>\d+)\.\d+\.\d+/m)
=> false
irb(main):010:0> !!File.read("./spec/fixtures/windows_lockfile/Gemfile.lock", mode: 'rt').match(/^BUNDLED WITH$(\r?\n)   (?<major>\d+)\.\d+
\.\d+/m)
=> true

The test now also assert the desired behavior of removing BUNDLED WITH occurs.

@schneems schneems requested a review from a team as a code owner January 14, 2021 18:10
Copy link
Member

@edmorley edmorley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot! :-)

@schneems
Copy link
Contributor Author

Related ticket https://heroku.support/950520

@schneems
Copy link
Contributor Author

Default stack bump made some tests fail, I'll fix that in another PR and rebase when done.

Windows Gemfile.lock uses `\r\n` instead of `\n` for newlines which can cause issues when matching regex. We are using regex to strip out BUNDLED WITH and were not previously handling windows Gemfile.lock by mistake.

There is other code that reads in the major version of BUNDLED WITH and it uses a read mode of `rt` which solves the problem.

The solution is to change this other location to also use a read mode of `rt`:

```
irb(main):009:0> !!File.read("./spec/fixtures/windows_lockfile/Gemfile.lock").match(/^BUNDLED WITH$(\r?\n)   (?<major>\d+)\.\d+\.\d+/m)
=> false
irb(main):010:0> !!File.read("./spec/fixtures/windows_lockfile/Gemfile.lock", mode: 'rt').match(/^BUNDLED WITH$(\r?\n)   (?<major>\d+)\.\d+
\.\d+/m)
=> true
```

The test now also assert the desired behavior of removing BUNDLED WITH occurs.
@schneems schneems force-pushed the schneems/handle-windows-gemfilelock branch from 0ed9058 to e99732c Compare January 15, 2021 15:42
@schneems schneems merged commit 60b5586 into main Jan 15, 2021
@schneems schneems deleted the schneems/handle-windows-gemfilelock branch January 15, 2021 15:58
@raldred
Copy link

raldred commented Jan 15, 2021

Awesome thanks for getting this sorted @schneems

@schneems
Copy link
Contributor Author

Happy to help. I'll let this sit on main for a few days to test for stability. I'll likely aim to deploy next week Wednesday or Thursday, but that could slip based on other workloads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants