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 .gitignore syntax in sync section and make sure it works recursively #854

Merged
merged 4 commits into from
Oct 10, 2023

Conversation

andrewnester
Copy link
Contributor

Fixes #815

libs/fileset/glob.go Outdated Show resolved Hide resolved
}

func (i *includer) IgnoreDirectory(path string) (bool, error) {
return false, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

To match .gitignore syntax, this needs to do the same as in libs/git/view.go.

If someone specifies foo/bar/ (note the trailing /), it only matches the directory bar and not a file bar. The file system walker will then also skip walking the directory entirely, which can save a bunch of time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If someone specifies foo/bar/ (note the trailing /), it only matches the directory bar and not a file bar. The file system walker will then also skip walking the directory entirely, which can save a bunch of time.

It indeed make sense for ignore logic. But for the include, the logic seems to be inversed: for the pattern foo/bar/ we still need to look into the directory for file matches and can't really skip the dir altogether if there is no match, for example if we specify pattern like foo/bar/*.go. This pattern does not match directory but matches all the files inside of it.

Or when we traverse the tree, we will try to call IgnoreDirectory on ".", "./foo", "./foo/bar" but use the pattern foo/bar/*.go. We need to make the matcher code more complex like generate different prefix patterns to be able to exclude code from traversing.

Indeed, in this case lower complexity comes at the cost of performance

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, yeah this makes sense. Could you include this explanation in the code as well?

This is specific to the glob set and the fact that we use it both for includes as well as excludes.

@andrewnester andrewnester requested a review from pietern October 9, 2023 17:28
@andrewnester andrewnester added this pull request to the merge queue Oct 10, 2023
Merged via the queue into main with commit 8c1441f Oct 10, 2023
@andrewnester andrewnester deleted the sync-recursiveley branch October 10, 2023 08:52
andrewnester added a commit that referenced this pull request Oct 11, 2023
CLI:
 * Improve `workspace import` command by allowing references to local files for content ([#793](#793)).
 * Add `--file` flag to workspace export command ([#794](#794)).
 * Ensure profile flag is respected for sync command ([#837](#837)).
 * Add hint to delete sync snapshot if parsing fails ([#853](#853)).
 * Use profile information when getting a token using the CLI ([#855](#855)).

Bundles:
 * Minor template tweaks ([#832](#832)).
 * Fixed using repo files as pipeline libraries ([#847](#847)).
 * Support .gitignore syntax in sync section and make sure it works recursively ([#854](#854)).
 * Allow target overrides for sync section ([#856](#856)).

Internal:
 * Fix import export integration tests on windows ([#842](#842)).
 * Fix workspace import test ([#844](#844)).
 * Automatically create a release PR in homebrew-tap repo ([#841](#841)).

Dependency updates:
 * Bump golang.org/x/term from 0.12.0 to 0.13.0 ([#852](#852)).
 * Bump golang.org/x/mod from 0.12.0 to 0.13.0 ([#851](#851)).
 * Bump golang.org/x/sync from 0.3.0 to 0.4.0 ([#849](#849)).
 * Bump golang.org/x/oauth2 from 0.12.0 to 0.13.0 ([#850](#850)).
@andrewnester andrewnester mentioned this pull request Oct 11, 2023
github-merge-queue bot pushed a commit that referenced this pull request Oct 11, 2023
CLI:
* Improve `workspace import` command by allowing references to local
files for content ([#793](#793)).
* Add `--file` flag to workspace export command
([#794](#794)).
* Ensure profile flag is respected for sync command
([#837](#837)).
* Add hint to delete sync snapshot if parsing fails
([#853](#853)).
* Use profile information when getting a token using the CLI
([#855](#855)).

Bundles:
* Minor template tweaks
([#832](#832)).
* Fixed using repo files as pipeline libraries
([#847](#847)).
* Support .gitignore syntax in sync section and make sure it works
recursively ([#854](#854)).
* Allow target overrides for sync section
([#856](#856)).

Internal:
* Fix import export integration tests on windows
([#842](#842)).
* Fix workspace import test
([#844](#844)).
* Automatically create a release PR in homebrew-tap repo
([#841](#841)).


Dependency updates:
* Bump golang.org/x/term from 0.12.0 to 0.13.0
([#852](#852)).
* Bump golang.org/x/mod from 0.12.0 to 0.13.0
([#851](#851)).
* Bump golang.org/x/sync from 0.3.0 to 0.4.0
([#849](#849)).
* Bump golang.org/x/oauth2 from 0.12.0 to 0.13.0
([#850](#850)).
hectorcast-db pushed a commit that referenced this pull request Oct 13, 2023
CLI:
* Improve `workspace import` command by allowing references to local
files for content ([#793](#793)).
* Add `--file` flag to workspace export command
([#794](#794)).
* Ensure profile flag is respected for sync command
([#837](#837)).
* Add hint to delete sync snapshot if parsing fails
([#853](#853)).
* Use profile information when getting a token using the CLI
([#855](#855)).

Bundles:
* Minor template tweaks
([#832](#832)).
* Fixed using repo files as pipeline libraries
([#847](#847)).
* Support .gitignore syntax in sync section and make sure it works
recursively ([#854](#854)).
* Allow target overrides for sync section
([#856](#856)).

Internal:
* Fix import export integration tests on windows
([#842](#842)).
* Fix workspace import test
([#844](#844)).
* Automatically create a release PR in homebrew-tap repo
([#841](#841)).


Dependency updates:
* Bump golang.org/x/term from 0.12.0 to 0.13.0
([#852](#852)).
* Bump golang.org/x/mod from 0.12.0 to 0.13.0
([#851](#851)).
* Bump golang.org/x/sync from 0.3.0 to 0.4.0
([#849](#849)).
* Bump golang.org/x/oauth2 from 0.12.0 to 0.13.0
([#850](#850)).
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.

Asset Bundles Sync Exclude/Include Recursive
2 participants