This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains an implementation of exclude patterns, where the user may specify certain packages )or folders) to exclude from vendoring. For the rationale behind this please see #54.
The exclusion pattern in the plain config file format is an import path with an dash (
-
) preceding it, so it's unambiguous and backwards compatible with the current mode of operation. In yaml format a newexclude
field is used which contains a list of paths to exclude. If an exclude pattern is present in the config file,trash
will first delete those from any vendored packages and only then proceed with theremoveUnusedImports
step, ensuring that anything that only excluded packages depended on is also removed.Beside the above feature, the PR contains two bugfixes:
Previously a
trash --update
overwrote any existing config file without retaining its original format (#46). This had the unfortunate side effect that an original yaml config file was swapped out with a flat conf type. A proposal to fix this was done in #50, but adding a new flag is a redundant operation since the code already knows what the original format was. This PR ensures that the original config file format (yaml or conf) is retained inside theConf
struct, allowing to serialize back to the same format on a dump.Another bug was that
trash
recreated a new config structure from scratch on update, overwriting the old struct before the package metadata (version, external repo) could be extracted, losing all such information. A proposal was opened in #51 to fix this, but it doesn't play nice with other internal/private fields in theConf
struct. This PR offers an alternative solution by not recreating the original config struct, just itsImports
field. This was all private metadata is preserved, including theimportMap
containing the import meta fields.