1
0
Fork 0
mirror of synced 2024-12-22 14:11:07 -05:00
Commit graph

22 commits

Author SHA1 Message Date
Kurt McKee
33f5390a62
Stop patches in the reverse order they were started
Because some functions are patched twice (like `os.rename()`),
stopping the patches in the same order they were started
can result in restoration of one of the patches.

For example:

```
fn = os.rename

# Patch nesting order: 1 then 2
os.rename = patch_1(fn)
os.rename = patch_2(patch_1(fn))

# Unpatch 1 then 2: A still-patched function is restored
os.rename = fn
os.rename = patch_1(fn)

# Unpatch 2 then 1: The original function is restored
os.rename = patch_1(fn)
os.rename = fn
```

Fixes #365
2024-12-18 08:31:31 -06:00
Anish Athalye
def05688c0 Make Dispatcher have all plugins by default
This used to be the behavior, and then
b5499c7dc5 changed this, breaking some
plugins (some of which subsequently implemented workarounds). This patch
restores the behavior, so that if a Dispatcher is constructed without
explicitly passing in plugins, it has access to all plugins.

This change seems safe, in that it's unlikely that any plugins were
relying on the behavior between b5499c7dc5
and this patch, where a Dispatcher without an explicit plugin list
behaved as if there were no plugins---because such a Dispatcher is not
very useful!
2024-12-08 18:15:08 -05:00
Anish Athalye
cef40c902e Fix issue with duplicate execution of plugins 2024-12-07 18:34:56 -05:00
Anish Athalye
8c2dc8cbc6 Make set of plugins available in context
This is useful for plugins like dotbot-if [1] that want to instantiate
their own Dispatcher. Previously, the Dispatcher found the set of
available plugins on its own, but as of
b5499c7dc5, this was changed so that
plugins are passed in.

Given that it has been over two years since this behavior has been
broken/changed, reverting to the previous behavior of having the
Dispatcher auto-load plugins might not be ideal, which is why this patch
instead makes the set of plugins available via the Context for plugins
to use.

This was reported in the Dotbot repository [2], and earlier in dotbot-if
[3]. dotbot-if is currently using a workaround [4] that was originally
implemented in dotbot-ifplatform [5].

[1]: https://github.com/wonderbeyond/dotbot-if
[2]: https://github.com/anishathalye/dotbot/issues/339
[3]: https://github.com/wonderbeyond/dotbot-if/issues/1
[4]: https://github.com/wonderbeyond/dotbot-if/pull/2
[5]: e35b5c0d71
2024-12-07 18:24:32 -05:00
Kurt McKee
eba0b24331
Resolve a Python 3.12 DeprecationWarning 2023-09-10 10:27:54 -05:00
Anish Athalye
81d4a434ef Drop support for Python 2 and Python < 3.6
This patch also deletes all of the compatibility code that we no longer
need.
2023-09-09 20:57:01 -04:00
Anish Athalye
416f32f5fe Fix globbing when there is a single match
See https://github.com/anishathalye/dotbot/issues/282 and
https://github.com/anishathalye/dotbot/issues/315.

This patch simplifies the implementation, removing special-case handling
for the cases of zero matches and one match. Instead, any situation
where `glob: true` is specified and the path contains a glob character
(any of "?", "*", or "[") is treated as a glob case. The reason we check
both `use_glob` and `_has_glob_chars()` is to more gracefully handle the
case where the user has enabled globs by default, but most links do not
contain glob characters and should not be treated as globs.
2023-07-09 16:24:13 -04:00
Anish Athalye
4daa065dc9 Allow empty glob
This is convenient and more flexible. See
https://github.com/anishathalye/dotbot/issues/284.
2023-07-09 16:20:27 -04:00
Kurt McKee
e0c78d9c56
Resolve merge conflicts
Note that this does NOT port the following command over:

```shell
git config --global protocol.file.allow always
```

Doing so would change the git configuration of users running
the unit tests locally, and this is not an acceptable outcome.
Instead, the git configuration is modified at the CLI using
the `-c protocol.file.allow=always` argument to accomplish
the same thing without side effects.
2022-12-16 13:52:33 -06:00
Kurt McKee
59b1b85d07 Account for MacOS and Windows temp directory issues 2022-05-18 06:37:48 -05:00
Kurt McKee
5c0ddc6fc1 Migrate the bin/dotbot script test to Python 2022-05-13 10:44:29 -05:00
Kurt McKee
74aca02157 Migrate the shim test to Python 2022-05-13 10:44:29 -05:00
Kurt McKee
1ff796a9dc Enforce platform-specific CPython version requirements for Windows in tox
This also changes the black and isort tests to use CPython 3.9
because Cygwin currently doesn't have CPython 3.10 available.
2022-05-13 10:44:29 -05:00
Kurt McKee
ea98e5eafc Add isort as a tox environment, and run it 2022-05-13 10:44:29 -05:00
Kurt McKee
566ba0b853 Add black as tox environment, and run it 2022-05-13 10:44:29 -05:00
Kurt McKee
a8dd89f48f Migrate CLI argument tests to Python 2022-05-13 10:44:29 -05:00
Kurt McKee
68246ba33e Migrate shell-* tests to Python 2022-05-13 10:44:29 -05:00
Kurt McKee
b8dfbae730 Migrate config-* tests to Python 2022-05-13 10:44:29 -05:00
Kurt McKee
5b7db08e8a Migrate clean-* tests to Python 2022-05-13 10:44:29 -05:00
Kurt McKee
b59b3af448 Migrate create-* tests to Python 2022-05-13 10:44:29 -05:00
Kurt McKee
4469b857aa Migrate link-* tests to Python 2022-05-13 10:44:29 -05:00
Kurt McKee
c015f7bce8 Add a test framework for all supported Python versions 2022-05-13 10:44:29 -05:00