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 restore of multiple asset manifests on rollback #226

Merged
merged 5 commits into from
May 11, 2020

Conversation

lennart
Copy link
Contributor

@lennart lennart commented Oct 15, 2018

Handle multiple manifest files gracefully.

Related to #123 this PR will fix issues with multiple sprockets asset manifest files lying around in #{shared_path}/public/assets/ and #{release_path}/assets_manifest_backup on cap <stage> deploy:rollback.

Currently this will fail due to multiple filepaths being interpolated into a single shell if condition:

if test "[[ -f #{source} && -f #{target} ]]"

see https://github.com/capistrano/rails/blob/master/lib/capistrano/tasks/assets.rake#L93 and #204 (comment)

To deal with this restore_manifest will explicitly copy each of these files in a separate cp command.

Feedback on how to improve this PR is very welcome!

@capistrano-bot
Copy link

1 Warning
⚠️ Please update CHANGELOG.md with a description of your changes. If this PR is not a user-facing change (e.g. just refactoring), you can disregard this.

Thanks for the PR! This project lacks automated tests, which makes reviewing and approving PRs somewhat difficult. Please make sure that your contribution has not broken backwards compatibility or introduced any risky changes.

Here's an example of a CHANGELOG.md entry (place it immediately under the * Your contribution here! line):

* [#226](https://github.com/capistrano/rails/pull/226): handle restore of multiple asset manifests on rollback - [@lennart](https://github.com/lennart)

Generated by 🚫 Danger

@lennart
Copy link
Contributor Author

lennart commented Aug 5, 2019

since this is neither a user-facing change nor can I see how to "test" this (apart from using this, and it seems to work).

is it possible to merge this pr?

Copy link
Member

@mattbrictson mattbrictson left a comment

Choose a reason for hiding this comment

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

Hi, thanks for the PR and sorry for the lack of a timely response.

The reason this is a hard PR for me to review is that even though I am a maintainer, I do not use the "rollback" feature of Capistrano. That makes it hard for me to intuitively judge if this change is needed and whether it works as intended.

That said, your explanation of why -f fails makes sense, and your code is easy to follow. Thanks for that!

Before I merge, could you post output of a cap rollback that demonstrates this code working? I don't have a means of testing it at the moment.

lib/capistrano/tasks/assets.rake Outdated Show resolved Hide resolved
lib/capistrano/tasks/assets.rake Outdated Show resolved Hide resolved
@lennart
Copy link
Contributor Author

lennart commented Mar 27, 2020

@mattbrictson I resolved the issues you had in code and made a demo-run of deploy and rollback handling multiple-manifest files without breakage, see:

https://gist.github.com/lennart/d2eab716d5b589da869a7c6f86ec6cc2

@lennart
Copy link
Contributor Author

lennart commented Mar 27, 2020

um, when I take a look at this now, I realize there's a bug. targets and sources are mixed up... I'll fix this

@lennart
Copy link
Contributor Author

lennart commented Mar 27, 2020

ok, so now, starting at: https://gist.github.com/lennart/d2eab716d5b589da869a7c6f86ec6cc2#file-capistrano-deploy-and-rollback-log-L511

it lists the files in the assets_manifest_backup folder and then restores all backed-up manifests to public/assets/

@lennart lennart requested a review from mattbrictson May 5, 2020 07:59
Copy link
Member

@mattbrictson mattbrictson left a comment

Choose a reason for hiding this comment

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

This looks good. Thanks for your patience and for following up!

I have one more small change to request before merging this. Let me know what you think.

lib/capistrano/tasks/assets.rake Outdated Show resolved Hide resolved
Co-authored-by: Matt Brictson <mattbrictson@users.noreply.github.com>
@lennart
Copy link
Contributor Author

lennart commented May 11, 2020

@mattbrictson sounds good, I accepted your suggestion!

@mattbrictson mattbrictson merged commit d86a8db into capistrano:master May 11, 2020
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