Commit Graph

172 Commits

Author SHA1 Message Date
Erik Flodin 42c74efbac
Add support for multiple local classes
A local class is set with:
$ yadm config local.class cls1

More classes can be added with:
$ yadm config --add local.class cls2
$ yadm config --add local.class cls3

Any of cls1, cls2 and cls3 can be used in an alternate condition.

For templates, the existing variable yadm.class/YADM_CLASS is set to
the last class (i.e. cls3) to remain compatible with how it works
today and with what the following command gives:
$ yadm config local.class

For the default template processor there is no explicit yadm.classes
variable. Instead a yadm.class condition will check against all

For the other processors, a new template variable YADM_CLASSES will be
set to all classes separated by newline. For jinja2 templates a class
can be checked with: {%- if "cls" in YADM_CLASSES.split("\n") %}

For esh templates the logic is a bit more complex, but it is possible
to do.

Fixes #185.
2021-12-27 21:14:09 +01:00
Tim Byrne 4843e1fa14
Add arch to template tests 2021-12-23 15:43:30 -06:00
Tim Byrne 85e05d311a
Merge pull request #203 from jameshclrk/arch-alternative 2021-12-21 16:50:41 -06:00
Tim Byrne 5adb486727
Fix support for multiple GPG recipients (#342) 2021-05-17 15:42:35 -05:00
Tim Byrne 216aed2f87
Adjust special handling of existing read-only output files
Instead of duplicating the permissions on the temp file, the permissions
are duplicated on the output file directly. If the output file exists as
read-only, it is made writeable first.

There are some environments which don't allow the mv to work if the file
itself is read-only.
2021-02-28 10:55:37 -06:00
Tim Byrne 1461b1ac33
Merge pull request #311 from erijo/test-upgrade-typo 2021-02-15 12:42:17 -06:00
Tim Byrne 88ee3f09fb
Merge pull request #301 from erijo/relative-path 2021-02-15 12:11:21 -06:00
Tim Byrne 31071d9ac9
Clarify error message
Conflicts are not stashed anymore
2021-02-04 00:06:00 -06:00
Erik Flodin 990b4ce119
Fix typo in test (can_upgraded_... -> can_upgrade_...) 2021-01-17 19:07:36 +01:00
Erik Flodin accec694f5
Deinit submodules before removing the repo
when forcing init/clone to happen.
2021-01-08 22:21:35 +01:00
Erik Flodin f45e66d4da
Rework clone
Instead of doing work to find the default branch just to be able to
set up the repository before doing a fetch, do a "git clone" and let
git handle it.

Use -c core.sharedrepository=0600 to get the same result as
--shared=0600 passed to init.

Use --separate-git-dir to get the git directory in $YADM_REPO. Use a
temporary dir as work tree and remove it right after the clone is

When the clone is done, iterate over all missing files in $YADM_WORK
and perform a checkout. If local files exists that differ compared
with the cloned ones the local files are left intact and the user is
instructed to deal with the conflicts.
2021-01-08 22:05:46 +01:00
Erik Flodin a321c88c7c
Support passing relative paths to --yadm-* and -w
Relative paths are expanded relative the current working dir as
2021-01-08 21:45:55 +01:00
Erik Flodin 6378fe3073
Print errors to stderr
This makes it possible to run e.g. "yadm -Y foo introspect repo
2>/dev/null" and get an empty output instead of getting the error
message about foo not being fully qualified.
2021-01-05 21:57:32 +01:00
Erik Flodin cd50c128ba
Fix test when test is run from a git worktree 2021-01-05 21:56:50 +01:00
Tim Byrne 0b4aa767fb
Merge pull request #293 from erijo/submodule-upgrade 2021-01-04 12:52:39 -06:00
Erik Flodin 5818eeb9dd
Change handling of submodules at upgrade
Start with doing "submodule absorbgitdirs" as otherwise "submodule
deinit" will fail if a module has been cloned first and later added as
a submodule (as it will then contain the .git dir instead of it being
under the superprojects .git dir).

Then try to deinit the submodules before moving the repo and abort the
upgrade if it fails for any submodule. Then do the move and finally
initialize the submodules that were initialized before the upgrade.

See #285
2021-01-04 18:31:24 +01:00
Erik Flodin 230b8b9374
Basic test to verify upgrade using real yadm releases
Both with and without submodules.
2021-01-04 17:33:48 +01:00
Tim Byrne 7c1192ae2e
Support upgrading from version 1 repos
* yadm upgrade now updates legacy paths created by yadm 1
* Warnings are issued for invalid alternates again
2020-12-30 14:19:49 -06:00
Tim Byrne 0d3ff086c5
Add test for --no-zle shell option 2020-12-29 17:58:51 -06:00
Erik Flodin 48e7337ef1
Upgrade to latest pytest version (6.2.1) 2020-12-29 21:51:57 +01:00
Erik Flodin ec3956c560
Configure git email and name in docker
to make it easier to use yadm in the container. Set it in the system
config (i.e. /etc/gitconfig) to avoid getting a clash if one wants to
clone an existing yadm repo that contains a .gitconfig.
2020-12-29 21:50:56 +01:00
Erik Flodin 6fc510f473
Include released versions of yadm in docker images
Make it easier to test upgrades (#276).
2020-12-29 19:49:41 +01:00
Erik Flodin 6df2a5df74
Shrink docker image
Don't install apt recommendations and use the ADD directive instead of
running curl in the image. Saves ~380MB in docker image size.
2020-12-29 19:11:45 +01:00
Erik Flodin 5e9c5cf66c
Issue legacy path warnings to stderr
To make it possible to ignore the warning e.g. when running yadm
introspect repo in the bash completion.
2020-12-27 22:33:15 +01:00
Tim Byrne df2ff5ec70
Remove deprecated option cygwin-copy 2020-12-26 12:34:58 -06:00
Tim Byrne 74df722840
Add tests for hook executable bit 2020-12-22 11:52:44 -06:00
Tim Byrne 99897124e6
Verify extension does not modify alt score 2020-12-22 10:51:23 -06:00
Tim Byrne d298b42653
Merge pull request #257 from erijo/extension 2020-12-22 10:08:30 -06:00
Tim Byrne c4b419d98e
Add --version and --help as yadm internal commands (#267) 2020-12-21 17:06:14 -06:00
Tim Byrne 6b068a141d
Remove superfluous f-strings 2020-12-21 17:06:14 -06:00
Tim Byrne c8d516c67d
Bump versions of required linters 2020-12-21 17:06:14 -06:00
Tim Byrne 4b5f16d73a
Improve support for default branches (#231, #232)
Unless a branch is specified, the default remote HEAD is used during
clone. Also a local master branch is not created if it is not the remote
2020-12-06 13:23:25 -06:00
Tim Byrne 4cb13d5d08
Remove unnecessary LEGACY_WARNING_ISSUED flag 2020-11-25 23:18:26 -06:00
Tim Byrne 13a3cdc8a8
Remove reporting of invalid alts 2020-11-25 23:18:25 -06:00
Tim Byrne 7997dc9a3d
Update upgrade
Upgrade will only move 2.0.0 paths to 3.0.0 standards
2020-11-25 23:18:25 -06:00
Tim Byrne 62b109ad2d
Rename yadm_y -> yadm_cmd
-Y is no longer used when running commands
2020-11-22 17:09:44 -06:00
Tim Byrne 8efe2c8fad
Improve tests to use XDG* variables
Instead of overriding YADM_DIR via -Y, set the XDG* environment
2020-11-22 17:09:44 -06:00
Tim Byrne fc66b6b71b
Support XDG_DATA_HOME (#208)
* Create a YADM_DATA base (that is the source for repo & archive)
* Add --yadm-data to override
* Default YADM_DATA will be determined by XDG_DATA_HOME
2020-11-22 17:09:44 -06:00
Erik Flodin f22c4d04cc
Add support for the extension "condition"
This special condition doesn't affect the selection process and is only
supported to support syntax highlighting and language detection for alt files
as reported in #239.
2020-10-25 10:41:52 +01:00
Tim Byrne b19c78b8e2
Remove support for YADM_COMPATIBILITY=1 (#242) 2020-10-17 17:41:09 -05:00
Tim Byrne a66d3c148c
Remove tests for deprecated alternate processing 2020-10-17 17:39:24 -05:00
Erik Flodin 9bcf070dfe
Add support for including files using the default template processor
The syntax is '{% include "file" %}' where file is either an absolute path or a
path relative to the current template file's directory.

Variables in the included file will be replaced as for the main template. But
the included file can't include files itself.
2020-10-12 16:13:50 +02:00
Tim Byrne e0daf86334
Add encryption unit tests 2020-10-07 01:44:35 -05:00
Tim Byrne 59c60a4675
Change default archive name to "archive" 2020-09-25 12:10:34 -05:00
Tim Byrne 05ae6f0257
Add config yadm.openssl-old
The newer versions (OpenSSL 1.1.1 or LibreSSL 2.9.1) support the pbkdf2
key derivation function, while older versions do not. In addition the
new versions have changed the default digest to SHA256 instead of MD5.

Files encrypted with older versions would throw warnings about
deprecated key derivation used files encrypted with newer versions +
pbkdf2 would not be decryptable using older versions These problems
matter, when many users maintain their dotfiles across different systems
with different levels of OpenSSL support.

A new boolean config option has been added, yadm.openssl-old

* If false, use options -pbkdf2 -iter 100000 -md sha512
* If true, use options -md md5 (and if decrypting with newer versions
  warnings will be printed)
2020-09-25 10:04:18 -05:00
Tim Byrne 4ae504c533
Merge alternative cyphers changes into develop 2020-07-17 14:07:10 -05:00
Tim Byrne 102ba5d558
Preserve file mode of template (#193)
Any processed templates will inherit the file mode of the source
2020-07-11 21:52:28 -05:00
Tim Byrne 6654e29c62
Merge pull request #220 2020-07-08 16:17:24 -05:00
Tim Byrne 87f81143b2
Add unit test for alternate order
Ensure that any alternates for YADM_CONFIG are processed prior to
2020-07-08 16:16:48 -05:00
Tim Byrne 6d8494a35f
Fix linting errors 2020-07-08 15:30:15 -05:00