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

Ignore files #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

apmiller108
Copy link

Some editors produce temporary dotfiles for which it may not be desirable to watch. For example, Vim has swap files and Emacs has file locks. Some of these files may even cause problems for Sentry. For instance an Emacs file lock is symbolic link which causes Sentry to crash with:
Unable to get stat for './src/.#my_file.cr': No such file or directory (Errno) when attempting to get_timestamp (happened to me when doing Amber's Quick Start Guide). This PR address address both issues:

  • Check if File.exists?. Skip the scan if it does not.
  • Leverage the .sentry.yml to include an ingore key that can contain a list of patterns for files to ignore from the watched file paths.

* Leverages the .sentry.yml to add a list of patterns for files to
ignore from the watched file paths.  This can be useful for developers
whose editors produce temporary dotfiles (lock and/or autosave files)
for which it may not be desired to watch.
@samueleaton
Copy link
Owner

Hey sorry. been really busy recently. I'll set aside time to review this tonight or tomorrow.

@@ -81,7 +81,8 @@ if Sentry::Config.shard_name
build_args: config.build_args,
run_args: config.run_args,
should_build: config.should_build?,
files: config.watch
files: config.watch,
ignore_regexes: config.ignore
Copy link
Owner

Choose a reason for hiding this comment

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

I think ignore_regexes should just be ignore for the cli and the api.

- Skip caching timestamps for symbolic links by checking if
`File.exists?(file)`.  This resolves exception:
`Unable to get stat for './src/my_file.cr': No such file or directory (Errno)`

- Update API documentation with `ignore` reference
- rename `ignore_regexes` to `ignore`
@apmiller108
Copy link
Author

Yep, good call. I changed ignore_regexes to ignore.

# The list of patterns of files to ignore from the watched file paths.
ignore:
- /\.swp$/
- /^\.#/
Copy link
Owner

Choose a reason for hiding this comment

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

I'm sorry, what does the # do? I'm looking at the pattern reference and don't see a hash character. You either meant * or I got some learning to do.

Copy link
Owner

Choose a reason for hiding this comment

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

Since these are strings that we have to cast to regex, does that mean we have to add extra backslashes to everything (e.g. \\w, \\/)?

Copy link
Author

Choose a reason for hiding this comment

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

That example was inspired by the issue I was having with the emacs lock files. Those lock files take on the format, .#my_file.cr; So, that pattern filters them out (any file starting with .#). The example patterns here could be better I think 🤔.

Since we're reading in the sentry.yml with File.read, the escape backslashes are added automatically: \nignore:\n - /\\.swp$/\n - /^\\.#/\n".

@faultyserver
Copy link
Contributor

I've got a case now where this would really simplify my files entry since I want to avoid one subfolder in a directory with multiple folders.

Any chance this could get merged soon?

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