mirror of
1
0
Fork 0
Commit Graph

95 Commits

Author SHA1 Message Date
Anish Athalye 840cd164d2 Release 1.20.1 2023-09-10 10:37:02 -04:00
Anish Athalye 7a24ded5a6 Release 1.20.0 2023-09-09 21:03:40 -04: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 b04a3f1844 Release 1.19.2 2023-07-09 16:28:06 -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
Anish Athalye ed60c62432 Improve output of '--version' 2023-07-09 15:26:46 -04:00
Anish Athalye da928a4c6b Release 1.19.1 2022-12-17 15:13:48 -05: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
Arbaaz Shafiq 76ccc53eee Don't show command if quiet: true
Don't print the command if quiet option is set to true and no
description is given.
2022-11-17 13:23:23 -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 b5499c7dc5 Separate module importing from plugin identification
This change allows the test framework to reliably specify
which plugins to load and use within the same process.

Previously, plugins were loaded by importing files and then
accessing the Plugin class' list of subclasses.
Now, it's possible to run dotbot multiple times without
plugins accruing across runs with different configurations
and CLI arguments.

In addition, this fixes some circular imports that were
previously avoided because plugins were imported in a function.
2022-05-13 10:44:29 -05:00
Kurt McKee a2846d0a61 Resolve Windows-specific clean issues 2022-05-13 10:44:29 -05:00
Kurt McKee 5d11c7954d Resolve Windows-specific create issues 2022-05-13 10:44:29 -05:00
Kurt McKee 78bec43e33 Resolve Windows-specific link issues 2022-05-13 10:44:29 -05:00
Anish Athalye 769767c129 Migrate code style to Black 2022-01-30 18:53:05 -05:00
Subho Banerjee 4d2e1537f4
adding a exit on failure flag 2021-09-12 19:34:44 -05:00
Anish Athalye 076939da8e Remove stray asterisk 2021-06-02 20:23:55 -04:00
Anish Athalye 24f88c4584 Merge branch 'eengstrom/259-link-prefix' 2021-06-02 20:21:40 -04:00
Eric Engstrom 6c044208fa
feat: Add `prefix: 'string'` option to linking when `glob: true`.
Allows one to store files in a directory or git-repo without the leading 
`.`, as in:

```
dotconf:
├── README.md
├── bin
│   ├── dotbot
│   ├── look
│   ├── pbfile
│   └── ...
├── dot
│   ├── bashrc
│   ├── gitconfig
│   ├── gitignore
│   ├── gorc
│   ├── login
│   ├── ...
│   ├── zshrc
│   └── zshenv
```

Can take a many-line dotbot.yml listing **each** file in `dotconf/dot`,
reducing it to five lines:

```
- link:
    ~/:
      path: dotconf/dot/*
      glob: true
      prefix: '.'
```

FIXES: #259
2021-05-27 12:07:17 -05:00
Eric Engstrom ab7cbd42dc
feat: Support recursive globbing with `**`.
For example, will handle an entire directory tree of files, linking all 
files:

```
- link:
    ~/.config/:
      path: dotconf/config/**
      glob: true
```

NOTE, this feature requires newer versions of `glob()` (Python >= 3.5),
and `dotbot` will throw an error if using an earlier version of python.

For testing purposes, added:
  - ability to skip tests in test harness
  - added testing for older Python(s).

