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

Support the .orgzlyignore file in all repo types #224

Open
amberin opened this issue Apr 20, 2024 · 6 comments · May be fixed by #282
Open

Support the .orgzlyignore file in all repo types #224

amberin opened this issue Apr 20, 2024 · 6 comments · May be fixed by #282
Labels
enhancement New feature or request org-roam Affects support for org-roam usage

Comments

@amberin
Copy link
Member

amberin commented Apr 20, 2024

I am planning to add this as a first step towards #175.

The .orgzlyignore file is currently only supported in Git repos. It is parsed using the JGit library, so it uses the same syntax as a .gitignore file. I believe this should work well for all repo types.

@amberin
Copy link
Member Author

amberin commented May 28, 2024

I'm currently looking at supporting both an .orgzlyinclude and an .orgzlyexclude file, with the same syntax but opposite effects. The include file would take priority. This would solve #217 as well.

My experiments are going well, I just need to figure out the right way to structure the code to avoid messiness and brittleness.

@stfl
Copy link

stfl commented May 29, 2024

How about using the common syntax of .gitignore which allow to invert the ignore with !
When cloning a repo the ! in .orgzlyignore already works but does not work for updates yet.

You can probably parse the .orgzlyignore twice to once for ignore and once for includes to get to same semantice?!

Examples in #151 (comment) and #226

@amberin
Copy link
Member Author

amberin commented May 29, 2024

@stfl wrote:

How about using the common syntax of .gitignore which allow to invert the ignore with ! When cloning a repo the ! in .orgzlyignore already works but does not work for updates yet.

I'm glad you asked. I know that you can add exclusions in .gitignore and then make specific inclusions, but as I understand it, it's not really practical when you have nested directories, since you need to add "unexclude" rules on every level. I haven't used this myself, but I'm going by https://stackoverflow.com/a/5534865, and I concluded that this looks pretty tedious.

But if I'm wrong about that, it would of course be easier to stick with the current .orgzlyignore implementation. There should be no need to parse it multiple times.

(It's very possible that there are bugs in today's implementation - I haven't looked into it yet. But that's a separate issue.)

@chaoflow
Copy link

@amberin I like the simplicity of sticking with gitignore syntax, it is well-documented, there is an implementation, and people are most likely already familiar with it.

I'm not sure about the use cases. We're anyway looking only at org-files and non-org files are implicitly ignored, correct? So we are probably only looking at ignoring specific directories or file patterns?

An alternative could be something like python's MANIFEST.in (see the table with "Command" and "Description").

In which case I'd stick to exactly how they work and implicitly ignore any files that do not have an .org-suffix.

Ignore top-level attic folder:

global-include *.org
prune attic

Ignore all legacy files anywhere:

global-include *.org
global-exclude legacy-*

Only yop-level org-files and all anywhere in mobile folder:

include *.org
recursive-include mobile *.org

@amberin
Copy link
Member Author

amberin commented May 30, 2024

@chaoflow Interesting. I have no experience with the MANIFEST.in format, but it certainly sounds like a possibility.

I am now convinced that we should stick to a single .orgzlyignore file for now, implement it for all repo types, and then take another look at it if we get indications that many users are dissatisfied with the "mass exclude" possibilities that it offers. As @chaoflow said, only .org files are ever considered, and I now realize that it seems unlikely that people would have loads of different directory trees containing org files which they generally want to ignore, while loading multiple specific files many levels down.

@amberin
Copy link
Member Author

amberin commented May 31, 2024

I'm currently looking at supporting both an .orgzlyinclude and an .orgzlyexclude file, with the same syntax but opposite effects.

I realize this was not very clear. The idea was that both files would use the .gitignore format, but with opposite meanings. So no custom parser or syntax. But I've now dropped the idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request org-roam Affects support for org-roam usage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants