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

Bug: wrong common origin for buildroot package #264

Closed
Mephistophiles opened this issue Mar 15, 2022 · 2 comments
Closed

Bug: wrong common origin for buildroot package #264

Mephistophiles opened this issue Mar 15, 2022 · 2 comments
Labels
has workaround Bug has a workaround, so it might not need urgent attention not a bug Might actually be a feature, or a non-bug issue
Milestone

Comments

@Mephistophiles
Copy link

Wrong common origin for buildroot package (sub repository):

$ exa -laT /tmp/main_repo/
drwxr-xr-x    - mzhukov 15 Mar 11:44 /tmp/main_repo
drwxr-xr-x    - mzhukov 15 Mar 11:43 ├── .git
.rw-r--r--    8 mzhukov 15 Mar 11:44 ├── .gitignore
drwxr-xr-x    - mzhukov 15 Mar 11:44 └── output
drwxr-xr-x    - mzhukov 15 Mar 11:44    └── subrepo
drwxr-xr-x    - mzhukov 15 Mar 11:44       ├── .git
.rw-r--r--    5 mzhukov 15 Mar 11:44       └── test.c

$ cat /tmp/main_repo/.gitignore
/output

If I try to watch test.c, watchexec determines the wrong common origin (watchexec always follows to top git repository, but the top repository can contain .gitignore with sub-repo path (as in my case)):

subrepo $ watchexec -v -w test.c 'echo 1'
2022-03-15T08:47:19.645143Z DEBUG watchexec::filterer::common: resolved all project origins origins={"/tmp/main_repo/output/subrepo", "/tmp/main_re
po"}
2022-03-15T08:47:19.645159Z DEBUG watchexec::filterer::common: resolved common/project origin project_origin="/tmp/main_repo"
  • watchexec 1.18.7
  • Archlinux
  • watchexec.log
  • subrepo $ watchexec -v -w test.c 'echo 1'
@Mephistophiles Mephistophiles added the bug Something's not right! label Mar 15, 2022
@passcod
Copy link
Member

passcod commented Mar 15, 2022

Hmm, that's a bit tricky. I would say the current situation is correct. It's correctly finding your project origin, that's just not what you wanted here. In 1.19 there'll be a new --project-origin flag to help with this situation.

Unfortunately, until that lands, there's no easy way to avoid this. You can use --no-vcs-ignore or --no-project-ignore to avoid loading that root (and others) ignore file.

Also note you should be doing this:

watchexec -w . -f test.c ...

Doing this automatically is covered by #190.

Also helpful would be CLI negative ignores, covered in #166. Negative ignores in ignore files do function, but don't help in this particular case.


However! you can exploit a current bug to do what you want, which is that using -w or not yields slightly different behaviour:

  • watchexec -w . ... or watchexec -w test.c ...: project_origin = main_repo
  • watchexec ... (without -w): project_origin = subrepo

This is a bug, but I'll fix it in 1.19 so that it coincides with the introduction of --project-origin ;)

@passcod passcod added not a bug Might actually be a feature, or a non-bug issue has workaround Bug has a workaround, so it might not need urgent attention and removed bug Something's not right! labels Mar 15, 2022
@passcod passcod added this to the 1.18 issues milestone Mar 15, 2022
@Mephistophiles
Copy link
Author

Thanks for the detailed answer! watchexec -w . -f test.c ... works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has workaround Bug has a workaround, so it might not need urgent attention not a bug Might actually be a feature, or a non-bug issue
Projects
None yet
Development

No branches or pull requests

2 participants