FIXES: #270
2021-05-27 11:58:55 -05:00
Eric Engstrom f56e903cee
Support both `[]` and `?` glob patterns 2021-04-15 23:28:19 -05:00
Anish Athalye dcb3743115 Release 1.19.0 2021-04-06 10:54:27 -04:00
Anish Athalye eb7f3fb7b1 Include git hash in version when available 2021-02-27 14:34:52 -05:00
Anish Athalye f15293b3d5 Rename 'canonicalize-path' into 'canonicalize'
This parallels 'relative' (it's not 'relative-path'). The old
'canonicalize-path' is still supported for backward compatibility.
2021-02-25 08:26:19 -05:00
E. Keys c35382c06d Add cli option force shell show stderr/stdout
Passing `--verbose` flag two times will now force shell commands to show
stderr/stdout output regardless of settings in config file.

Resolves #104
2021-02-25 08:00:07 -05:00
E. Keys b18ba4d392 Make parsed CLI options available to plugins 2021-02-25 07:57:12 -05:00
Anish Athalye 22ed23c7d9 Merge branch 'etkeys/feature/glob-with-exclude' 2021-02-25 06:59:22 -05:00
E. Keys 6c6fee697e Improve globbing behavior with leading '.' 2021-02-25 06:44:14 -05:00
Anish Athalye 945c1e5a4e Add mode option to create directive
See <https://github.com/anishathalye/dotbot/issues/260>. Thanks to
@eengstrom for the feature suggestion.
2021-02-25 06:25:17 -05:00
Anish Athalye a5e1dca91d Release 1.18.0 2020-12-23 18:04:23 -05:00
Anish Athalye cf366bbf66 Fix interaction between --only and defaults
We should treat defaults specially, and even when `--only` is
specified, we should always run defaults.
2020-11-22 16:58:00 -05:00
E. Keys 2ec7a24129 Add exclude parameter for link globbing
- Added `exclude` parameter to _link_. Now, an array of glob patterns
    can be given that will be used to remove items from a glob match.
    This parameter will only have an effect when `glob` is `true`.
- Updated README to add description for `exclude` and add in examples.

Resolves #247
2020-11-22 14:13:11 -05:00
Bob Whitelock 2432a2ba87 Add `--force-color` option
This forces Dotbot to produce colored output, regardless of whether it
is outputting to a TTY.

This is useful to support use cases such as piping colored Dotbot output
into another program for formatting (e.g. I want to indent the output as
part of a larger installation script); this was not previously easy to
do as this would cause the output to lose its colored formatting.

This option cannot be provided at the same time as the existing
`--no-color` option, as there's no logical interpretation of what effect
providing both of these should have.

As part of this change I've refactored some existing code determining
whether output should be colored to where options are parsed, as this
made this change simpler and I think it makes sense for all this logic
to be performed in the same place.
2020-08-23 00:02:26 +01:00
Anish Athalye 1d4f4348bb Release 1.17.1 2020-07-24 08:42:12 -04:00
tpansin 322661dde1 Added support to run with python -m 2020-07-23 08:44:06 -07:00
Anish Athalye c5e709d433 Make error for empty config a little friendlier
In the setup guide in the README, we have people start out with an empty
file (created using `touch`). Before this patch, Dotbot gave the
following error:

    Configuration file must be a list of tasks

Instead, with this patch, Dotbot says:

    Configuration file is empty, no work to do

This change was prompted by
https://github.com/anishathalye/dotbot/pull/226.
2020-06-25 16:07:23 -04:00
Anish Athalye f5e019105e Work around subprocess.call() issue on Windows
On POSIX-like systems, calling `subprocess.call()` with both
`shell=True` and `executable='...'` has the following behavior:

> If `shell=True`, on POSIX the _executable_ argument specifies a
> replacement shell for the default `/bin/sh`.

(via https://docs.python.org/3/library/subprocess.html?highlight=subprocess#popen-constructor)

This seems to have a similar behavior on Windows, but this is
problematic when a POSIX shell is substituted for cmd.exe. This is
because when `shell=True`, the shell is invoked with a '/c' argument,
which is the correct argument for cmd.exe but not for Bash, which
expects a '-c' argument instead. See here:
1def7754b7/Lib/subprocess.py (L1407)

This is problematic when combined with Dotbot's behavior, where the
`executable` argument is set based on `$SHELL`. For example, when
running in Git Bash, the `$SHELL` environment variable is set to Bash,
so any commands run by Dotbot will fail (because it'll invoke Bash with
a '/c' argument).

This behavior of setting the `executable` argument based on `$SHELL` was
introduced in 7593d8c134. This is the
desired behavior. See discussion in
https://github.com/anishathalye/dotbot/issues/97 and
https://github.com/anishathalye/dotbot/pull/100.

Unfortunately, this doesn't work quite right on Windows. This patch
works around the issue by avoiding setting the `executable` argument
when the platform is Windows, which is tested using
`platform.system() == 'Windows'`. This means that shell commands
executed by Dotbot on this platform will always be run using cmd.exe.
Invocations of single programs or simple commands will probably work
just fine in cmd.exe. If Bash-like behavior is desired, the user will
have to write their command as `bash -c '...'`.

This shouldn't have any implications for backwards-compatibility,
because setting the `executable` argument on Windows didn't do the right
thing anyways. Previous workarounds that users had should continue to
work with the new code.

When using Python from CYGWIN, `platform.system()` returns something
like 'CYGWIN_NT-...', so it won't be detected with the check, but this
is the correct behavior, because CYGWIN Python's `subprocess.call()` has
the POSIX-like behavior.

This patch also refactors the code to factor out the
`subprocess.call()`, which was being called in both `link.py` and
`shell.py`, so the workaround can be applied in a single place.

See the following issues/pull requests for a discussion of this bug:
- https://github.com/anishathalye/dotbot/issues/170
- https://github.com/anishathalye/dotbot/pull/177
- https://github.com/anishathalye/dotbot/issues/219

An issue has also been raised in Python's issue tracker:
- https://bugs.python.org/issue40467

Thanks to @shivapoudel for originally reporting the issue, @SuJiKiNen
for debugging it and submitting a pull request, and @mohkale for
suggesting factoring out the code so that other plugins could use it.
2020-05-01 11:52:51 -04:00
Anish Athalye 7ffaa65482 Add --only and --except command-line arguments
Internal to Dotbot, we use the name "skip" instead of "except", because
the latter is a keyword, and using a name like "except_" didn't seem as
nice.
2020-03-26 11:23:07 -04:00
Anish Athalye 9281d120dd Release 1.17.0 2020-01-03 16:47:57 -05:00
Anish Athalye ec8498ffb8 Merge branch 'ypid/add/link_real_path_option' 2020-01-03 16:46:19 -05:00
Anish Athalye 320d5d0123 Add tests for canonicalize-path 2020-01-03 16:45:35 -05:00
Robin Schneider 138fdbc8d7
Add 'canonicalize-path' option to link
Dotbot had a hardcoded behaviour that the BASEDIR was always passed to
os.path.realpath which "returns the canonical path of the specified
filename, eliminating any symbolic links encountered in the path".

This might not always be desirable so this commit makes it configurable.

The use case where `canonicalize-path` comes in handy is the following:
You want to provide dotfiles in the Filesystem Hierarchy Standard under
`/usr/local/share/ypid_dotfiles/`. Now you want to provide
`.config/dotfiles` as a default in `/etc/skel`. When you now
pre-configure `/etc/skel` by running dotbot in it set has HOME, dotfiles
will refer to `/usr/local/share/ypid_dotfiles/` and not
`/etc/skel/.config/dotfiles` which does not look nice.

This is related to but not the same as the `relative` parameter used
with link commands.
2020-01-03 22:35:13 +01:00
Anish Athalye 1e1885c45a Fix incorrect use of `is` over `==`
Comparing strings and integers with `is` is a bug: comparisons should be
done with `==`. It might not have caused observable problems in the past
because small integers and strings can be interned.
2020-01-03 15:31:24 -05:00
Anish Athalye e38e021ab3 Add option to clean recursively 2019-12-31 19:14:23 -05:00
Anish Athalye 81f0d74955 Fix clean not respecting defaults
Previously, clean read the defaults once, and then it updated the
setting for each entry it read. This resulted in the defaults being
clobbered and then not being respected for subsequent entries. This
patch fixes the issue by re-reading the defaults before processing each
item.

The other plugins (link, shell) do not have this problem.
2019-12-31 14:47:32 -05:00
Albert Puig eabd84bce1 Add ignore-missing option to link 2019-12-31 14:25:53 -05:00
Anish Athalye 5bb3c8a343 Release 1.16.0 2019-10-12 12:02:40 -04:00
Jesse Leite 5a0f6676d4 Add 'create' directive to create directories 2019-10-12 11:55:09 -04:00