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

Add ANNOTATERB_SKIP_ON_DB_TASKS ENV var to skip auto annotations #40

Merged
merged 4 commits into from
Jun 10, 2023

Conversation

drwl
Copy link
Owner

@drwl drwl commented Jun 10, 2023

In the old annotate gem, it used to be possible set ANNOTATE_SKIP_ON_DB_MIGRATE to true|t|yes|y|1 to skip the automatic annotation that happens after a Rails db task is run (e.g. bin/rails db:migrate). Note that the automatic annotation would only happen if a user installed the rails plugin (done via rails g annotate_rb:install).

This behavior got removed when the dependency on ENV was removed. After some feedback, it seems like it's worth adding back to support special development setups or for checks in a CI pipeline.

Note: if you want the updated rake task, you'll have to rerun rails g annotate_rb:install.

@drwl drwl merged commit 8add22e into main Jun 10, 2023
@drwl drwl deleted the drwl/add-back-env-skip branch June 10, 2023 21:46
# This rake task was added by annotate_rb gem.

# Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this
if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"].nil?
Copy link
Contributor

@Maimer Maimer Jun 11, 2023

Choose a reason for hiding this comment

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

Minor: but I might have gone with:

if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"]

This is because you could set this environment variable to false and it would skip annotations, but probably not that big of a deal.

Copy link
Owner Author

@drwl drwl Jun 11, 2023

Choose a reason for hiding this comment

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

I don't know if it's shell/environment specific but I think any values are interpreted as strings and not parsed.

# $ A_STRING=false pry

[1] pry(main)> ENV['A_STRING']
=> "false"

This using zsh on a M1 mac.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true, I guess that makes my comment not as relevant. (Also realized I had the boolean logic backwards and had included a !)

Copy link
Owner Author

Choose a reason for hiding this comment

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

No worries. I wasn't sure how ENV behaved, so when I first read your comment I thought this could be changed as well.

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.

2 participants