Commit graph

228 commits

Author SHA1 Message Date
Erik Flodin 0e0172769d
Add yadm.filename variable to default template processor
Some checks are pending
Tests / Tests (macos-13) (push) Waiting to run
Tests / Tests (macos-15) (push) Waiting to run
Tests / Tests (ubuntu-20.04) (push) Waiting to run
Tests / Tests (ubuntu-24.04) (push) Waiting to run
Tests / Tests (windows-2022) (push) Waiting to run
Similar to yadm.source but reflects the current file also in included
files (#520).
2025-03-03 23:47:16 +01:00
AaronYoung5 9ff5e09650
Add support for negative alt conditions (#522) 2025-03-02 22:06:12 +01:00
Erik Flodin d4796108f4
Automatically exclude alt links and template files
unless yadm.auto-exclude is set to false (#234, #465).

Alt files exclude pattern will be written to $GIT_DIR/info/exclude.yadm-alt and
encrypt files exclude patthern to ...yadm-encrypt. Then these two files will be
merged together and added to $GIT_DIR/info/exclude whenever one of them has
changed.
2025-03-02 21:05:43 +01:00
Erik Flodin 6726730701
parse_encrypt: Don't let e.g. "*.ext" match files in subdirs
Some checks failed
Tests / Tests (macos-13) (push) Has been cancelled
Tests / Tests (macos-15) (push) Has been cancelled
Tests / Tests (ubuntu-20.04) (push) Has been cancelled
Tests / Tests (ubuntu-24.04) (push) Has been cancelled
Tests / Tests (windows-2022) (push) Has been cancelled
This matches the behavior before 3.4.0.

Silent errors from ls-files to avoid warnings about e.g. directories that
aren't readable and also list files that would have been encrypted had they not
been tracked in git (#521).

Fix the patterns written to info/exclude so that they match the same files as
are encrypted (e.g. *.key should only match .key files in the topdir, not in
subdirs).
2025-02-25 23:04:23 +01:00
Erik Flodin 1505b7ec8f
Add test to verify that file is only included once in archive
As of the switch (in 4511f5d9) to use git ls-files to list files to include in
archive, duplicate matches are automatically removed (fixes #125).
2025-01-27 21:54:10 +01:00
Erik Flodin 02b4019bc6
Add support and tests for clone --recurse-submodules
Some checks failed
Tests / Tests (macos-13) (push) Has been cancelled
Tests / Tests (macos-15) (push) Has been cancelled
Tests / Tests (ubuntu-20.04) (push) Has been cancelled
Tests / Tests (ubuntu-24.04) (push) Has been cancelled
Tests / Tests (windows-2022) (push) Has been cancelled
Including tests for clone --recursive.
2025-01-20 00:01:22 +01:00
Erik Flodin f33e7c2e1f
Run tests on github windows runner using WSL
Some checks failed
Tests / Tests (macos-13) (push) Has been cancelled
Tests / Tests (macos-15) (push) Has been cancelled
Tests / Tests (ubuntu-20.04) (push) Has been cancelled
Tests / Tests (ubuntu-24.04) (push) Has been cancelled
Tests / Tests (windows-2022) (push) Has been cancelled
2025-01-09 22:15:22 +01:00
Erik Flodin 0f5ee86b38
test: Make distroy family detection work as in yadm
So that family is properly set also on e.g. debian.
2025-01-09 22:08:50 +01:00
Christof Warlich 1e5612d707
Fix testing with WSL (#516) 2025-01-09 21:46:58 +01:00
Erik Flodin 119d1ddbaa
Refactor template handling
Move common template logic out to a new template() function that calls one of
the existing template processors and then handles writing the result and
copying permissions.
2024-12-15 16:15:14 +01:00
Erik Flodin 4511f5d9c6
Use git ls-files to list files to encrypt
By using git ls-files instead of bash we can support ** also on macOS where the
included bash version (3) doesn't support globstar.
2024-12-10 21:51:58 +01:00
Erik Flodin 216d49ceef
Run mandoc or groff instead of man.REAL to check man page
Also fix all warnings reported by mandoc and apply some of the recommendations
from https://liw.fi/manpages/.
2024-12-10 21:29:27 +01:00
Erik Flodin 24772e7b4b
Fix test_upgrade when running outside of docker image
E.g. direct on github runner.
2024-12-10 21:28:51 +01:00
Erik Flodin c232894792
Make test_unit_configure_paths work with bash 3
Bash 3 doesn't understand declare -p so use regular parameter expansion instead
to print all variables that begin with YADM_ or GIT_.
2024-12-10 21:28:50 +01:00
Erik Flodin 8c2f833b43
Support overriding distro and distro family
Fixes #430.
2024-12-10 18:35:26 +01:00
Erik Flodin c092b7c099
Ignore case in alt and default template processor conditions
Some checks are pending
Tests / Tests (push) Waiting to run
This aligns all conditions with distro and distro_family.

Suggestion from #456.
2024-12-09 23:50:49 +01:00
Erik Flodin 6c1970fb41
Set distro family from ID line if no ID_LIKE line is found
See #456.
2024-12-09 23:13:43 +01:00
Erik Flodin 18d5f66542
Ignore case for yadm.distro and .distro_family in default template
Same as b2b0b14 but for if statements in default template processor.
2024-12-09 22:54:41 +01:00
Erik Flodin b2b0b143d6
Refactor alt handling
Some checks failed
Tests / Tests (push) Has been cancelled
* Simplify score_file() by using case in instead of nested ifs with regexps.
* Merge record_score() and record_template().
* Alt condition processing no longer stops when a template condition is seen
  but continues processing to verify that all conditions are valid (as the
  documentation says it should). Fixes #478.
* Support alt dirs with deeply nested tracked files (fixes #490).
* Use git ls-files to filter out which tracked files to consider for alt
  processing. Should speed up auto-alt (#505).
* Use nocasematch when comparing distro and distro_family. Fixed #455.
2024-12-06 23:10:52 +01:00
Erik Flodin b164d03594
Make relative_path match full dir and not just a prefix
Before this change, relative_path "/A/B/C" "/A/B/CD" would return "" instead of
the correct "../CD".
2024-12-06 23:10:49 +01:00
Erik Flodin 6ee9b472d1
Merge pull request #507 from AVM-Martin/fix/reset-yadm-work-index
Some checks failed
Tests / Tests (push) Has been cancelled
fix(clone): reset index of YADM_WORK
2024-11-29 23:10:35 +01:00
AVM.Martin 85e8c1ddfc
docs: fix comment 2024-11-26 19:21:18 +07:00
AVM.Martin a7939bec7b
style: join arguments 2024-11-26 19:20:59 +07:00
Erik Flodin 30fa6f08a4
Update testbed docker image
Some checks failed
Tests / Tests (push) Has been cancelled
* Update base image to Ubuntu 24.10. This uses a python version where j2cli no
  longer works when installed using pip so use the version from Ubuntu instead
  which has been patched to work.

* Update shellcheck, pylint, pytest, isort, flake8, black and yamllint to the
  latest versions. This closes #502.

* Use a longer expect timeout to fix tests failing when gpg is killed due to
  this timeout.

* Explicitly flush gpg-agent's cached passwords to fix failing tests with
  latest gnupg. Also clean up after tests to avoid having gpg-agents running
  after the test (e.g. when running tests directly without docker).
2024-11-11 22:30:41 +01:00
Erik Flodin 640b324401
Prepare for version 3.3.0
Some checks failed
Tests / Tests (push) Has been cancelled
* Support nested ifs in default template (#436)
 * Support include and ifs in default template includes (#406)
 * Support environment variables in ifs in default template (#488)
 * Support != in default template (#358, #477)
 * Fix multiple classes in default template on macOS (#437)
2024-11-08 20:23:23 +01:00
Erik Flodin 8ba9823407
Rewrite default template to handle nested ifs, != and env vars in if
The awk script now performs all processing in the BEGIN block using an
implementation that is capable of handling if statements which contain nested
if statments (fixes #436). To make nested ifs look better, if, else and endif
lines can now have optional whitespace before {%.

Includes are now handled in the same way as the main file which means that
included files can both include other files and have if statements in addition
to variables (fixes #406). Include lines can now also have optional whitespace
before {%.

All variables are handled in the same way now so it's now possible to use env
variables in if statements (fixes #488).

Also add support for != in addition to == (fixes #358). Thus it's now
e.g. possible to check if a variable is set (#477) by doing:

{% if yadm.class != ""%}
Class is set to {{ yadm.class }}
{% endif %}

A non-existing yadm or env variable is now replaced with the empty string.
2024-11-04 22:30:23 +01:00
Tim Byrne 38880abc68
Update repo location 2024-10-30 17:18:49 -05:00
AVM.Martin 12c51e130b
test(clone): run inside YADM_WORK sub-directory
Whenever using `clone` command inside YADM_WORK sub-directory, we need
to checkout the correct repo contents.

Steps to reproduce:

```bash
mkdir $HOME/subdir
cd $HOME/subdir

yadm clone --bootstrap "<repo-url>"
yadm status
```
2024-07-21 07:02:49 +07:00
Tim Byrne 76ce3defea
Changes for black compliance 2023-07-12 09:20:00 -05:00
Tim Byrne e704175201
Add black to linting 2023-07-12 09:20:00 -05:00
Tim Byrne 1b36bf2bb6
Move all test/linting configs into pyproject.toml
Except for flake8 which doesn't support pyproject.toml yet.
2023-07-12 09:19:59 -05:00
Tim Byrne 7af2af52ae
Lint using isort 2023-07-12 09:19:59 -05:00
Tim Byrne bbc1ca17f0
Changes for new flake8 compliance 2023-07-12 09:19:59 -05:00
Tim Byrne 8a87f4a30f
Changes for new pylint compliance 2023-07-12 09:19:59 -05:00
Tim Byrne f9e0368385
Changes for new shellcheck compliance 2023-07-12 09:19:59 -05:00
Tim Byrne c8acf77e04
Adjust pinentry mock
The new test Docker image has a newer gnupg which does not behave the
same way, handling invalid passwords. This type of error is simulated
using an ICP error in the pinentry protocol.
2023-07-12 09:19:59 -05:00
Tim Byrne 9752d801ae
Replace deprecated "pipes" with "shlex" 2023-07-12 09:19:58 -05:00
Tim Byrne 84437894b5
Use man.REAL 2023-07-12 09:19:58 -05:00
Tim Byrne 82ba16db34
Support testing with newer version of Git 2023-07-12 09:19:58 -05:00
Tim Byrne 2253e52ab7
Update test Docker image
* Update base image (which uses a newer python)
* Update linters
* Update other dependencies
2023-07-12 09:19:53 -05:00
Tim Byrne 0f8538d3e3
Create tests for underscores in distro/family 2022-09-13 12:38:18 -05:00
Tim Byrne 46f72c2768
Add local.arch to config introspection 2022-02-21 14:09:57 -06:00
Tim Byrne ebb6715aad
Reduce supported labels for architecture 2022-02-21 14:01:08 -06:00
Tim Byrne 50bf8716cd
Unify template support for classes (#185) 2022-02-21 11:31:44 -06:00
Tim Byrne 0b75e71237
Merge pull request #347 from rasa/develop 2022-02-17 16:45:45 -06:00
Ross Smith II 487f030405
Update test/test_unit_template_default.py
Co-authored-by: Paulo Köch <paulo.koch@gmail.com>
2022-02-17 16:45:07 -06:00
Paulo Köch b0e0856658
Add test 2022-02-17 16:44:57 -06:00
Tim Byrne 027c7359ac
Merge pull request #304 from erijo/multiple-classes 2022-01-22 18:14:23 -06:00
Tim Byrne 3d3432516f
Distinguish tests of templates 2022-01-22 18:05:29 -06:00
Tim Byrne 5ae553b078
Add support for distro_family (#213)
Obtained from /etc/os-release: ID_LIKE.
Alternate attributes f & distro_family.
2022-01-22 18:05:15 -06:00