Compare commits

...

130 Commits

Author SHA1 Message Date
Tim Byrne 0a5e7aa353
Merge pull request #470 from LFd3v/master 2023-11-12 07:33:09 -06:00
LFdev 040dd461bd
Update Arch Linux badge in README.md
community repo was merged with extra, please refer to:

https://archlinux.org/news/git-migration-announcement/
https://archlinux.org/news/git-migration-completed/
2023-11-08 23:02:14 +00:00
Tim Byrne e4bb8a79a4
Update to shields.io new API 2023-01-23 13:51:06 -06:00
Tim Byrne 2d4dcd05ef
Update version number and update documentation
* Support spaces in distro/distro-family (#432)
* Fix zsh hanging when tab completing add/checkout (#417)
* Add yadm-untracked script to contributed files (#418)
* Fix documentation typos (#425)
* Support docker-like OCI engines for dev testing (#431)
2023-01-23 13:25:54 -06:00
Tim Byrne 5981f6329e
Adjust markdown creation for new version of groff 2023-01-23 13:16:53 -06:00
Tim Byrne 0f8538d3e3
Create tests for underscores in distro/family 2022-09-13 12:38:18 -05:00
Tim Byrne 67c684473d
Merge pull request #432 from signed-log/alt_with_spaces 2022-09-13 11:56:51 -05:00
Nicolas signed-log FORMICHELLA 8f390cf085
Accept _ as space substitutes
Replace all spaces in the ID/ID_LIKE scoring to allow for space
replacement

Signed-off-by: Nicolas signed-log FORMICHELLA <stigpro@outlook.fr>
2022-08-28 18:29:41 +02:00
Tim Byrne 36fda72bec
Remove superfluous space 2022-08-27 13:55:24 -05:00
Tim Byrne a89e5cee89
Merge pull request #431 from signed-log/makefile-oci-patch 2022-08-27 13:45:53 -05:00
Nicolas signed-log FORMICHELLA 075cd1b06b
[Documentation] Document OCI switch
Document the OCI override switch

Signed-off-by: Nicolas signed-log FORMICHELLA <stigpro@outlook.fr>
2022-08-27 11:55:54 +02:00
Nicolas signed-log FORMICHELLA 19b7a30668
[Makefile] Support docker-like OCI engines
Support setting a different OCI engine than docker

- Create OCI variable to override the docker engine
- Refactor the test-docker error message to expose this possibility

Signed-off-by: Nicolas signed-log FORMICHELLA <stigpro@outlook.fr>
2022-08-27 11:39:22 +02:00
Tim Byrne 6304553ab3
Merge pull request #425 from rasa/patch-1 2022-07-13 00:03:46 -05:00
Ross Smith II 24ee841372
docs: Fix cypher typo 2022-07-08 17:08:51 -07:00
Ross Smith II 87ff97bbd6
docs: Fix cypher typo 2022-07-08 17:06:30 -07:00
Tim Byrne f163130609
Remove trailing whitespace 2022-07-08 08:12:08 -05:00
Tim Byrne d49005ce6c
Merge branch 'joshzcold-master' into develop
I've signed these commits myself.
2022-07-08 08:11:30 -05:00
Joshua Cold 2cc64a2fa0
remove extra lines 2022-07-08 08:09:38 -05:00
Joshua Cold 2989734359
Add back in the descriptions 2022-07-08 08:09:33 -05:00
Joshua Cold 7573e18a89
Fix duplicates from completion 2022-07-08 08:09:27 -05:00
Joshua Cold beb83077d8
Fix zsh hanging when tab completing add/checkout 2022-07-08 08:08:58 -05:00
Tim Byrne 6a49e849c8
Remove trailing space 2022-06-03 15:49:14 -05:00
Tim Byrne 222182b296
Add README for contrib/commands 2022-06-03 15:49:05 -05:00
Tim Byrne 0d67c44343
Merge pull request #418 from gwww/master 2022-06-03 15:47:43 -05:00
Glenn Waters a9e7e7679b
Add yadm-untracked script. 2022-06-03 15:36:50 -05:00
Tim Byrne abf6ea4b61
Update version number and update documentation
* Fix Bash 3 bad array subscript bug (#411)
2022-03-17 18:47:43 -05:00
Tim Byrne f59d903769
Fix Bash 3 bad array subscript bug (#411) 2022-03-17 18:43:10 -05:00
Tim Byrne bd0039a650
Release 3.2.0 2022-03-16 10:22:30 -05:00
Tim Byrne 82c0b6d02e
Update version number and update documentation
* Support architecture for alternates/templates (#202, #203, #393)
* Support distro_family for alternates/templates (#213)
* Support setting multiple classes (#185, #304)
* Support environment variables in default template processor (#347)
* Update version command to include Bash & Git versions (#377)
2022-03-16 09:26:11 -05:00
Tim Byrne a4adadcc8c
Fix table format 2022-03-12 15:11:55 -06:00
Tim Byrne 287249df91
Clarify requirements for linked directories (#328) 2022-03-12 15:04:47 -06:00
Tim Byrne c5e4e4eda2
Adjust exempt labels 2022-03-12 11:36:26 -06: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 39d0c791ce
Reorder list 2022-02-21 13:18:48 -06:00
Tim Byrne 3445763731
Add manpage docs about env support in default templates 2022-02-21 12:42:45 -06:00
Tim Byrne 718e99c826
Add manpage documentation for multiple classes 2022-02-21 11:36:51 -06:00
Tim Byrne 50bf8716cd
Unify template support for classes (#185) 2022-02-21 11:31:44 -06:00
Tim Byrne 82bfd5e773
Fix table formatting 2022-02-21 10:29:59 -06:00
Tim Byrne b7c5294bd9
Add manpage docs for distro_family (#213) 2022-02-21 10:29:53 -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
Tim Byrne 32bc9abb0c
Include bash version 2022-01-17 11:45:09 -06:00
Tim Byrne 8186705059
Include Git version with yadm version (#377) 2022-01-17 09:12:41 -06:00
Tim Byrne f28d4bc1c6
Update image tag 2022-01-07 00:28:14 -06:00
Tim Byrne f11974140e
Merge pull request #395 from erijo/shellcheck 2022-01-07 00:21:53 -06:00
Tim Byrne 71cb08a5f3
Merge pull request #394 from erijo/esh 2022-01-07 00:18:34 -06:00
Erik Flodin 1aa9839096
Bump shellcheck to version 0.8.0 in docker image
And fix the new SC2295 warning.
2021-12-29 21:55:14 +01:00
Erik Flodin a9fc8b1374
Bump esh to version 0.3.1 in docker image 2021-12-29 20:44:12 +01:00
Tim Byrne 0ae8931e01
Merge pull request #393 from erijo/arch-fixes 2021-12-27 16:59:23 -06:00
Erik Flodin 2379d63068
Support overriding architecture
In the same way as os, hostname and user.
2021-12-27 22:21:18 +01:00
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
classes.

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 2f00dabcdb
Make order of attributes match precedence 2021-12-23 15:51:18 -06:00
Tim Byrne 4caf5f681e
Add arch to manpage 2021-12-23 15:43:36 -06:00
Tim Byrne 4843e1fa14
Add arch to template tests 2021-12-23 15:43:30 -06:00
Tim Byrne bacc948bba
Support "YADM_ARCH" variable in esh templates 2021-12-23 15:43:29 -06:00
Tim Byrne 31e2ce56bc
Support "arch" variable in built-in templates 2021-12-23 15:42:08 -06:00
Tim Byrne 3d82aff3e8
Merge pull request #384 from orenzp/workflow-stale-issues 2021-12-22 12:53:02 -06:00
Tim Byrne 0cac436219
Tweak stale workflow
- Add issue exemptions
- Use all lowercase label
- Update issue comments
2021-12-22 12:51:50 -06:00
Tim Byrne ec307ce4f8
Update yaml formatting 2021-12-22 12:21:33 -06:00
Tim Byrne de34cd2e8c
Change extension to match other workflows 2021-12-22 11:59:31 -06:00
Oren Zipori a37eabba98
Adding new github workflow for stale issues
Adding a Github workflow that will mark issues that didn't have any activity on them for the last 60 days and put a label of stale on them. After 7 days if the stale issue didn't have any updates the issue will be deleted.
2021-12-22 11:58:05 -06:00
Tim Byrne 85e05d311a
Merge pull request #203 from jameshclrk/arch-alternative 2021-12-21 16:50:41 -06:00
Tim Byrne 0ecb9c4f2f
Merge pull request #390 from Stig124/fix-makefile2 2021-11-29 12:55:15 -06:00
Nicolas stig124 FORMICHELLA 344b740d9b
Fix Makefile portability
OBS *among others* need to copy files from the build folder to the
package folder.
With the old version, that wasn't possible, as it would try to install the software in the worker folder,
of course something denied on public instances.
Adding $(DESTDIR) before all paths ensure that you can install to another folder
2021-11-25 22:30:43 +01:00
Tim Byrne 9aaefa60fe
Merge pull request #373 from exic/patch-1 2021-11-03 08:57:00 -05:00
Tim Byrne 6c57bdd8fb
Merge pull request #380 from dessert1/patch-1 2021-11-03 08:45:17 -05:00
dessert1 ed4a60257d
fix “Mackbook” typo in manpage 2021-10-22 16:03:23 +02:00
Jonas 9beed3307f
Fix arch-badge
Obviously yadm was moved from AUR to Community repository :-)
2021-09-10 10:49:27 +02:00
Tim Byrne f8abcd756b
Update version number and update documentation
* Fix clone support for older versions of Git (#348)
* Fix support for multiple GPG recipients (#342)
* Find symlinks in bootstrap-in-dir (#340)
2021-08-23 08:25:10 -05:00
Tim Byrne db78669479
Fix clone support for older versions of Git (#348) 2021-08-23 08:12:09 -05:00
Tim Byrne 1544413c91
Merge pull request #340 from rasa/patch-3 2021-08-23 08:05:53 -05:00
Ross Smith II 73af421667
feat: Add support for env vars in templates 2021-06-06 10:37:14 -07:00
Tim Byrne 5adb486727
Fix support for multiple GPG recipients (#342) 2021-05-17 15:42:35 -05:00
Ross Smith II c144d9f3bb
fix: Find symlinks in bootstrap-in-dir
Fixes #339
2021-05-06 20:11:36 -07:00
Tim Byrne a4d39c7504
Update version number and update documentation
* Use `git clone` directly during clone (#289, #323)
* Fix compatibility bug with Git completions (#318, #321)
* Support relative paths for --yadm-* and -w (#301)
* Improve parsing of if-statement in default template (#303)
* Read files without running cat in subshells (#317)
* Improve portability of updating read-only files (#320)
* Various code improvements (#306, #307, #311)
2021-04-03 12:00:02 -05:00
Tim Byrne 034045f58c
Fix man formatting 2021-03-22 13:36:58 -05:00
Tim Byrne 1998a8ed50
Fix typo 2021-03-22 13:28:57 -05:00
Tim Byrne 6cdbc92c64
Merge pull request #323 from erijo/man-new-clone 2021-03-22 13:26:30 -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 39773765ab
Merge pull request #320 from rasa/rs/update-read-only-files 2021-02-27 18:36:58 -06:00
Tim Byrne 8cc30193f3
Merge pull request #317 from rasa/rs/remove-cats 2021-02-27 18:28:58 -06:00
Ross Smith II 814e5f8ab3
Replace cats with reads (passes all tests)
Signed-off-by: Ross Smith II <ross@smithii.com>
2021-02-23 17:51:44 -08:00
Tim Byrne d11e094f7b
Merge pull request #303 from erijo/default-template-if 2021-02-15 12:57:45 -06:00
Tim Byrne e6d7e6f174
Simplify return 2021-02-15 12:51:33 -06:00
Tim Byrne 999692fe5e
Merge pull request #307 from rasa/rs/simplify_parse_encrypt 2021-02-15 12:45:31 -06:00
Tim Byrne 1461b1ac33
Merge pull request #311 from erijo/test-upgrade-typo 2021-02-15 12:42:17 -06:00
Tim Byrne a8e5b20021
Move shellcheck option below license 2021-02-15 12:39:27 -06:00
Tim Byrne 8ece22ab2a
Merge pull request #306 from rasa/rs/default-shellcheck 2021-02-15 12:33:22 -06:00
Tim Byrne 79f7aae073
Remove unnecessary [[ 2021-02-15 12:27:55 -06:00
Tim Byrne 88ee3f09fb
Merge pull request #301 from erijo/relative-path 2021-02-15 12:11:21 -06:00
Erik Flodin 7b1bfac12b
Update the man page to match new clone behavior (from #289) 2021-02-08 23:00:13 +01:00
Tim Byrne c4327d0099
Fix compatibility bug with Git completions (#318)
Git 2.30.0 removed an internal function yadm completion depended upon.
This change retains the old function call for compatibility.
2021-02-07 16:30:27 -06:00
Tim Byrne 31071d9ac9
Clarify error message
Conflicts are not stashed anymore
2021-02-04 00:06:00 -06:00
Tim Byrne e6cfd39bbc
Remove mktemp dependency 2021-02-03 22:46:48 -06:00
Tim Byrne 9c999c7998
Merge pull request #289 from erijo/clone 2021-02-03 21:18:24 -06:00
Ross Smith II 96471a6d68
Fix updating of readonly files 2021-01-30 18:17:59 -08:00
Erik Flodin 990b4ce119
Fix typo in test (can_upgraded_... -> can_upgrade_...) 2021-01-17 19:07:36 +01:00
Ross Smith II 84136a8633
Remove unneeded duplicate line 2021-01-11 17:17:11 -08:00
Ross Smith II 0c788ae020
Simplify parse_encrypt by exiting early
if encrypt file doesn't exist.

Signed-off-by: Ross Smith II <ross@smithii.com>
2021-01-10 19:07:21 -08:00
Ross Smith II fecbb315df
Add 'shellcheck shell=bash' as the default
See https://github.com/koalaman/shellcheck/wiki/Directive#shell

Signed-off-by: Ross Smith II <ross@smithii.com>
2021-01-10 18:49:28 -08:00
Erik Flodin e2ed647c2a
Tighten up parsing of if-statement in default template
Require space after if and an ending %} after the condition.
2021-01-10 20:53:12 +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 fb56513d17
zsh: complete all supported git clone parameters for yadm clone 2021-01-08 22:21:27 +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
done.

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
expected.
2021-01-08 21:45:55 +01:00
Tim Byrne a5b1067e02
Update version number and update documentation
* Fix parsing by sh (#299)
2021-01-07 10:49:26 -06:00
Tim Byrne b32025bcc3
Fix parsing by sh (#299) 2021-01-07 10:46:06 -06:00
Tim Byrne afab29c5fc
Update version number and update documentation
* Improve handling of submodules at upgrade (#284, #285, #293)
* Improve Zsh completions (#292, #298)
* Use stderr for error messages (#297)
2021-01-07 09:24:11 -06:00
Tim Byrne 9b83169ae9
Merge pull request #298 from erijo/zsh-completion 2021-01-07 09:19:09 -06:00
Erik Flodin 57eed9742a
Rework zsh completion fallback
Don't rely on internals from the git completion. Instead set up the
environment and then simply call _git and let it do the completion as
it see fit.

See #292.
2021-01-06 20:36:07 +01:00
Tim Byrne aaf519623b
Merge pull request #297 from erijo/error-on-stderr 2021-01-06 10:20:59 -06: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 630bc69b37
Merge pull request #29 from erijo/zsh-git-completion 2021-01-04 20:03:08 -06:00
Erik Flodin d6f623c546
Support fallback to git completion from git
Fixes #292
2021-01-05 00:25:24 +01:00
Tim Byrne ca5aba43c3
Merge pull request #287 from erijo/bootstrap.d 2021-01-04 14:06:13 -06:00
Tim Byrne 1c9dff7a42
Update documentation for changes to upgrade 2021-01-04 13:14:07 -06:00
Tim Byrne 0b4aa767fb
Merge pull request #293 from erijo/submodule-upgrade 2021-01-04 12:52:39 -06:00
Tim Byrne 4a4f426058
Merge pull request #284 from erijo/upgrade 2021-01-04 12:20:51 -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 0675bc9240
Merge pull request #288 from erijo/testyadm-version 2021-01-02 12:10:18 -06:00
Erik Flodin f67189c6b7
Use local version of yadm by default (in testhost/scripthost)
Also symlink instead of copy in that case, so that changes locally can
be reflected in the testhost directly, and print the used version in a
more readable format.
2021-01-02 00:05:00 +01:00
Erik Flodin 7d216d47e0
Add example bootstrap script to run files in bootstrap.d
This script will, when installed as yadm's bootstrap script, run all
executables in $YADM_DIR/bootstrap.d.
2021-01-01 22:23:53 +01:00
James Clark 77d2da4e9b
Support architecture in alternates (#202) 2020-02-22 02:08:53 +00:00
44 changed files with 1495 additions and 818 deletions

View File

@ -212,6 +212,11 @@ these principles when making changes.
```text
$ make test
```
If you don't use `docker` but an OCI engine akin to `podman`, you can set it through the `OCI` switch for every target
```text
$ make test OCI=podman
```
5. Create a feature branch, based off the `develop` branch.

25
.github/workflows/stale.yml vendored Normal file
View File

@ -0,0 +1,25 @@
---
name: Close Stale Issues
on: # yamllint disable-line rule:truthy
schedule:
- cron: "30 1 * * *" # Daily
jobs:
Stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v4
with:
close-issue-message: >-
This issue was closed because it has been labeled as stale for 7
days with no activity.
days-before-close: 7
days-before-stale: 60
exempt-all-assignees: true
exempt-issue-labels: in develop, 1, 2, 3
exempt-pr-labels: in develop, 1, 2, 3
stale-issue-label: stale
stale-issue-message: >-
This issue has been labeled as stale because it has been open 60
days with no activity. Remove stale label or comment or this will
be closed in 7 days.
stale-pr-label: stale

39
CHANGES
View File

@ -1,3 +1,42 @@
3.2.2
* Support spaces in distro/distro-family (#432)
* Fix zsh hanging when tab completing add/checkout (#417)
* Add yadm-untracked script to contributed files (#418)
* Fix documentation typos (#425)
* Support docker-like OCI engines for dev testing (#431)
3.2.1
* Fix Bash 3 bad array subscript bug (#411)
3.2.0
* Support architecture for alternates/templates (#202, #203, #393)
* Support distro_family for alternates/templates (#213)
* Support setting multiple classes (#185, #304)
* Support environment variables in default template processor (#347)
* Update version command to include Bash & Git versions (#377)
3.1.1
* Fix clone support for older versions of Git (#348)
* Fix support for multiple GPG recipients (#342)
* Find symlinks in bootstrap-in-dir (#340)
3.1.0
* Use `git clone` directly during clone (#289, #323)
* Fix compatibility bug with Git completions (#318, #321)
* Support relative paths for --yadm-* and -w (#301)
* Improve parsing of if-statement in default template (#303)
* Read files without running cat in subshells (#317)
* Improve portability of updating read-only files (#320)
* Various code improvements (#306, #307, #311)
3.0.2
* Fix parsing by sh (#299)
3.0.1
* Improve handling of submodules at upgrade (#284, #285, #293)
* Improve Zsh completions (#292, #298)
* Use stderr for error messages (#297)
3.0.0
* Support encryption with OpenSSL (#138)
* Support "include" directive in built-in template processor (#255)

View File

@ -1,21 +1,28 @@
CONTRIBUTORS
Tim Byrne
Martin Zuther
Erik Flodin
Martin Zuther
Jan Schulz
Ross Smith II
Jonathan Daigle
Luis López
Tin Lai
Espen Henriksen
Cameron Eagans
Klas Mellbourn
Ross Smith II
James Clark
Glenn Waters
Nicolas signed-log FORMICHELLA
Tomas Cernaj
Joshua Cold
jonasc
Nicolas stig124 FORMICHELLA
Chad Wade Day, Jr
Sébastien Gross
David Mandelberg
Paulo Köch
Oren Zipori
Daniel Gray
Paraplegic Racehorse
japm48
@ -23,17 +30,23 @@ Siôn Le Roux
Mateusz Piotrowski
Uroš Golja
Satoshi Ohki
Jonas
Franciszek Madej
Daniel Wagenknecht
Stig Palmquist
Patrick Hof
con-f-use
Samisafool
Bram Ceulemans
Travis A. Everett
Sheng Yang
Jared Smartt
Adam Jimerson
dessert1
addshore
Tim Condit
Thomas Luzat
Russ Allbery
Brayden Banks
Alexandre GV
Felipe S. S. Schneider

View File

@ -1,5 +1,6 @@
PYTESTS = $(wildcard test/test_*.py)
IMAGE = yadm/testbed:2020-12-29
IMAGE = docker.io/yadm/testbed:2022-01-07
OCI = docker
.PHONY: all
all:
@ -23,11 +24,10 @@ usage:
@echo
@echo ' make testhost [version=VERSION]'
@echo ' - Create an ephemeral container for doing adhoc yadm testing. The'
@echo ' HEAD revision of yadm will be used unless "version" is'
@echo ' working copy version of yadm will be used unless "version" is'
@echo ' specified. "version" can be set to any commit, branch, tag, etc.'
@echo ' The targeted "version" will be retrieved from the repo, and'
@echo ' linked into the container as a local volume. Setting version to'
@echo ' "local" uses yadm from the current working tree.'
@echo ' linked into the container as a local volume.'
@echo
@echo ' make scripthost [version=VERSION]'
@echo ' - Create an ephemeral container for demonstrating a bug. After'
@ -95,7 +95,7 @@ test:
py.test -v $(testargs); \
else \
$(MAKE) -s require-docker && \
docker run \
$(OCI) run \
--rm -t$(shell test -t 0 && echo i) \
-v "$(CURDIR):/yadm:ro" \
$(IMAGE) \
@ -103,20 +103,22 @@ test:
fi
.PHONY: .testyadm
.testyadm: version ?= HEAD
.testyadm: version ?= local
.testyadm:
@echo "Using yadm version=\"$(version)\""
@rm -f $@
@if [ "$(version)" = "local" ]; then \
cp -f yadm $@; \
ln -sf yadm $@; \
echo "Using local yadm ($$(git describe --tags --dirty))"; \
else \
git show $(version):yadm > $@; \
echo "Using yadm version $$(git describe --tags $(version))"; \
fi
@chmod a+x $@
.PHONY: testhost
testhost: require-docker .testyadm
@echo "Starting testhost"
@docker run \
@$(OCI) run \
-w /root \
--hostname testhost \
--rm -it \
@ -128,7 +130,7 @@ testhost: require-docker .testyadm
scripthost: require-docker .testyadm
@echo "Starting scripthost \(recording script\)"
@printf '' > script.gz
@docker run \
@$(OCI) run \
-w /root \
--hostname scripthost \
--rm -it \
@ -158,7 +160,7 @@ testenv:
.PHONY: image
image:
@docker build -f test/Dockerfile . -t "$(IMAGE)"
@$(OCI) build -f test/Dockerfile . -t "$(IMAGE)"
.PHONY: man
@ -174,7 +176,7 @@ man-ps:
@groff -man -Tps ./yadm.1 > yadm.ps
yadm.md: yadm.1
@groff -man -Tascii ./yadm.1 | col -bx | sed 's/^[A-Z]/## &/g' | sed '/yadm(1)/d' > yadm.md
@groff -man -Tutf8 -Z ./yadm.1 | grotty -c | col -bx | sed 's/^[A-Z]/## &/g' | sed '/yadm(1)/d' > yadm.md
.PHONY: contrib
contrib: SHELL = /bin/bash
@ -191,9 +193,9 @@ install:
@[ -n "$(PREFIX)" ] || { echo "PREFIX is not set"; exit 1; }
@{\
set -e ;\
bin="$(PREFIX)/bin" ;\
doc="$(PREFIX)/share/doc/yadm" ;\
man="$(PREFIX)/share/man/man1" ;\
bin="$(DESTDIR)$(PREFIX)/bin" ;\
doc="$(DESTDIR)$(PREFIX)/share/doc/yadm" ;\
man="$(DESTDIR)$(PREFIX)/share/man/man1" ;\
install -d "$$bin" "$$doc" "$$man" ;\
install -m 0755 yadm "$$bin" ;\
install -m 0644 yadm.1 "$$man" ;\
@ -203,11 +205,11 @@ install:
.PHONY: sync-clock
sync-clock:
docker run --rm --privileged alpine hwclock -s
$(OCI) run --rm --privileged alpine hwclock -s
.PHONY: require-docker
require-docker:
@if ! command -v "docker" > /dev/null 2>&1; then \
echo "Sorry, this make target requires docker to be installed."; \
@if ! command -v $(OCI) > /dev/null 2>&1; then \
echo "Sorry, this make target requires docker to be installed, to use another docker-compatible engine, like podman, re-run the make command adding OCI=podman"; \
false; \
fi

View File

@ -3,7 +3,7 @@
[![Latest Version][releases-badge]][releases-link]
[![Homebrew Version][homebrew-badge]][homebrew-link]
[![OBS Version][obs-badge]][obs-link]
[![Arch Version][aur-badge]][aur-link]
[![Arch Version][arch-badge]][arch-link]
[![License][license-badge]][license-link]<br />
[![Master Update][master-date]][master-commits]
[![Develop Update][develop-date]][develop-commits]
@ -56,23 +56,23 @@ The star count helps others discover yadm.
[Git]: https://git-scm.com/
[GnuPG]: https://gnupg.org/
[OpenSSL]: https://www.openssl.org/
[aur-badge]: https://img.shields.io/aur/version/yadm.svg
[aur-link]: https://aur.archlinux.org/packages/yadm
[dev-pages-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Test%20Site/dev-pages?label=dev-pages
[develop-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Tests/develop?label=develop
[arch-badge]: https://img.shields.io/archlinux/v/extra/any/yadm
[arch-link]: https://archlinux.org/packages/extra/any/yadm/
[dev-pages-badge]: https://img.shields.io/github/actions/workflow/status/TheLocehiliosan/yadm/test.yml?branch=dev-pages
[develop-badge]: https://img.shields.io/github/actions/workflow/status/TheLocehiliosan/yadm/test.yml?branch=develop
[develop-commits]: https://github.com/TheLocehiliosan/yadm/commits/develop
[develop-date]: https://img.shields.io/github/last-commit/TheLocehiliosan/yadm/develop.svg?label=develop
[dotfiles]: https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory
[gh-pages-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Test%20Site/gh-pages?label=gh-pages
[gh-pages-badge]: https://img.shields.io/github/actions/workflow/status/TheLocehiliosan/yadm/test.yml?branch=gh-pages
[git-crypt]: https://github.com/AGWA/git-crypt
[homebrew-badge]: https://img.shields.io/homebrew/v/yadm.svg
[homebrew-link]: https://formulae.brew.sh/formula/yadm
[license-badge]: https://img.shields.io/github/license/TheLocehiliosan/yadm.svg
[license-link]: https://github.com/TheLocehiliosan/yadm/blob/master/LICENSE
[master-badge]: https://img.shields.io/github/workflow/status/TheLocehiliosan/yadm/Tests/master?label=master
[master-badge]: https://img.shields.io/github/actions/workflow/status/TheLocehiliosan/yadm/test.yml?branch=master
[master-commits]: https://github.com/TheLocehiliosan/yadm/commits/master
[master-date]: https://img.shields.io/github/last-commit/TheLocehiliosan/yadm/master.svg?label=master
[obs-badge]: https://img.shields.io/badge/OBS-v3.0.0-blue
[obs-badge]: https://img.shields.io/badge/OBS-v3.2.2-blue
[obs-link]: https://software.opensuse.org//download.html?project=home%3ATheLocehiliosan%3Ayadm&package=yadm
[releases-badge]: https://img.shields.io/github/tag/TheLocehiliosan/yadm.svg?label=latest+release
[releases-link]: https://github.com/TheLocehiliosan/yadm/releases

View File

@ -1,10 +1,12 @@
# test if git completion is missing, but loader exists, attempt to load
if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; then
_completion_loader git
if ! declare -F _git > /dev/null && ! declare -F __git_wrap__git_main > /dev/null; then
if declare -F _completion_loader > /dev/null; then
_completion_loader git
fi
fi
# only operate if git completion is present
if declare -F _git > /dev/null; then
if declare -F _git > /dev/null || declare -F __git_wrap__git_main > /dev/null; then
_yadm() {
@ -66,7 +68,11 @@ if declare -F _git > /dev/null; then
if [[ " ${yadm_switches[*]} " != *" $penultimate "* ]]; then
# TODO: somehow solve the problem with [--yadm-xxx option] being
# incompatible with what git expects, namely [--arg=option]
_git
if declare -F _git > /dev/null; then
_git
else
__git_wrap__git_main
fi
fi
if [[ "$current" =~ ^- ]]; then
local matching

View File

@ -1,5 +1,26 @@
#compdef yadm
# This completion tries to fallback to git's completion for git commands.
zstyle -T ':completion:*:yadm:argument-1:descriptions:' format && \
zstyle ':completion:*:yadm:argument-1:descriptions' format '%d:'
zstyle -T ':completion:*:yadm:*:yadm' group-name && \
zstyle ':completion:*:yadm:*:yadm' group-name ''
function _yadm-add(){
local -a yadm_options yadm_path
yadm_path="$(yadm rev-parse --show-toplevel)"
yadm_options=($(yadm status --porcelain=v1 |
awk -v yadm_path=${yadm_path} '{printf "%s/%s:%s\n", yadm_path, $2, $1}' ))
_describe 'command' yadm_options
_files
}
function _yadm-checkout(){
_yadm-add
}
_yadm-alt() {
return 0
}
@ -12,10 +33,12 @@ _yadm-clone() {
_arguments \
'(--bootstrap --no-bootstrap)--bootstrap[force bootstrap, without prompt]' \
'(--bootstrap --no-bootstrap)--no-bootstrap[prevent bootstrap, without prompt]' \
'-b[branch name]:' \
'-f[force overwrite of existing repository]' \
'-w[work tree path]: :_files -/' \
'*:'
'-w[yadm work tree path]: :_files -/'
local curcontext="${curcontext%:*:*}:git:"
words=("git" "${words[@]}") CURRENT=$((CURRENT + 1)) service=git _git
}
_yadm-config() {
@ -41,12 +64,6 @@ _yadm-git-crypt() {
# TODO: complete git-crypt options
}
_yadm-gitconfig() {
integer ret=1
_call_function ret _git-config
return ret
}
_yadm-help() {
return 0
}
@ -67,13 +84,15 @@ _yadm-perms() {
}
_yadm-transcrypt() {
integer ret=1
_call_function ret _transcrypt
return ret
integer _ret=1
_call_function _ret _transcrypt
return _ret
}
_yadm-upgrade() {
return 0
_arguments \
'-f[force deinit of submodules]' \
': '
}
_yadm-version() {
@ -81,37 +100,38 @@ _yadm-version() {
}
_yadm_commands() {
local -a commands
commands=(
alt:'create links for alternates (yadm)'
bootstrap:'execute bootstrap (yadm)'
clone:'clone an existing repository (yadm)'
local -a commands=(
alt:'create links for alternates'
bootstrap:'execute bootstrap'
clone:'clone an existing yadm repository'
config:'configure an yadm setting'
decrypt:'decrypt files (yadm)'
encrypt:'encrypt files (yadm)'
decrypt:'decrypt files'
encrypt:'encrypt files'
enter:'run sub-shell with GIT variables set'
git-crypt:'run git-crypt commands for the yadm repository'
gitconfig:'run the git config command'
help:'display yadm help information'
init:'initialize an empty yadm repository'
list:'list files tracked by yadm'
perms:'fix perms for private files (yadm)'
perms:'fix perms for private files'
transcrypt:'run transcrypt commands for the yadm repository'
upgrade:'upgrade legacy yadm paths'
version:'show yadm version'
)
zstyle ':completion:*:*:yadm:*' user-commands $commands
local oldcontext="$curcontext"
local curcontext="${curcontext%:*:*}:git:"
integer ret=1
_call_function ret _git_commands
words=("git" "${words[-1]}") CURRENT=2 service=git _git
zstyle -d ':completion:*:*:yadm:*' user-commands
return ret
curcontext="$oldcontext"
_describe -t yadm "yadm commands" commands
return 0
}
_yadm() {
local curcontext=$curcontext state line
local curcontext=$curcontext state state_descr line
declare -A opt_args
_arguments -C \
@ -131,33 +151,30 @@ _yadm() {
(( $+opt_args[--yadm-repo] )) && repo_args+=(--yadm-repo "$opt_args[--yadm-repo]")
(( $+opt_args[--yadm-data] )) && repo_args+=(--yadm-data "$opt_args[--yadm-data]")
local -x GIT_DIR="$(_call_program gitdir yadm "${repo_args[@]}" introspect repo)"
[[ -z "$GIT_DIR" ]] && return 1
integer ret=1
integer _ret=1
case $state in
(command)
_yadm_commands && ret=0
_yadm_commands && _ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:yadm-$words[1]:
curcontext=${curcontext%:*:*}:yadm-${words[1]}:
if ! _call_function _ret _yadm-${words[1]}; then
if ! _call_function ret _yadm-$words[1]; then
curcontext=${curcontext%:*:*}:git-$words[1]:
if ! _call_function ret _git-$words[1]; then
if [[ $words[1] = \!* ]]; then
words[1]=${words[1]##\!}
_normal && ret=0
elif zstyle -T :completion:$curcontext: use-fallback; then
_default && ret=0
else
_message "unknown sub-command: $words[1]"
fi
fi
# Translate gitconfig to use the regular completion for config
[[ ${words[1]} = "gitconfig" ]] && words[1]=config
words=("git" "${(@)words}")
CURRENT=$(( CURRENT + 1 ))
curcontext=${curcontext%:*:*}:git:
service=git _git && _ret=0
fi
;;
esac
return ret
return _ret
}
(( $+functions[_git_commands] )) || _git
_yadm "$@"
(( $+functions[_git] )) && _yadm

View File

@ -0,0 +1,24 @@
#!/bin/bash
# Save this file as ~/.config/yadm/bootstrap and make it executable. It will
# execute all executable files (excluding templates and editor backups) in the
# ~/.config/yadm/bootstrap.d directory when run.
set -eu
# Directory to look for bootstrap executables in
BOOTSTRAP_D="${BASH_SOURCE[0]}.d"
if [[ ! -d "$BOOTSTRAP_D" ]]; then
echo "Error: bootstrap directory '$BOOTSTRAP_D' not found" >&2
exit 1
fi
find -L "$BOOTSTRAP_D" -type f | sort | while IFS= read -r bootstrap; do
if [[ -x "$bootstrap" && ! "$bootstrap" =~ "##" && ! "$bootstrap" =~ "~$" ]]; then
if ! "$bootstrap"; then
echo "Error: bootstrap '$bootstrap' failed" >&2
exit 1
fi
fi
done

View File

@ -0,0 +1,9 @@
## Contributed Commands
Although these commands are available as part of the official
**yadm** source tree, they have a somewhat different status. The intention is to
keep interesting and potentially useful commands here, building a library of
examples that might help others.
I recommend *careful review* of any code from here before using it. No
guarantees of code quality is assumed.

71
contrib/commands/yadm-untracked Executable file
View File

@ -0,0 +1,71 @@
#!/usr/bin/env bash
# To run: `yadm-untracked <config-file>`
#
# If you wish to create a YADM alias to run this as, for example `yadm untracked`
# then the following command will add the alias:
# `yadm gitconfig alias.untracked '!<PATH>/yadm-untracked'`
# Possible script improvements:
# - Reduce the amount of configuration; I have not figured out a way to
# get rid of the non-recursive and ignore. The recursive list could be
# built from the directories that are present in `yadm list`
# Configuration... The script looks at the following 3 arrays:
#
# yadm_tracked_recursively
# The directories and files in this list are searched recursively to build
# a list of files that you expect are tracked with `yadm`. Items in this
# list are relative to the root of your YADM repo (which is $HOME for most).
# yadm_tracked_nonrecursively
# Same as above but don't search recursively
#
# ignore_files_and_dirs
# A list of directories and files that will not be reported as untracked if
# found in the above two searches.
#
# Example configuration file (uncomment it to use):
# yadm_tracked_recursively=(
# bin .config .vim
# )
#
# yadm_tracked_nonrecursively=(
# ~
# )
#
# ignore_files_and_dirs=(
# .CFUserTextEncoding .DS_Store .config/gh
# .vim/autoload/plug.vim
# )
if [[ $# -ne 1 ]]; then
echo 'Usage: yadm-untracked <config-file>'
exit 1
fi
yadm_tracked_recursively=()
yadm_tracked_nonrecursively=()
ignore_files_and_dirs=()
source $1
root=`yadm enter echo '$GIT_WORK_TREE'`
cd $root
find_list=$(mktemp -t find_list)
find ${yadm_tracked_recursively[*]} -type f >$find_list
find ${yadm_tracked_nonrecursively[*]} -maxdepth 1 -type f |
awk "{sub(\"^\./\", \"\"); sub(\"^$root/\", \"\"); print }" >>$find_list
sort -o $find_list $find_list
yadm_list=$(mktemp -t yadm_list)
yadm list >$yadm_list
find ${ignore_files_and_dirs[*]} -type f >>$yadm_list
sort -o $yadm_list $yadm_list
# Show the files not in `yadm list`
comm -23 $find_list $yadm_list
rm -f $find_list $yadm_list

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# yadm - Yet Another Dotfiles Manager
# Copyright (C) 2015-2020 Tim Byrne and Martin Zuther
# Copyright (C) 2015-2021 Tim Byrne and Martin Zuther
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# yadm - Yet Another Dotfiles Manager
# Copyright (C) 2015-2020 Tim Byrne and Martin Zuther
# Copyright (C) 2015-2021 Tim Byrne and Martin Zuther
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# yadm - Yet Another Dotfiles Manager
# Copyright (C) 2015-2020 Tim Byrne and Martin Zuther
# Copyright (C) 2015-2021 Tim Byrne and Martin Zuther
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@ -8,7 +8,7 @@ max-attributes=8
max-statements=65
[SIMILARITIES]
min-similarity-lines=6
min-similarity-lines=8
[MESSAGES CONTROL]
disable=redefined-outer-name

View File

@ -2,8 +2,8 @@ FROM ubuntu:18.04
MAINTAINER Tim Byrne <sultan@locehilios.com>
# Shellcheck and esh versions
ARG SC_VER=0.7.1
ARG ESH_VER=0.3.0
ARG SC_VER=0.8.0
ARG ESH_VER=0.3.1
# Install prerequisites and configure UTF-8 locale
RUN \

View File

@ -25,7 +25,7 @@ def pytest_addoption(parser):
@pytest.fixture(scope='session')
def shellcheck_version():
"""Version of shellcheck supported"""
return '0.7.1'
return '0.8.0'
@pytest.fixture(scope='session')
@ -68,12 +68,29 @@ def tst_distro(runner):
return distro
@pytest.fixture(scope='session')
def tst_distro_family(runner):
"""Test session's distro_family"""
family = ''
with contextlib.suppress(Exception):
run = runner(command=[
'grep', '-oP', r'ID_LIKE=\K.+', '/etc/os-release'], report=False)
family = run.out.strip()
return family
@pytest.fixture(scope='session')
def tst_sys():
"""Test session's uname value"""
return platform.system()
@pytest.fixture(scope='session')
def tst_arch():
"""Test session's uname value"""
return platform.machine()
@pytest.fixture(scope='session')
def supported_commands():
"""List of supported commands
@ -109,6 +126,7 @@ def supported_configs():
This list should be updated every time yadm learns a new config.
"""
return [
'local.arch',
'local.class',
'local.hostname',
'local.os',

View File

@ -82,25 +82,32 @@ def test_relative_link(runner, paths, yadm_alt):
@pytest.mark.parametrize('suffix', [
'##default',
'##default,e.txt', '##default,extension.txt',
'##a.$tst_arch', '##arch.$tst_arch',
'##o.$tst_sys', '##os.$tst_sys',
'##d.$tst_distro', '##distro.$tst_distro',
'##f.$tst_distro_family', '##distro_family.$tst_distro_family',
'##c.$tst_class', '##class.$tst_class',
'##h.$tst_host', '##hostname.$tst_host',
'##u.$tst_user', '##user.$tst_user',
])
def test_alt_conditions(
runner, paths,
tst_sys, tst_distro, tst_host, tst_user, suffix):
tst_arch, tst_sys, tst_distro, tst_distro_family, tst_host, tst_user,
suffix):
"""Test conditions supported by yadm alt"""
yadm_dir, yadm_data = setup_standard_yadm_dir(paths)
# set the class
tst_class = 'testclass'
utils.set_local(paths, 'class', tst_class)
utils.set_local(paths, 'class', tst_class + ".before")
utils.set_local(paths, 'class', tst_class, add=True)
utils.set_local(paths, 'class', tst_class + ".after", add=True)
suffix = string.Template(suffix).substitute(
tst_arch=tst_arch,
tst_sys=tst_sys,
tst_distro=tst_distro,
tst_distro_family=tst_distro_family,
tst_class=tst_class,
tst_host=tst_host,
tst_user=tst_user,

View File

@ -27,5 +27,9 @@ def test_bootstrap(
paths.bootstrap.chmod(0o775)
run = runner(command=yadm_cmd('bootstrap'))
assert run.code == code
assert run.err == ''
assert expect in run.out
if exists and executable:
assert run.err == ''
assert expect in run.out
else:
assert expect in run.err
assert run.out == ''

View File

@ -7,5 +7,5 @@ def test_clean_command(runner, yadm_cmd):
# do nothing, this is a dangerous Git command when managing dot files
# report the command as disabled and exit as a failure
assert run.failure
assert run.err == ''
assert 'disabled' in run.out
assert run.out == ''
assert 'disabled' in run.err

View File

@ -58,14 +58,14 @@ def test_clone(
if not good_remote:
# clone should fail
assert run.failure
assert run.err != ''
assert 'Unable to fetch origin' in run.out
assert run.out == ''
assert 'Unable to clone the repository' in run.err
assert not paths.repo.exists()
elif repo_exists and not force:
# can't overwrite data
assert run.failure
assert run.err == ''
assert 'Git repo already exists' in run.out
assert run.out == ''
assert 'Git repo already exists' in run.err
else:
# clone should succeed, and repo should be configured properly
assert successful_clone(run, paths, repo_config)
@ -76,8 +76,7 @@ def test_clone(
# ensure conflicts are handled properly
if conflicts:
assert 'NOTE' in run.out
assert 'Merging origin/master failed' in run.out
assert 'Conflicts preserved' in run.out
assert 'Local files with content that differs' in run.out
# confirm correct Git origin
run = runner(
@ -89,26 +88,19 @@ def test_clone(
# ensure conflicts are really preserved
if conflicts:
# test to see if the work tree is actually "clean"
# test that the conflicts are preserved in the work tree
run = runner(
command=yadm_cmd('status', '-uno', '--porcelain'),
cwd=paths.work)
assert run.success
assert run.err == ''
assert run.out == '', 'worktree has unexpected changes'
assert str(ds1.tracked[0].path) in run.out
# test to see if the conflicts are stashed
run = runner(command=yadm_cmd('stash', 'list'), cwd=paths.work)
# verify content of the conflicts
run = runner(command=yadm_cmd('diff'), cwd=paths.work)
assert run.success
assert run.err == ''
assert 'Conflicts preserved' in run.out, 'conflicts not stashed'
# verify content of the stashed conflicts
run = runner(
command=yadm_cmd('stash', 'show', '-p'), cwd=paths.work)
assert run.success
assert run.err == ''
assert '\n+conflict' in run.out, 'conflicts not stashed'
assert '\n+conflict' in run.out, 'conflict overwritten'
# another force-related assertion
if old_repo:
@ -242,20 +234,20 @@ def test_clone_perms(
f'initial private dir perms drwxrwxrwx.+.{private_type}',
run.out)
assert re.search(
f'pre-merge private dir perms drwxrwxrwx.+.{private_type}',
f'pre-checkout private dir perms drwxrwxrwx.+.{private_type}',
run.out)
assert re.search(
f'post-merge private dir perms drwxrwxrwx.+.{private_type}',
f'post-checkout private dir perms drwxrwxrwx.+.{private_type}',
run.out)
else:
# private directories which are created, should be done prior to
# merging, and with secure permissions.
# checkout, and with secure permissions.
assert 'initial private dir perms' not in run.out
assert re.search(
f'pre-merge private dir perms drwx------.+.{private_type}',
f'pre-checkout private dir perms drwx------.+.{private_type}',
run.out)
assert re.search(
f'post-merge private dir perms drwx------.+.{private_type}',
f'post-checkout private dir perms drwx------.+.{private_type}',
run.out)
# standard perms still apply afterwards unless disabled with auto.perms
@ -297,8 +289,8 @@ def test_alternate_branch(runner, paths, yadm_cmd, repo_config, branch):
if branch == 'invalid':
assert run.failure
assert 'ERROR: Clone failed' in run.out
assert f"'origin/{branch}' does not exist in {remote_url}" in run.out
assert 'ERROR: Unable to clone the repository' in run.err
assert f"Remote branch {branch} not found in upstream" in run.err
else:
assert successful_clone(run, paths, repo_config)
@ -321,7 +313,6 @@ def test_alternate_branch(runner, paths, yadm_cmd, repo_config, branch):
def successful_clone(run, paths, repo_config, expected_code=0):
"""Assert clone is successful"""
assert run.code == expected_code
assert 'Initialized' in run.out
assert oct(paths.repo.stat().mode).endswith('00'), 'Repo is not secured'
assert repo_config('core.bare') == 'false'
assert repo_config('status.showUntrackedFiles') == 'no'
@ -342,10 +333,11 @@ def remote(paths, ds1_repo_copy):
def test_no_repo(runner, yadm_cmd, ):
"""Test cloning without specifying a repo"""
run = runner(command=yadm_cmd('clone'))
run = runner(command=yadm_cmd('clone', '-f'))
assert run.failure
assert run.err == ''
assert 'ERROR: No repository provided' in run.out
assert run.out == ''
assert 'ERROR: Unable to clone the repository' in run.err
assert 'repository \'repo.git\' does not exist' in run.err
def verify_head(paths, branch):

View File

@ -1,27 +0,0 @@
"""Unit tests: _default_remote_branch()"""
import pytest
@pytest.mark.parametrize('condition', ['found', 'missing'])
def test(runner, paths, condition):
"""Test _default_remote_branch()"""
test_branch = 'test/branch'
output = f'ref: refs/heads/{test_branch}\\tHEAD\\n'
if condition == 'missing':
output = 'output that is missing ref'
script = f"""
YADM_TEST=1 source {paths.pgm}
function git() {{
printf '{output}';
printf 'mock stderr\\n' 1>&2
}}
_default_remote_branch URL
"""
print(condition)
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
if condition == 'found':
assert run.out.strip() == test_branch
else:
assert run.out.strip() == 'master'

View File

@ -212,7 +212,7 @@ def test_symmetric_encrypt(
assert run.err == ''
if missing_encrypt:
assert 'does not exist' in run.out
assert 'does not exist' in run.err
elif bad_phrase:
assert 'Invalid passphrase' in run.err
else:
@ -313,7 +313,7 @@ def test_asymmetric_encrypt(
runner, gnupg, paths.archive, encrypt_targets)
else:
assert run.failure
assert 'Unable to write' in run.out
assert 'Unable to write' in run.out if expect else run.err
if ask:
assert 'Enter the user ID' in run.out
@ -326,7 +326,7 @@ def test_multi_key(runner, yadm_cmd, gnupg):
# specify two encryption recipient
os.system(' '.join(yadm_cmd(
'config', 'yadm.gpg-recipient', f'"{KEY_NAME} second-key"')))
'config', 'yadm.gpg-recipient', f'"second-key {KEY_NAME}"')))
env = os.environ.copy()
env['GNUPGHOME'] = gnupg.home
@ -380,7 +380,7 @@ def test_asymmetric_decrypt(
assert paths.work.join(filename).read() == filename
else:
assert run.failure
assert 'Unable to extract encrypted files' in run.out
assert 'Unable to extract encrypted files' in run.err
@pytest.mark.parametrize(

View File

@ -35,13 +35,13 @@ def test_enter(runner, yadm_cmd, paths, shell, success):
run = runner(command=yadm_cmd('enter'), env=env)
assert run.success == success
assert run.err == ''
prompt = f'yadm shell ({paths.repo})'
if success:
assert run.out.startswith('Entering yadm repo')
assert run.out.rstrip().endswith('Leaving yadm repo')
if not success:
assert 'does not refer to an executable' in run.out
assert run.err == ''
else:
assert 'does not refer to an executable' in run.err
if 'env' in shell:
assert f'GIT_DIR={paths.repo}' in run.out
assert f'GIT_WORK_TREE={paths.work}' in run.out

View File

@ -42,7 +42,7 @@ def test_ext_encryption(runner, yadm, paths, tmpdir, crypt, cmd, var):
else:
assert run.success
assert run.out.strip() == 'ext-crypt ran'
assert run.err == ''
else:
assert run.failure
assert f"command '{pgm}' cannot be located" in run.out
assert run.err == ''
assert f"command '{pgm}' cannot be located" in run.err

View File

@ -45,18 +45,22 @@ def test_init(
# command args
args = ['init']
cwd = None
if alt_work:
args.extend(['-w', paths.work])
if force:
cwd = paths.work.dirname
args.extend(['-w', paths.work.basename])
else:
args.extend(['-w', paths.work])
if force:
args.append('-f')
# run init
run = runner(yadm_cmd(*args), env={'HOME': home})
assert run.err == ''
run = runner(yadm_cmd(*args), env={'HOME': home}, cwd=cwd)
if repo_present and not force:
assert run.failure
assert 'repo already exists' in run.out
assert 'repo already exists' in run.err
assert old_repo.isfile(), 'Missing original repo'
else:
assert run.success
@ -64,6 +68,8 @@ def test_init(
if repo_present:
assert not old_repo.isfile(), 'Original repo still exists'
else:
assert run.err == ''
if alt_work:
assert repo_config('core.worktree') == paths.work

View File

@ -32,26 +32,30 @@ YDATA = '.local/share/yadm'
'override archive',
'override bootstrap',
])
def test_config(runner, paths, override, expect):
@pytest.mark.parametrize(
'path', ['.', './override', 'override', '.override', '/override'], ids=[
'cwd', './relative', 'relative', 'hidden relative', 'absolute'
])
def test_config(runner, paths, override, expect, path):
"""Test configure_paths"""
opath = 'override'
matches = match_map()
args = []
if path.startswith('/'):
expected_path = path
else:
expected_path = str(paths.root.join(path))
args = [override, path] if override else []
if override == '-Y':
matches = match_map('/' + opath)
if override == '--yadm-data':
matches = match_map(None, '/' + opath)
matches = match_map(expected_path)
elif override == '--yadm-data':
matches = match_map(None, expected_path)
else:
matches = match_map()
if override:
args = [override, '/' + opath]
for ekey in expect.keys():
matches[ekey] = f'{expect[ekey]}="/{opath}"'
run_test(
runner, paths,
[override, opath],
['must specify a fully qualified'], 1)
for ekey in expect.keys():
matches[ekey] = f'{expect[ekey]}="{expected_path}"'
run_test(runner, paths, args, matches.values(), 0)
run_test(runner, paths, args, matches.values(), cwd=str(paths.root))
def match_map(yadm_dir=None, yadm_data=None):
@ -71,7 +75,7 @@ def match_map(yadm_dir=None, yadm_data=None):
}
def run_test(runner, paths, args, expected_matches, expected_code=0):
def run_test(runner, paths, args, expected_matches, cwd=None):
"""Run proces global args, and run configure_paths"""
argstring = ' '.join(['"'+a+'"' for a in args])
script = f"""
@ -83,8 +87,8 @@ def run_test(runner, paths, args, expected_matches, expected_code=0):
configure_paths
declare -p | grep -E '(YADM|GIT)_'
"""
run = runner(command=['bash'], inp=script)
assert run.code == expected_code
run = runner(command=['bash'], inp=script, cwd=cwd)
assert run.success
assert run.err == ''
for match in expected_matches:
assert match in run.out

View File

@ -51,14 +51,14 @@ def test_encrypt_decrypt(runner, paths, cipher, mode):
"""
run = runner(command=['bash'], inp=script)
assert run.err == ''
if cipher != 'bad':
assert run.success
assert run.out.startswith(cipher)
assert str(paths.archive) in run.out
assert run.err == ''
else:
assert run.failure
assert 'Unknown cipher' in run.out
assert 'Unknown cipher' in run.err
@pytest.mark.parametrize('condition', ['default', 'override'])

View File

@ -1,40 +0,0 @@
"""Unit tests: is_valid_branch_name"""
import pytest
# Git branches do not allow:
# * path component that begins with "."
# * double dot
# * "~", "^", ":", "\", space
# * end with a "/"
# * end with ".lock"
@pytest.mark.parametrize(
'branch, expected', [
('master', 'valid'),
('path/branch', 'valid'),
('path/.branch', 'invalid'),
('path..branch', 'invalid'),
('path~branch', 'invalid'),
('path^branch', 'invalid'),
('path:branch', 'invalid'),
('path\\branch', 'invalid'),
('path branch', 'invalid'),
('path/branch/', 'invalid'),
('branch.lock', 'invalid'),
])
def test_is_valid_branch_name(runner, yadm, branch, expected):
"""Test function is_valid_branch_name()"""
script = f"""
YADM_TEST=1 source {yadm}
if is_valid_branch_name "{branch}"; then
echo valid
else
echo invalid
fi
"""
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
assert run.out.strip() == expected

View File

@ -0,0 +1,26 @@
"""Unit tests: query_distro_family"""
import pytest
@pytest.mark.parametrize(
'condition', ['os-release', 'os-release-quotes', 'missing'])
def test_query_distro_family(runner, yadm, tmp_path, condition):
"""Match ID_LIKE when present"""
test_family = 'testfamily'
os_release = tmp_path.joinpath('os-release')
if 'os-release' in condition:
quotes = '"' if 'quotes' in condition else ''
os_release.write_text(
f"testing\nID_LIKE={quotes}{test_family}{quotes}\nfamily")
script = f"""
YADM_TEST=1 source {yadm}
OS_RELEASE="{os_release}"
query_distro_family
"""
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
if 'os-release' in condition:
assert run.out.rstrip() == test_family
else:
assert run.out.rstrip() == ''

View File

@ -6,25 +6,33 @@ CONDITION = {
'labels': ['default'],
'modifier': 0,
},
'arch': {
'labels': ['a', 'arch'],
'modifier': 1,
},
'system': {
'labels': ['o', 'os'],
'modifier': 1,
'modifier': 2,
},
'distro': {
'labels': ['d', 'distro'],
'modifier': 2,
'modifier': 4,
},
'distro_family': {
'labels': ['f', 'distro_family'],
'modifier': 8,
},
'class': {
'labels': ['c', 'class'],
'modifier': 4,
'modifier': 16,
},
'hostname': {
'labels': ['h', 'hostname'],
'modifier': 8,
'modifier': 32,
},
'user': {
'labels': ['u', 'user'],
'modifier': 16,
'modifier': 64,
},
}
TEMPLATE_LABELS = ['t', 'template', 'yadm']
@ -44,6 +52,12 @@ def calculate_score(filename):
label, value = condition.split('.', 1)
if label in CONDITION['default']['labels']:
score += 1000
elif label in CONDITION['arch']['labels']:
if value == 'testarch':
score += 1000 + CONDITION['arch']['modifier']
else:
score = 0
break
elif label in CONDITION['system']['labels']:
if value == 'testsystem':
score += 1000 + CONDITION['system']['modifier']
@ -82,6 +96,8 @@ def calculate_score(filename):
@pytest.mark.parametrize(
'default', ['default', None], ids=['default', 'no-default'])
@pytest.mark.parametrize(
'arch', ['arch', None], ids=['arch', 'no-arch'])
@pytest.mark.parametrize(
'system', ['system', None], ids=['system', 'no-system'])
@pytest.mark.parametrize(
@ -93,10 +109,11 @@ def calculate_score(filename):
@pytest.mark.parametrize(
'user', ['user', None], ids=['user', 'no-user'])
def test_score_values(
runner, yadm, default, system, distro, cla, host, user):
runner, yadm, default, arch, system, distro, cla, host, user):
"""Test score results"""
# pylint: disable=too-many-branches
local_class = 'testclass'
local_arch = 'testarch'
local_system = 'testsystem'
local_distro = 'testdistro'
local_host = 'testhost'
@ -111,6 +128,18 @@ def test_score_values(
newfile += ','
newfile += label
filenames[newfile] = calculate_score(newfile)
if arch:
for filename in list(filenames):
for match in [True, False]:
for label in CONDITION[arch]['labels']:
newfile = filename
if not newfile.endswith('##'):
newfile += ','
newfile += '.'.join([
label,
local_arch if match else 'badarch'
])
filenames[newfile] = calculate_score(newfile)
if system:
for filename in list(filenames):
for match in [True, False]:
@ -176,6 +205,8 @@ def test_score_values(
YADM_TEST=1 source {yadm}
score=0
local_class={local_class}
local_classes=({local_class})
local_arch={local_arch}
local_system={local_system}
local_distro={local_distro}
local_host={local_host}
@ -221,6 +252,7 @@ def test_extensions(runner, yadm, ext):
def test_score_values_templates(runner, yadm):
"""Test score results"""
local_class = 'testclass'
local_arch = 'arch'
local_system = 'testsystem'
local_distro = 'testdistro'
local_host = 'testhost'
@ -239,6 +271,7 @@ def test_score_values_templates(runner, yadm):
YADM_TEST=1 source {yadm}
score=0
local_class={local_class}
local_arch={local_arch}
local_system={local_system}
local_distro={local_distro}
local_host={local_host}
@ -282,3 +315,37 @@ def test_template_recording(runner, yadm, cmd_generated):
assert run.success
assert run.err == ''
assert run.out.rstrip() == expected
def test_underscores_in_distro_and_family(runner, yadm):
"""Test replacing spaces in distro / distro_family with underscores"""
local_distro = 'test distro'
local_distro_family = 'test family'
filenames = {
'filename##distro.test distro': 1004,
'filename##distro.test-distro': 0,
'filename##distro.test_distro': 1004,
'filename##distro_family.test family': 1008,
'filename##distro_family.test-family': 0,
'filename##distro_family.test_family': 1008,
}
script = f"""
YADM_TEST=1 source {yadm}
score=0
local_distro="{local_distro}"
local_distro_family="{local_distro_family}"
"""
expected = ''
for filename in filenames:
script += f"""
score_file "{filename}"
echo "{filename}"
echo "$score"
"""
expected += filename + '\n'
expected += str(filenames[filename]) + '\n'
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
assert run.out == expected

View File

@ -7,6 +7,7 @@ import utils
'override', [
False,
'class',
'arch',
'os',
'hostname',
'user',
@ -14,6 +15,7 @@ import utils
ids=[
'no-override',
'override-class',
'override-arch',
'override-os',
'override-hostname',
'override-user',
@ -21,7 +23,7 @@ import utils
)
@pytest.mark.usefixtures('ds1_copy')
def test_set_local_alt_values(
runner, yadm, paths, tst_sys, tst_host, tst_user, override):
runner, yadm, paths, tst_arch, tst_sys, tst_host, tst_user, override):
"""Use issue_legacy_path_warning"""
script = f"""
YADM_TEST=1 source {yadm} &&
@ -29,12 +31,16 @@ def test_set_local_alt_values(
YADM_DIR={paths.yadm} YADM_DATA={paths.data} configure_paths &&
set_local_alt_values
echo "class='$local_class'"
echo "arch='$local_arch'"
echo "os='$local_system'"
echo "host='$local_host'"
echo "user='$local_user'"
"""
if override:
if override == 'class':
utils.set_local(paths, override, 'first')
utils.set_local(paths, override, 'override', add=True)
elif override:
utils.set_local(paths, override, 'override')
run = runner(command=['bash'], inp=script)
@ -46,6 +52,11 @@ def test_set_local_alt_values(
else:
assert "class=''" in run.out
if override == 'arch':
assert "arch='override'" in run.out
else:
assert f"arch='{tst_arch}'" in run.out
if override == 'os':
assert "os='override'" in run.out
else:
@ -62,16 +73,20 @@ def test_set_local_alt_values(
assert f"user='{tst_user}'" in run.out
def test_distro(runner, yadm):
"""Assert that local_distro is set"""
def test_distro_and_family(runner, yadm):
"""Assert that local_distro/local_distro_family are set"""
script = f"""
YADM_TEST=1 source {yadm}
function config() {{ echo "$1"; }}
function query_distro() {{ echo "testdistro"; }}
function query_distro_family() {{ echo "testfamily"; }}
set_local_alt_values
echo "distro='$local_distro'"
echo "distro_family='$local_distro_family'"
"""
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
assert run.out.strip() == "distro='testdistro'"
assert "distro='testdistro'" in run.out
assert "distro_family='testfamily'" in run.out

View File

@ -5,17 +5,23 @@ FILE_MODE = 0o754
# these values are also testing the handling of bizarre characters
LOCAL_CLASS = "default_Test+@-!^Class"
LOCAL_CLASS2 = "default_Test+@-|^2nd_Class withSpace"
LOCAL_ARCH = "default_Test+@-!^Arch"
LOCAL_SYSTEM = "default_Test+@-!^System"
LOCAL_HOST = "default_Test+@-!^Host"
LOCAL_USER = "default_Test+@-!^User"
LOCAL_DISTRO = "default_Test+@-!^Distro"
LOCAL_DISTRO_FAMILY = "default_Test+@-!^Family"
TEMPLATE = f'''
start of template
default class = >{{{{yadm.class}}}}<
default os = >{{{{yadm.os}}}}<
default host = >{{{{yadm.hostname}}}}<
default user = >{{{{yadm.user}}}}<
default distro = >{{{{yadm.distro}}}}<
default class = >{{{{yadm.class}}}}<
default arch = >{{{{yadm.arch}}}}<
default os = >{{{{yadm.os}}}}<
default host = >{{{{yadm.hostname}}}}<
default user = >{{{{yadm.user}}}}<
default distro = >{{{{yadm.distro}}}}<
default distro_family = >{{{{yadm.distro_family}}}}<
classes = >{{{{yadm.classes}}}}<
{{% if yadm.class == "else1" %}}
wrong else 1
{{% else %}}
@ -30,9 +36,21 @@ Multiple lines
{{% else %}}
Should not be included...
{{% endif %}}
{{% if yadm.class == "{LOCAL_CLASS2}" %}}
Included section for second class
{{% endif %}}
{{% if yadm.class == "wrongclass2" %}}
wrong class 2
{{% endif %}}
{{% if yadm.arch == "wrongarch1" %}}
wrong arch 1
{{% endif %}}
{{% if yadm.arch == "{LOCAL_ARCH}" %}}
Included section for arch = {{{{yadm.arch}}}} ({{{{yadm.arch}}}} repeated)
{{% endif %}}
{{% if yadm.arch == "wrongarch2" %}}
wrong arch 2
{{% endif %}}
{{% if yadm.os == "wrongos1" %}}
wrong os 1
{{% endif %}}
@ -69,22 +87,40 @@ Included section for distro = {{{{yadm.distro}}}} ({{{{yadm.distro}}}} again)
{{% if yadm.distro == "wrongdistro2" %}}
wrong distro 2
{{% endif %}}
{{% if yadm.distro_family == "wrongfamily1" %}}
wrong family 1
{{% endif %}}
{{% if yadm.distro_family == "{LOCAL_DISTRO_FAMILY}" %}}
Included section for distro_family = \
{{{{yadm.distro_family}}}} ({{{{yadm.distro_family}}}} again)
{{% endif %}}
{{% if yadm.distro_family == "wrongfamily2" %}}
wrong family 2
{{% endif %}}
end of template
'''
EXPECTED = f'''
start of template
default class = >{LOCAL_CLASS}<
default os = >{LOCAL_SYSTEM}<
default host = >{LOCAL_HOST}<
default user = >{LOCAL_USER}<
default distro = >{LOCAL_DISTRO}<
default class = >{LOCAL_CLASS}<
default arch = >{LOCAL_ARCH}<
default os = >{LOCAL_SYSTEM}<
default host = >{LOCAL_HOST}<
default user = >{LOCAL_USER}<
default distro = >{LOCAL_DISTRO}<
default distro_family = >{LOCAL_DISTRO_FAMILY}<
classes = >{LOCAL_CLASS2}
{LOCAL_CLASS}<
Included section from else
Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Multiple lines
Included section for second class
Included section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated)
Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
Included section for distro_family = \
{LOCAL_DISTRO_FAMILY} ({LOCAL_DISTRO_FAMILY} again)
end of template
'''
@ -127,14 +163,23 @@ def test_template_default(runner, yadm, tmpdir):
input_file.chmod(FILE_MODE)
output_file = tmpdir.join('output')
# ensure overwrite works when file exists as read-only (there is some
# special processing when this is encountered because some environments do
# not properly overwrite read-only files)
output_file.write('existing')
output_file.chmod(0o400)
script = f"""
YADM_TEST=1 source {yadm}
set_awk
local_class="{LOCAL_CLASS}"
local_classes=("{LOCAL_CLASS2}" "{LOCAL_CLASS}")
local_arch="{LOCAL_ARCH}"
local_system="{LOCAL_SYSTEM}"
local_host="{LOCAL_HOST}"
local_user="{LOCAL_USER}"
local_distro="{LOCAL_DISTRO}"
local_distro_family="{LOCAL_DISTRO_FAMILY}"
template_default "{input_file}" "{output_file}"
"""
run = runner(command=['bash'], inp=script)
@ -196,3 +241,22 @@ def test_include(runner, yadm, tmpdir):
assert run.err == ''
assert output_file.read() == EXPECTED_INCLUDE
assert os.stat(output_file).st_mode == os.stat(input_file).st_mode
def test_env(runner, yadm, tmpdir):
"""Test env"""
input_file = tmpdir.join('input')
input_file.write('{{env.PWD}}', ensure=True)
input_file.chmod(FILE_MODE)
output_file = tmpdir.join('output')
script = f"""
YADM_TEST=1 source {yadm}
set_awk
template_default "{input_file}" "{output_file}"
"""
run = runner(command=['bash'], inp=script)
assert run.success
assert run.err == ''
assert output_file.read().strip() == os.environ['PWD']

View File

@ -4,31 +4,50 @@ import os
FILE_MODE = 0o754
LOCAL_CLASS = "esh_Test+@-!^Class"
LOCAL_CLASS2 = "esh_Test+@-|^2nd_Class withSpace"
LOCAL_ARCH = "esh_Test+@-!^Arch"
LOCAL_SYSTEM = "esh_Test+@-!^System"
LOCAL_HOST = "esh_Test+@-!^Host"
LOCAL_USER = "esh_Test+@-!^User"
LOCAL_DISTRO = "esh_Test+@-!^Distro"
LOCAL_DISTRO_FAMILY = "esh_Test+@-!^Family"
TEMPLATE = f'''
start of template
esh class = ><%=$YADM_CLASS%><
esh os = ><%=$YADM_OS%><
esh host = ><%=$YADM_HOSTNAME%><
esh user = ><%=$YADM_USER%><
esh distro = ><%=$YADM_DISTRO%><
esh class = ><%=$YADM_CLASS%><
esh arch = ><%=$YADM_ARCH%><
esh os = ><%=$YADM_OS%><
esh host = ><%=$YADM_HOSTNAME%><
esh user = ><%=$YADM_USER%><
esh distro = ><%=$YADM_DISTRO%><
esh distro_family = ><%=$YADM_DISTRO_FAMILY%><
esh classes = ><%=$YADM_CLASSES%><
<% if [ "$YADM_CLASS" = "wrongclass1" ]; then -%>
wrong class 1
<% fi -%>
<% if [ "$YADM_CLASS" = "{LOCAL_CLASS}" ]; then -%>
Included section for class = <%=$YADM_CLASS%> (<%=$YADM_CLASS%> repeated)
Included esh section for class = <%=$YADM_CLASS%> (<%=$YADM_CLASS%> repeated)
<% fi -%>
<% if [ "$YADM_CLASS" = "wrongclass2" ]; then -%>
wrong class 2
<% fi -%>
<% echo "$YADM_CLASSES" | while IFS='' read cls; do
if [ "$cls" = "{LOCAL_CLASS2}" ]; then -%>
Included esh section for second class
<% fi; done -%>
<% if [ "$YADM_ARCH" = "wrongarch1" ]; then -%>
wrong arch 1
<% fi -%>
<% if [ "$YADM_ARCH" = "{LOCAL_ARCH}" ]; then -%>
Included esh section for arch = <%=$YADM_ARCH%> (<%=$YADM_ARCH%> repeated)
<% fi -%>
<% if [ "$YADM_ARCH" = "wrongarch2" ]; then -%>
wrong arch 2
<% fi -%>
<% if [ "$YADM_OS" = "wrongos1" ]; then -%>
wrong os 1
<% fi -%>
<% if [ "$YADM_OS" = "{LOCAL_SYSTEM}" ]; then -%>
Included section for os = <%=$YADM_OS%> (<%=$YADM_OS%> repeated)
Included esh section for os = <%=$YADM_OS%> (<%=$YADM_OS%> repeated)
<% fi -%>
<% if [ "$YADM_OS" = "wrongos2" ]; then -%>
wrong os 2
@ -37,7 +56,7 @@ wrong os 2
wrong host 1
<% fi -%>
<% if [ "$YADM_HOSTNAME" = "{LOCAL_HOST}" ]; then -%>
Included section for host = <%=$YADM_HOSTNAME%> (<%=$YADM_HOSTNAME%> again)
Included esh section for host = <%=$YADM_HOSTNAME%> (<%=$YADM_HOSTNAME%> again)
<% fi -%>
<% if [ "$YADM_HOSTNAME" = "wronghost2" ]; then -%>
wrong host 2
@ -46,7 +65,7 @@ wrong host 2
wrong user 1
<% fi -%>
<% if [ "$YADM_USER" = "{LOCAL_USER}" ]; then -%>
Included section for user = <%=$YADM_USER%> (<%=$YADM_USER%> repeated)
Included esh section for user = <%=$YADM_USER%> (<%=$YADM_USER%> repeated)
<% fi -%>
<% if [ "$YADM_USER" = "wronguser2" ]; then -%>
wrong user 2
@ -55,25 +74,42 @@ wrong user 2
wrong distro 1
<% fi -%>
<% if [ "$YADM_DISTRO" = "{LOCAL_DISTRO}" ]; then -%>
Included section for distro = <%=$YADM_DISTRO%> (<%=$YADM_DISTRO%> again)
Included esh section for distro = <%=$YADM_DISTRO%> (<%=$YADM_DISTRO%> again)
<% fi -%>
<% if [ "$YADM_DISTRO" = "wrongdistro2" ]; then -%>
wrong distro 2
<% fi -%>
<% if [ "$YADM_DISTRO_FAMILY" = "wrongfamily1" ]; then -%>
wrong family 1
<% fi -%>
<% if [ "$YADM_DISTRO_FAMILY" = "{LOCAL_DISTRO_FAMILY}" ]; then -%>
Included esh section for distro_family = \
<%=$YADM_DISTRO_FAMILY%> (<%=$YADM_DISTRO_FAMILY%> again)
<% fi -%>
<% if [ "$YADM_DISTRO" = "wrongfamily2" ]; then -%>
wrong family 2
<% fi -%>
end of template
'''
EXPECTED = f'''
start of template
esh class = >{LOCAL_CLASS}<
esh os = >{LOCAL_SYSTEM}<
esh host = >{LOCAL_HOST}<
esh user = >{LOCAL_USER}<
esh distro = >{LOCAL_DISTRO}<
Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
esh class = >{LOCAL_CLASS}<
esh arch = >{LOCAL_ARCH}<
esh os = >{LOCAL_SYSTEM}<
esh host = >{LOCAL_HOST}<
esh user = >{LOCAL_USER}<
esh distro = >{LOCAL_DISTRO}<
esh distro_family = >{LOCAL_DISTRO_FAMILY}<
esh classes = >{LOCAL_CLASS2} {LOCAL_CLASS}<
Included esh section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Included esh section for second class
Included esh section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated)
Included esh section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included esh section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included esh section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included esh section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
Included esh section for distro_family = \
{LOCAL_DISTRO_FAMILY} ({LOCAL_DISTRO_FAMILY} again)
end of template
'''
@ -86,13 +122,22 @@ def test_template_esh(runner, yadm, tmpdir):
input_file.chmod(FILE_MODE)
output_file = tmpdir.join('output')
# ensure overwrite works when file exists as read-only (there is some
# special processing when this is encountered because some environments do
# not properly overwrite read-only files)
output_file.write('existing')
output_file.chmod(0o400)
script = f"""
YADM_TEST=1 source {yadm}
local_class="{LOCAL_CLASS}"
local_classes=("{LOCAL_CLASS2}" "{LOCAL_CLASS}")
local_arch="{LOCAL_ARCH}"
local_system="{LOCAL_SYSTEM}"
local_host="{LOCAL_HOST}"
local_user="{LOCAL_USER}"
local_distro="{LOCAL_DISTRO}"
local_distro_family="{LOCAL_DISTRO_FAMILY}"
template_esh "{input_file}" "{output_file}"
"""
run = runner(command=['bash'], inp=script)

View File

@ -5,31 +5,50 @@ import pytest
FILE_MODE = 0o754
LOCAL_CLASS = "j2_Test+@-!^Class"
LOCAL_CLASS2 = "j2_Test+@-|^2nd_Class withSpace"
LOCAL_ARCH = "j2_Test+@-!^Arch"
LOCAL_SYSTEM = "j2_Test+@-!^System"
LOCAL_HOST = "j2_Test+@-!^Host"
LOCAL_USER = "j2_Test+@-!^User"
LOCAL_DISTRO = "j2_Test+@-!^Distro"
LOCAL_DISTRO_FAMILY = "j2_Test+@-!^Family"
TEMPLATE = f'''
start of template
j2 class = >{{{{YADM_CLASS}}}}<
j2 os = >{{{{YADM_OS}}}}<
j2 host = >{{{{YADM_HOSTNAME}}}}<
j2 user = >{{{{YADM_USER}}}}<
j2 distro = >{{{{YADM_DISTRO}}}}<
j2 class = >{{{{YADM_CLASS}}}}<
j2 arch = >{{{{YADM_ARCH}}}}<
j2 os = >{{{{YADM_OS}}}}<
j2 host = >{{{{YADM_HOSTNAME}}}}<
j2 user = >{{{{YADM_USER}}}}<
j2 distro = >{{{{YADM_DISTRO}}}}<
j2 distro_family = >{{{{YADM_DISTRO_FAMILY}}}}<
j2 classes = >{{{{YADM_CLASSES}}}}<
{{%- if YADM_CLASS == "wrongclass1" %}}
wrong class 1
{{%- endif %}}
{{%- if YADM_CLASS == "{LOCAL_CLASS}" %}}
Included section for class = {{{{YADM_CLASS}}}} ({{{{YADM_CLASS}}}} repeated)
Included j2 section for class = \
{{{{YADM_CLASS}}}} ({{{{YADM_CLASS}}}} repeated)
{{%- endif %}}
{{%- if YADM_CLASS == "wrongclass2" %}}
wrong class 2
{{%- endif %}}
{{%- if "{LOCAL_CLASS2}" in YADM_CLASSES.split("\\n") %}}
Included j2 section for second class
{{%- endif %}}
{{%- if YADM_ARCH == "wrongarch1" %}}
wrong arch 1
{{%- endif %}}
{{%- if YADM_ARCH == "{LOCAL_ARCH}" %}}
Included j2 section for arch = {{{{YADM_ARCH}}}} ({{{{YADM_ARCH}}}} repeated)
{{%- endif %}}
{{%- if YADM_ARCH == "wrongarch2" %}}
wrong arch 2
{{%- endif %}}
{{%- if YADM_OS == "wrongos1" %}}
wrong os 1
{{%- endif %}}
{{%- if YADM_OS == "{LOCAL_SYSTEM}" %}}
Included section for os = {{{{YADM_OS}}}} ({{{{YADM_OS}}}} repeated)
Included j2 section for os = {{{{YADM_OS}}}} ({{{{YADM_OS}}}} repeated)
{{%- endif %}}
{{%- if YADM_OS == "wrongos2" %}}
wrong os 2
@ -38,7 +57,8 @@ wrong os 2
wrong host 1
{{%- endif %}}
{{%- if YADM_HOSTNAME == "{LOCAL_HOST}" %}}
Included section for host = {{{{YADM_HOSTNAME}}}} ({{{{YADM_HOSTNAME}}}} again)
Included j2 section for host = \
{{{{YADM_HOSTNAME}}}} ({{{{YADM_HOSTNAME}}}} again)
{{%- endif %}}
{{%- if YADM_HOSTNAME == "wronghost2" %}}
wrong host 2
@ -47,7 +67,7 @@ wrong host 2
wrong user 1
{{%- endif %}}
{{%- if YADM_USER == "{LOCAL_USER}" %}}
Included section for user = {{{{YADM_USER}}}} ({{{{YADM_USER}}}} repeated)
Included j2 section for user = {{{{YADM_USER}}}} ({{{{YADM_USER}}}} repeated)
{{%- endif %}}
{{%- if YADM_USER == "wronguser2" %}}
wrong user 2
@ -56,25 +76,44 @@ wrong user 2
wrong distro 1
{{%- endif %}}
{{%- if YADM_DISTRO == "{LOCAL_DISTRO}" %}}
Included section for distro = {{{{YADM_DISTRO}}}} ({{{{YADM_DISTRO}}}} again)
Included j2 section for distro = \
{{{{YADM_DISTRO}}}} ({{{{YADM_DISTRO}}}} again)
{{%- endif %}}
{{%- if YADM_DISTRO == "wrongdistro2" %}}
wrong distro 2
{{%- endif %}}
{{%- if YADM_DISTRO_FAMILY == "wrongfamily1" %}}
wrong family 1
{{%- endif %}}
{{%- if YADM_DISTRO_FAMILY == "{LOCAL_DISTRO_FAMILY}" %}}
Included j2 section for distro_family = \
{{{{YADM_DISTRO_FAMILY}}}} ({{{{YADM_DISTRO_FAMILY}}}} again)
{{%- endif %}}
{{%- if YADM_DISTRO_FAMILY == "wrongfamily2" %}}
wrong family 2
{{%- endif %}}
end of template
'''
EXPECTED = f'''
start of template
j2 class = >{LOCAL_CLASS}<
j2 os = >{LOCAL_SYSTEM}<
j2 host = >{LOCAL_HOST}<
j2 user = >{LOCAL_USER}<
j2 distro = >{LOCAL_DISTRO}<
Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
j2 class = >{LOCAL_CLASS}<
j2 arch = >{LOCAL_ARCH}<
j2 os = >{LOCAL_SYSTEM}<
j2 host = >{LOCAL_HOST}<
j2 user = >{LOCAL_USER}<
j2 distro = >{LOCAL_DISTRO}<
j2 distro_family = >{LOCAL_DISTRO_FAMILY}<
j2 classes = >{LOCAL_CLASS2}
{LOCAL_CLASS}<
Included j2 section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
Included j2 section for second class
Included j2 section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated)
Included j2 section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
Included j2 section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
Included j2 section for user = {LOCAL_USER} ({LOCAL_USER} repeated)
Included j2 section for distro = {LOCAL_DISTRO} ({LOCAL_DISTRO} again)
Included j2 section for distro_family = \
{LOCAL_DISTRO_FAMILY} ({LOCAL_DISTRO_FAMILY} again)
end of template
'''
@ -88,13 +127,22 @@ def test_template_j2(runner, yadm, tmpdir, processor):
input_file.chmod(FILE_MODE)
output_file = tmpdir.join('output')
# ensure overwrite works when file exists as read-only (there is some
# special processing when this is encountered because some environments do
# not properly overwrite read-only files)
output_file.write('existing')
output_file.chmod(0o400)
script = f"""
YADM_TEST=1 source {yadm}
local_class="{LOCAL_CLASS}"
local_classes=("{LOCAL_CLASS2}" "{LOCAL_CLASS}")
local_arch="{LOCAL_ARCH}"
local_system="{LOCAL_SYSTEM}"
local_host="{LOCAL_HOST}"
local_user="{LOCAL_USER}"
local_distro="{LOCAL_DISTRO}"
local_distro_family="{LOCAL_DISTRO_FAMILY}"
template_{processor} "{input_file}" "{output_file}"
"""
run = runner(command=['bash'], inp=script)

View File

@ -29,12 +29,11 @@ def test_upgrade_errors(tmpdir, runner, yadm, condition):
"""
run = runner(command=['bash'], inp=script)
assert run.failure
assert run.err == ''
assert 'Unable to upgrade' in run.out
assert 'Unable to upgrade' in run.err
if condition in ['override', 'equal']:
assert 'Paths have been overridden' in run.out
if condition == 'existing_repo':
assert 'already exists' in run.out
assert 'Paths have been overridden' in run.err
elif condition == 'existing_repo':
assert 'already exists' in run.err
@pytest.mark.parametrize(
@ -59,12 +58,16 @@ def test_upgrade(tmpdir, runner, yadm, condition):
yadm_legacy.join(path).write(path, ensure=True)
mock_git = ""
if condition in ['tracked', 'submodules']:
if condition != 'no-paths':
mock_git = f'''
function git() {{
echo "$@"
if [[ "$*" == *.gitmodules* ]]; then
return { '0' if condition == 'submodules' else '1' }
if [[ "$*" = *"submodule status" ]]; then
{ 'echo " 1234567 mymodule (1.0)"'
if condition == 'submodules' else ':' }
fi
if [[ "$*" = *ls-files* ]]; then
return { 1 if condition == 'untracked' else 0 }
fi
return 0
}}
@ -111,8 +114,9 @@ def test_upgrade(tmpdir, runner, yadm, condition):
assert expected in run.out
assert 'files tracked by yadm have been renamed' in run.out
if condition == 'submodules':
assert 'submodule deinit -f .' in run.out
assert 'submodule update --init --recursive' in run.out
assert 'submodule deinit -- mymodule' in run.out
assert 'submodule update --init --recursive -- mymodule' \
in run.out
else:
assert 'submodule deinit -f .' not in run.out
assert 'submodule deinit' not in run.out
assert 'submodule update --init --recursive' not in run.out

View File

@ -27,13 +27,13 @@ def test_x_program(
# test require_[git,gpg]
script = f"""
YADM_TEST=1 source {paths.pgm}
YADM_CONFIG="{paths.config}"
YADM_OVERRIDE_CONFIG="{paths.config}"
configure_paths
require_{program}
echo ${program.upper()}_PROGRAM
"""
run = runner(command=['bash'], inp=script)
assert run.success == success
assert run.err == ''
# [GIT,GPG]_PROGRAM set correctly
if value == 'program':
@ -43,4 +43,6 @@ def test_x_program(
# error reported about bad config
if match:
assert match in run.out
assert match in run.err
else:
assert run.err == ''

129
test/test_upgrade.py Normal file
View File

@ -0,0 +1,129 @@
"""Test upgrade"""
import os
import pytest
@pytest.mark.parametrize(
'versions', [
('1.12.0', '2.5.0'),
('1.12.0',),
('2.5.0',),
], ids=[
'1.12.0 -> 2.5.0 -> latest',
'1.12.0 -> latest',
'2.5.0 -> latest',
])
@pytest.mark.parametrize(
'submodule', [False, True],
ids=['no submodule', 'with submodules'])
def test_upgrade(tmpdir, runner, versions, submodule):
"""Upgrade tests"""
# pylint: disable=too-many-statements
home = tmpdir.mkdir('HOME')
env = {'HOME': str(home)}
if submodule:
ext_repo = tmpdir.mkdir('ext_repo')
ext_repo.join('afile').write('some data')
for cmd in (('init',), ('add', 'afile'), ('commit', '-m', 'test')):
run = runner(['git', '-C', str(ext_repo), *cmd])
assert run.success
os.environ.pop('XDG_CONFIG_HOME', None)
os.environ.pop('XDG_DATA_HOME', None)
def run_version(version, *args, check_stderr=True):
yadm = 'yadm-%s' % version if version else '/yadm/yadm'
run = runner([yadm, *args], shell=True, cwd=str(home), env=env)
assert run.success
if check_stderr:
assert run.err == ''
return run
# Initialize the repo with the first version
first = versions[0]
run_version(first, 'init')
home.join('file').write('some data')
run_version(first, 'add', 'file')
run_version(first, 'commit', '-m', '"First commit"')
if submodule:
# When upgrading via 2.5.0 we can't have a submodule that's been added
# after being cloned as 2.5.0 fails the upgrade in that case.
can_upgrade_cloned_submodule = '2.5.0' not in versions[1:]
if can_upgrade_cloned_submodule:
# Check out a repo and then add it as a submodule
run = runner(['git', '-C', str(home), 'clone', str(ext_repo), 'b'])
assert run.success
run_version(first, 'submodule', 'add', str(ext_repo), 'b')
# Add submodule without first checking it out
run_version(first, 'submodule', 'add', str(ext_repo), 'a',
check_stderr=False)
run_version(first, 'submodule', 'add', str(ext_repo), 'c',
check_stderr=False)
run_version(first, 'commit', '-m', '"Add submodules"')
for path in ('.yadm', '.config/yadm'):
yadm_dir = home.join(path)
if yadm_dir.exists():
break
yadm_dir.join('bootstrap').write('init stuff')
run_version(first, 'add', yadm_dir.join('bootstrap'))
run_version(first, 'commit', '-m', 'bootstrap')
yadm_dir.join('encrypt').write('secret')
hooks_dir = yadm_dir.mkdir('hooks')
hooks_dir.join('pre_status').write('status')
hooks_dir.join('post_commit').write('commit')
run_version(first, 'config', 'local.class', 'test')
run_version(first, 'config', 'foo.bar', 'true')
# Run upgrade with intermediate versions and latest
latest = None
for version in versions[1:] + (latest,):
run = run_version(version, 'upgrade', check_stderr=not submodule)
if submodule:
lines = run.err.splitlines()
if can_upgrade_cloned_submodule:
assert 'Migrating git directory of' in lines[0]
assert str(home.join('b/.git')) in lines[1]
assert str(yadm_dir.join('repo.git/modules/b')) in lines[2]
del lines[:3]
for line in lines:
assert line.startswith('Submodule')
assert 'registered for path' in line
# Verify result for the final upgrade
run_version(latest, 'status')
run = run_version(latest, 'show', 'HEAD:file')
assert run.out == 'some data'
if submodule:
if can_upgrade_cloned_submodule:
assert home.join('b/afile').read() == 'some data'
assert home.join('a/afile').read() == 'some data'
assert home.join('c/afile').read() == 'some data'
yadm_dir = home.join('.config/yadm')
assert yadm_dir.join('bootstrap').read() == 'init stuff'
assert yadm_dir.join('encrypt').read() == 'secret'
hooks_dir = yadm_dir.join('hooks')
assert hooks_dir.join('pre_status').read() == 'status'
assert hooks_dir.join('post_commit').read() == 'commit'
run = run_version(latest, 'config', 'local.class')
assert run.out.rstrip() == 'test'
run = run_version(latest, 'config', 'foo.bar')
assert run.out.rstrip() == 'true'

View File

@ -29,8 +29,10 @@ def test_semantic_version(expected_version):
@pytest.mark.parametrize('cmd', ['--version', 'version'])
def test_reported_version(
runner, yadm_cmd, cmd, expected_version):
"""Report correct version"""
"""Report correct version and bash/git versions"""
run = runner(command=yadm_cmd(cmd))
assert run.success
assert run.err == ''
assert run.out == f'yadm {expected_version}\n'
assert 'bash version' in run.out
assert 'git version' in run.out
assert run.out.endswith(f'\nyadm version {expected_version}\n')

View File

@ -21,11 +21,12 @@ INCLUDE_DIRS = ['', 'test alt']
INCLUDE_CONTENT = '8780846c02e34c930d0afd127906668f'
def set_local(paths, variable, value):
def set_local(paths, variable, value, add=False):
"""Set local override"""
add = "--add" if add else ""
os.system(
f'GIT_DIR={str(paths.repo)} '
f'git config --local "local.{variable}" "{value}"'
f'git config --local {add} "local.{variable}" "{value}"'
)

604
yadm

File diff suppressed because it is too large Load Diff

124
yadm.1
View File

@ -1,5 +1,5 @@
.\" vim: set spell so=8:
.TH yadm 1 "30 December 2020" "3.0.0"
.TH yadm 1 "23 January 2023" "3.2.2"
.SH NAME
@ -61,6 +61,7 @@ list
.BR yadm " transcrypt [ options ]
.BR yadm " upgrade
.RB [ -f ]
.BR yadm " introspect
.I category
@ -115,32 +116,12 @@ if it exists.
.TP
.BI clone " url
Clone a remote repository for tracking dotfiles.
After the contents of the remote repository have been fetched, a "merge" of
After the contents of the remote repository have been fetched, a "check out" of
the remote HEAD branch is attempted.
If there are conflicting files already present in the
.IR work-tree ,
this merge will fail and instead a "reset" of the remote HEAD branch
will be done, followed by a "stash". This "stash" operation will preserve the
original data.
You can review the stashed conflicts by running the command
.RS
.RS
yadm stash show -p
.RE
from within your
.I $HOME
directory. If you want to restore the stashed data, you can run
.RS
yadm stash apply
.RE
or
.RS
yadm stash pop
.RE
the local version will be left unmodified and you'll have to review and resolve
the difference.
The repository is stored in
.IR $HOME/.local/share/yadm/repo.git .
@ -160,7 +141,6 @@ exists). The options
.BR --bootstrap " or " --no-bootstrap
will either force the bootstrap to be run, or prevent it from being run,
without prompting the user.
.RE
.TP
.B config
This command manages configurations for yadm.
@ -297,8 +277,15 @@ This command will start by moving your yadm repo to the new path.
Next it will move any archive data.
If the archive is tracked within your yadm repo, this command will
"stage" the renaming of that file in the repo's index.
Upgrading will also re-initialize all submodules you have added (otherwise they
will be broken when the repo moves).
Upgrading will attempt to de-initialize and re-initialize your submodules. If
your submodules cannot be de-initialized, the upgrade will fail. The most
common reason submodules will fail to de-initialize is because they have local
modifications. If you are willing to lose the local modifications to those
submodules, you can use the
.B -f
option with the "upgrade" command to force the de-initialization.
After running "yadm upgrade", you should run "yadm status" to review changes
which have been staged, and commit them to your repository.
@ -323,7 +310,7 @@ alias yadm='yadm --yadm-repo /alternate/path/to/repo'
.RE
The following is the full list of universal options.
Each option should be followed by a fully qualified path.
Each option should be followed by a path.
.TP
.B -Y,--yadm-dir
Override the yadm directory.
@ -440,7 +427,7 @@ Disable the permission changes to
This feature is enabled by default.
.RE
The following four "local" configurations are not stored in the
The following five "local" configurations are not stored in the
.IR $HOME/.config/yadm/config,
they are stored in the local repository.
@ -448,6 +435,14 @@ they are stored in the local repository.
.B local.class
Specify a class for the purpose of symlinking alternate files.
By default, no class will be matched.
The local host can be assigned multiple classes using command:
.RS
yadm config --add local.class <additional-class>
.RE
.TP
.B local.arch
Override the architecture for the purpose of symlinking alternate files.
.TP
.B local.hostname
Override the hostname for the purpose of symlinking alternate files.
@ -491,17 +486,11 @@ Valid if the value matches the current user.
Current user is calculated by running
.BR "id -u -n" .
.TP
.BR distro , " d
Valid if the value matches the distro.
Distro is calculated by running
.B "lsb_release -si"
or by inspecting the ID from
.BR "/etc/os-release" .
.TP
.BR os , " o
Valid if the value matches the OS.
OS is calculated by running
.BR "uname -s" .
.BR hostname , " h
Valid if the value matches the short hostname.
Hostname is calculated by running
.BR "uname -n" ,
and trimming off any domain.
.TP
.BR class , " c
Valid if the value matches the
@ -512,11 +501,27 @@ Class must be manually set using
See the CONFIGURATION section for more details about setting
.BR local.class .
.TP
.BR hostname , " h
Valid if the value matches the short hostname.
Hostname is calculated by running
.BR "uname -n" ,
and trimming off any domain.
.BR distro , " d
Valid if the value matches the distro.
Distro is calculated by running
.B "lsb_release -si"
or by inspecting the ID from
.BR "/etc/os-release" .
.TP
.BR distro_family , " f
Valid if the value matches the distro family.
Distro family is calculated by inspecting the ID_LIKE line from
.BR "/etc/os-release" .
.TP
.BR os , " o
Valid if the value matches the OS.
OS is calculated by running
.BR "uname -s" .
.TP
.BR arch , " a
Valid if the value matches the architecture.
Architecture is calculated by running
.BR "uname -m" .
.TP
.B default
Valid when no other alternate is valid.
@ -590,7 +595,7 @@ If no "##default" version exists and no files have valid conditions, then no
link will be created.
Links are also created for directories named this way, as long as they have at
least one yadm managed file within them.
least one yadm managed file within them (at the top level).
yadm will automatically create these links by default. This can be disabled
using the
@ -609,8 +614,9 @@ command. The following sets the class to be "Work".
yadm config local.class Work
Similarly, the values of os, hostname, and user can be manually overridden
using the configuration options
Similarly, the values of architecture, os, hostname, and user can be manually
overridden using the configuration options
.BR local.arch ,
.BR local.os ,
.BR local.hostname ,
and
@ -658,14 +664,18 @@ to create or overwrite files.
During processing, the following variables are available in the template:
Default Jinja or ESH Description
------------- ------------- --------------------------
yadm.class YADM_CLASS Locally defined yadm class
yadm.distro YADM_DISTRO lsb_release -si
yadm.hostname YADM_HOSTNAME uname -n (without domain)
yadm.os YADM_OS uname -s
yadm.user YADM_USER id -u -n
yadm.source YADM_SOURCE Template filename
Default Jinja or ESH Description
------------- ------------- ----------------------------
yadm.arch YADM_ARCH uname -m
yadm.class YADM_CLASS Last locally defined class
yadm.classes YADM_CLASSES All classes
yadm.distro YADM_DISTRO lsb_release -si
yadm.distro_family YADM_DISTRO_FAMILY ID_LIKE from /etc/os-release
yadm.hostname YADM_HOSTNAME uname -n (without domain)
yadm.os YADM_OS uname -s
yadm.source YADM_SOURCE Template filename
yadm.user YADM_USER id -u -n
env.VAR Environment variable VAR
.BR NOTE :
The OS for "Windows Subsystem for Linux" is reported as "WSL", even
@ -736,7 +746,7 @@ and
.BR openssl (1)
are supported.
gpg is used by default, but openssl can be configured with the
.I yadm.cypher
.I yadm.cipher
configuration.
To use this feature, a list of patterns must be created and saved as

407
yadm.md
View File

@ -36,86 +36,74 @@
yadm transcrypt [ options ]
yadm upgrade
yadm upgrade [-f]
yadm introspect category
## DESCRIPTION
yadm is a tool for managing a collection of files across multiple com-
puters, using a shared Git repository. In addition, yadm provides a
feature to select alternate versions of files for particular systems.
Lastly, yadm supplies the ability to manage a subset of secure files,
yadm is a tool for managing a collection of files across multiple com
puters, using a shared Git repository. In addition, yadm provides a
feature to select alternate versions of files for particular systems.
Lastly, yadm supplies the ability to manage a subset of secure files,
which are encrypted before they are included in the repository.
## COMMANDS
git-command or git-alias
Any command not internally handled by yadm is passed through to
git(1). Git commands or aliases are invoked with the yadm man-
Any command not internally handled by yadm is passed through to
git(1). Git commands or aliases are invoked with the yadm man
aged repository. The working directory for Git commands will be
the configured work-tree (usually $HOME).
Dotfiles are managed by using standard git commands; add, com-
Dotfiles are managed by using standard git commands; add, com
mit, push, pull, etc.
The config command is not passed directly through. Instead use
The config command is not passed directly through. Instead use
the gitconfig command (see below).
alt Create symbolic links and process templates for any managed
files matching the naming rules described in the ALTERNATES and
TEMPLATES sections. It is usually unnecessary to run this com-
mand, as yadm automatically processes alternates by default.
This automatic behavior can be disabled by setting the configu-
alt Create symbolic links and process templates for any managed
files matching the naming rules described in the ALTERNATES and
TEMPLATES sections. It is usually unnecessary to run this com
mand, as yadm automatically processes alternates by default.
This automatic behavior can be disabled by setting the configu
ration yadm.auto-alt to "false".
bootstrap
Execute $HOME/.config/yadm/bootstrap if it exists.
clone url
Clone a remote repository for tracking dotfiles. After the con-
tents of the remote repository have been fetched, a "merge" of
the remote HEAD branch is attempted. If there are conflicting
files already present in the work-tree, this merge will fail and
instead a "reset" of the remote HEAD branch will be done, fol-
lowed by a "stash". This "stash" operation will preserve the
original data.
Clone a remote repository for tracking dotfiles. After the con
tents of the remote repository have been fetched, a "check out"
of the remote HEAD branch is attempted. If there are conflict
ing files already present in the work-tree, the local version
will be left unmodified and you'll have to review and resolve
the difference.
You can review the stashed conflicts by running the command
yadm stash show -p
from within your $HOME directory. If you want to restore the
stashed data, you can run
yadm stash apply
or
yadm stash pop
The repository is stored in $HOME/.local/share/yadm/repo.git.
The repository is stored in $HOME/.local/share/yadm/repo.git.
By default, $HOME will be used as the work-tree, but this can be
overridden with the -w option. yadm can be forced to overwrite
an existing repository by providing the -f option. If you want
to use a branch other than the remote HEAD branch you can spec-
ify it using the -b option. By default yadm will ask the user
if the bootstrap program should be run (if it exists). The
options --bootstrap or --no-bootstrap will either force the
bootstrap to be run, or prevent it from being run, without
prompting the user.
overridden with the -w option. yadm can be forced to overwrite
an existing repository by providing the -f option. If you want
to use a branch other than the remote HEAD branch you can spec
ify it using the -b option. By default yadm will ask the user
if the bootstrap program should be run (if it exists). The op
tions --bootstrap or --no-bootstrap will either force the boot
strap to be run, or prevent it from being run, without prompting
the user.
config This command manages configurations for yadm. This command
config This command manages configurations for yadm. This command
works exactly the way git-config(1) does. See the CONFIGURATION
section for more details.
decrypt
Decrypt all files stored in $HOME/.local/share/yadm/archive.
Files decrypted will be relative to the configured work-tree
Decrypt all files stored in $HOME/.local/share/yadm/archive.
Files decrypted will be relative to the configured work-tree
(usually $HOME). Using the -l option will list the files stored
without extracting them.
encrypt
Encrypt all files matching the patterns found in $HOME/.con-
fig/yadm/encrypt. See the ENCRYPTION section for more details.
Encrypt all files matching the patterns found in $HOME/.con
fig/yadm/encrypt. See the ENCRYPTION section for more details.
enter Run a sub-shell with all Git variables set. Exit the sub-shell
the same way you leave your normal shell (usually with the
@ -128,7 +116,7 @@
of invoking your shell, that command will be run with all of the
Git variables exposed to the command's environment.
Emacs Tramp and Magit can manage files by using this configura-
Emacs Tramp and Magit can manage files by using this configura
tion:
(add-to-list 'tramp-methods
@ -142,9 +130,9 @@
With this config, use (magit-status "/yadm::").
git-crypt options
If git-crypt is installed, this command allows you to pass
options directly to git-crypt, with the environment configured
to use the yadm repository.
If git-crypt is installed, this command allows you to pass op
tions directly to git-crypt, with the environment configured to
use the yadm repository.
git-crypt enables transparent encryption and decryption of files
in a git repository. You can read https://github.com/AGWA/git-
@ -152,13 +140,13 @@
gitconfig
Pass options to the git config command. Since yadm already uses
the config command to manage its own configurations, this com-
mand is provided as a way to change configurations of the repos-
the config command to manage its own configurations, this com
mand is provided as a way to change configurations of the repos
itory managed by yadm. One useful case might be to configure
the repository so untracked files are shown in status commands.
yadm initially configures its repository so that untracked files
are not shown. If you wish use the default Git behavior (to
show untracked files and directories), you can remove this con-
show untracked files and directories), you can remove this con
figuration.
yadm gitconfig --unset status.showUntrackedFiles
@ -181,15 +169,15 @@
support command line completion.
perms Update permissions as described in the PERMISSIONS section. It
is usually unnecessary to run this command, as yadm automati-
is usually unnecessary to run this command, as yadm automati
cally processes permissions by default. This automatic behavior
can be disabled by setting the configuration yadm.auto-perms to
"false".
transcrypt options
If transcrypt is installed, this command allows you to pass
options directly to transcrypt, with the environment configured
to use the yadm repository.
If transcrypt is installed, this command allows you to pass op
tions directly to transcrypt, with the environment configured to
use the yadm repository.
transcrypt enables transparent encryption and decryption of
files in a git repository. You can read
@ -198,18 +186,26 @@
upgrade
Version 3 of yadm uses a different directory for storing data.
When you start to use version 3 for the first time, you may see
warnings about moving your data to this new directory. The eas-
warnings about moving your data to this new directory. The eas
iest way to accomplish this is by running "yadm upgrade". This
command will start by moving your yadm repo to the new path.
Next it will move any archive data. If the archive is tracked
within your yadm repo, this command will "stage" the renaming of
that file in the repo's index. Upgrading will also re-initial-
ize all submodules you have added (otherwise they will be broken
when the repo moves). After running "yadm upgrade", you should
run "yadm status" to review changes which have been staged, and
commit them to your repository.
that file in the repo's index.
You can read https://yadm.io/docs/upgrade_from_2 for more infor-
Upgrading will attempt to de-initialize and re-initialize your
submodules. If your submodules cannot be de-initialized, the up
grade will fail. The most common reason submodules will fail to
de-initialize is because they have local modifications. If you
are willing to lose the local modifications to those submodules,
you can use the -f option with the "upgrade" command to force
the de-initialization.
After running "yadm upgrade", you should run "yadm status" to
review changes which have been staged, and commit them to your
repository.
You can read https://yadm.io/docs/upgrade_from_2 for more infor
mation.
version
@ -218,7 +214,7 @@
## OPTIONS
yadm supports a set of universal options that alter the paths it uses.
The default paths are documented in the FILES section. Any path speci-
The default paths are documented in the FILES section. Any path speci
fied by these options must be fully qualified. If you always want to
override one or more of these paths, it may be useful to create an
alias for the yadm command. For example, the following alias could be
@ -227,7 +223,7 @@
alias yadm='yadm --yadm-repo /alternate/path/to/repo'
The following is the full list of universal options. Each option
should be followed by a fully qualified path.
should be followed by a path.
-Y,--yadm-dir
Override the yadm directory. yadm stores its configurations
@ -265,24 +261,24 @@
The following is the full list of supported configurations:
yadm.alt-copy
If set to "true", alternate files will be copies instead of sym-
If set to "true", alternate files will be copies instead of sym
bolic links. This might be desirable, because some systems may
not properly support symlinks.
yadm.auto-alt
Disable the automatic linking described in the section ALTER-
Disable the automatic linking described in the section ALTER
NATES. If disabled, you may still run "yadm alt" manually to
create the alternate links. This feature is enabled by default.
create the alternate links. This feature is enabled by default.
yadm.auto-exclude
Disable the automatic exclusion of patterns defined in
Disable the automatic exclusion of patterns defined in
$HOME/.config/yadm/encrypt. This feature is enabled by default.
yadm.auto-perms
Disable the automatic permission changes described in the sec-
Disable the automatic permission changes described in the sec
tion PERMISSIONS. If disabled, you may still run yadm perms
manually to update permissions. This feature is enabled by
default.
manually to update permissions. This feature is enabled by de
fault.
yadm.auto-private-dirs
Disable the automatic creating of private directories described
@ -291,20 +287,20 @@
yadm.cipher
Configure which encryption system is used by the encrypt/decrypt
commands. Valid options are "gpg" and "openssl". The default is
"gpg". Detailed information can be found in the section ENCRYP-
"gpg". Detailed information can be found in the section ENCRYP
TION.
yadm.git-program
Specify an alternate program to use instead of "git". By
default, the first "git" found in $PATH is used.
Specify an alternate program to use instead of "git". By de
fault, the first "git" found in $PATH is used.
yadm.gpg-perms
Disable the permission changes to $HOME/.gnupg/*. This feature
is enabled by default.
yadm.gpg-program
Specify an alternate program to use instead of "gpg". By
default, the first "gpg" found in $PATH is used.
Specify an alternate program to use instead of "gpg". By de
fault, the first "gpg" found in $PATH is used.
yadm.gpg-recipient
Asymmetrically encrypt files with a gpg public/private key pair.
@ -312,9 +308,9 @@
The key must exist in your public keyrings. Multiple recipients
can be specified (separated by space). If left blank or not
provided, symmetric encryption is used instead. If set to
"ASK", gpg will interactively ask for recipients. See the
ENCRYPTION section for more details. This feature is disabled
by default.
"ASK", gpg will interactively ask for recipients. See the EN
CRYPTION section for more details. This feature is disabled by
default.
yadm.openssl-ciphername
Specify which cipher should be used by openssl. "aes-256-cbc"
@ -335,13 +331,20 @@
Disable the permission changes to $HOME/.ssh/*. This feature is
enabled by default.
The following four "local" configurations are not stored in the
The following five "local" configurations are not stored in the
$HOME/.config/yadm/config, they are stored in the local repository.
local.class
Specify a class for the purpose of symlinking alternate files.
By default, no class will be matched.
By default, no class will be matched. The local host can be as
signed multiple classes using command:
yadm config --add local.class <additional-class>
local.arch
Override the architecture for the purpose of symlinking alter
nate files.
local.hostname
Override the hostname for the purpose of symlinking alternate
@ -359,52 +362,60 @@
to have an automated way of choosing an alternate version of a file for
a different operating system, host, user, etc.
yadm will automatically create a symbolic link to the appropriate ver-
sion of a file, when a valid suffix is appended to the filename. The
suffix contains the conditions that must be met for that file to be
yadm will automatically create a symbolic link to the appropriate ver
sion of a file, when a valid suffix is appended to the filename. The
suffix contains the conditions that must be met for that file to be
used.
The suffix begins with "##", followed by any number of conditions sepa-
The suffix begins with "##", followed by any number of conditions sepa
rated by commas.
##<condition>[,<condition>,...]
Each condition is an attribute/value pair, separated by a period. Some
conditions do not require a "value", and in that case, the period and
value can be omitted. Most attributes can be abbreviated as a single
Each condition is an attribute/value pair, separated by a period. Some
conditions do not require a "value", and in that case, the period and
value can be omitted. Most attributes can be abbreviated as a single
letter.
<attribute>[.<value>]
These are the supported attributes, in the order of the weighted prece-
These are the supported attributes, in the order of the weighted prece
dence:
template, t
Valid when the value matches a supported template processor.
Valid when the value matches a supported template processor.
See the TEMPLATES section for more details.
user, u
Valid if the value matches the current user. Current user is
Valid if the value matches the current user. Current user is
calculated by running id -u -n.
distro, d
Valid if the value matches the distro. Distro is calculated by
running lsb_release -si or by inspecting the ID from /etc/os-
release.
os, o Valid if the value matches the OS. OS is calculated by running
uname -s.
hostname, h
Valid if the value matches the short hostname. Hostname is cal
culated by running uname -n, and trimming off any domain.
class, c
Valid if the value matches the local.class configuration. Class
must be manually set using yadm config local.class <class>. See
the CONFIGURATION section for more details about setting
local.class.
the CONFIGURATION section for more details about setting lo
cal.class.
hostname, h
Valid if the value matches the short hostname. Hostname is cal-
culated by running uname -n, and trimming off any domain.
distro, d
Valid if the value matches the distro. Distro is calculated by
running lsb_release -si or by inspecting the ID from /etc/os-re
lease.
distro_family, f
Valid if the value matches the distro family. Distro family is
calculated by inspecting the ID_LIKE line from /etc/os-release.
os, o Valid if the value matches the OS. OS is calculated by running
uname -s.
arch, a
Valid if the value matches the architecture. Architecture is
calculated by running uname -m.
default
Valid when no other alternate is valid.
@ -412,31 +423,30 @@
extension, e
A special "condition" that doesn't affect the selection process.
Its purpose is instead to allow the alternate file to end with a
certain extension to e.g. make editors highlight the content
certain extension to e.g. make editors highlight the content
properly.
NOTE: The OS for "Windows Subsystem for Linux" is reported as "WSL",
NOTE: The OS for "Windows Subsystem for Linux" is reported as "WSL",
even though uname identifies as "Linux".
You may use any number of conditions, in any order. An alternate will
only be used if ALL conditions are valid. For all files managed by
yadm's repository or listed in $HOME/.config/yadm/encrypt, if they
match this naming convention, symbolic links will be created for the
You may use any number of conditions, in any order. An alternate will
only be used if ALL conditions are valid. For all files managed by
yadm's repository or listed in $HOME/.config/yadm/encrypt, if they
match this naming convention, symbolic links will be created for the
most appropriate version.
The "most appropriate" version is determined by calculating a score for
each version of a file. A template is always scored higher than any
symlink condition. The number of conditions is the next largest factor
in scoring. Files with more conditions will always be favored. Any
invalid condition will disqualify that file completely.
each version of a file. A template is always scored higher than any
symlink condition. The number of conditions is the next largest factor
in scoring. Files with more conditions will always be favored. Any in
valid condition will disqualify that file completely.
If you don't care to have all versions of alternates stored in the same
directory as the generated symlink, you can place them in the
$HOME/.config/yadm/alt directory. The generated symlink or processed
$HOME/.config/yadm/alt directory. The generated symlink or processed
template will be created using the same relative path.
Alternate linking may best be demonstrated by example. Assume the fol-
Alternate linking may best be demonstrated by example. Assume the fol
lowing files are managed by yadm's repository:
- $HOME/path/example.txt##default
@ -451,7 +461,7 @@
If running on a Macbook named "host2", yadm will create a symbolic link
which looks like this:
$HOME/path/example.txt -> $HOME/path/example.txt##os.Darwin,host-
$HOME/path/example.txt -> $HOME/path/example.txt##os.Darwin,host
name.host2
However, on another Mackbook named "host3", yadm will create a symbolic
@ -459,7 +469,7 @@
$HOME/path/example.txt -> $HOME/path/example.txt##os.Darwin
Since the hostname doesn't match any of the managed files, the more
Since the hostname doesn't match any of the managed files, the more
generic version is chosen.
If running on a Linux server named "host4", the link will be:
@ -474,81 +484,84 @@
$HOME/path/example.txt -> $HOME/path/example.txt##class.Work
If no "##default" version exists and no files have valid conditions,
If no "##default" version exists and no files have valid conditions,
then no link will be created.
Links are also created for directories named this way, as long as they
have at least one yadm managed file within them.
Links are also created for directories named this way, as long as they
have at least one yadm managed file within them (at the top level).
yadm will automatically create these links by default. This can be dis-
abled using the yadm.auto-alt configuration. Even if disabled, links
yadm will automatically create these links by default. This can be dis
abled using the yadm.auto-alt configuration. Even if disabled, links
can be manually created by running yadm alt.
Class is a special value which is stored locally on each host (inside
the local repository). To use alternate symlinks using class, you must
set the value of class using the configuration local.class. This is
Class is a special value which is stored locally on each host (inside
the local repository). To use alternate symlinks using class, you must
set the value of class using the configuration local.class. This is
set like any other yadm configuration with the yadm config command. The
following sets the class to be "Work".
yadm config local.class Work
Similarly, the values of os, hostname, and user can be manually over-
ridden using the configuration options local.os, local.hostname, and
local.user.
Similarly, the values of architecture, os, hostname, and user can be
manually overridden using the configuration options local.arch, lo
cal.os, local.hostname, and local.user.
## TEMPLATES
If a template condition is defined in an alternate file's "##" suffix,
If a template condition is defined in an alternate file's "##" suffix,
and the necessary dependencies for the template are available, then the
file will be processed to create or overwrite files.
Supported template processors:
default
This is yadm's built-in template processor. This processor is
very basic, with a Jinja-like syntax. The advantage of this pro-
cessor is that it only depends upon awk, which is available on
most *nix systems. To use this processor, specify the value of
This is yadm's built-in template processor. This processor is
very basic, with a Jinja-like syntax. The advantage of this pro
cessor is that it only depends upon awk, which is available on
most *nix systems. To use this processor, specify the value of
"default" or just leave the value off (e.g. "##template").
ESH ESH is a template processor written in POSIX compliant shell. It
allows executing shell commands within templates. This can be
used to reference your own configurations within templates, for
allows executing shell commands within templates. This can be
used to reference your own configurations within templates, for
example:
<% yadm config mysection.myconfig %>
To use the ESH template processor, specify the value of "esh"
j2cli To use the j2cli Jinja template processor, specify the value of
j2cli To use the j2cli Jinja template processor, specify the value of
"j2" or "j2cli".
envtpl To use the envtpl Jinja template processor, specify the value of
"j2" or "envtpl".
NOTE: Specifying "j2" as the processor will attempt to use j2cli or en
vtpl, whichever is available.
NOTE: Specifying "j2" as the processor will attempt to use j2cli or
envtpl, whichever is available.
If the template processor specified is available, templates will be
If the template processor specified is available, templates will be
processed to create or overwrite files.
During processing, the following variables are available in the tem-
During processing, the following variables are available in the tem
plate:
Default Jinja or ESH Description
------------- ------------- --------------------------
yadm.class YADM_CLASS Locally defined yadm class
yadm.distro YADM_DISTRO lsb_release -si
yadm.hostname YADM_HOSTNAME uname -n (without domain)
yadm.os YADM_OS uname -s
yadm.user YADM_USER id -u -n
yadm.source YADM_SOURCE Template filename
Default Jinja or ESH Description
------------- ------------- ----------------------------
yadm.arch YADM_ARCH uname -m
yadm.class YADM_CLASS Last locally defined class
yadm.classes YADM_CLASSES All classes
yadm.distro YADM_DISTRO lsb_release -si
yadm.distro_family YADM_DISTRO_FAMILY ID_LIKE from /etc/os-release
yadm.hostname YADM_HOSTNAME uname -n (without domain)
yadm.os YADM_OS uname -s
yadm.source YADM_SOURCE Template filename
yadm.user YADM_USER id -u -n
env.VAR Environment variable VAR
NOTE: The OS for "Windows Subsystem for Linux" is reported as "WSL",
NOTE: The OS for "Windows Subsystem for Linux" is reported as "WSL",
even though uname identifies as "Linux".
NOTE: If lsb_release is not available, DISTRO will be the ID specified
NOTE: If lsb_release is not available, DISTRO will be the ID specified
in /etc/os-release.
Examples:
@ -562,7 +575,7 @@
{% include "whatever.extra" %}
{% endif %}
would output a file named whatever with the following content if the
would output a file named whatever with the following content if the
user is "harvey":
config=work-Linux
@ -572,7 +585,7 @@
config=dev-whatever
admin=false
An equivalent Jinja template named whatever##template.j2 would look
An equivalent Jinja template named whatever##template.j2 would look
like:
{% if YADM_USER == 'harvey' -%}
@ -582,7 +595,7 @@
{% include 'whatever.extra' %}
{% endif -%}
An equivalent ESH templated named whatever##template.esh would look
An equivalent ESH templated named whatever##template.esh would look
like:
<% if [ "$YADM_USER" = "harvey" ]; then -%>
@ -594,55 +607,55 @@
## ENCRYPTION
It can be useful to manage confidential files, like SSH or GPG keys,
across multiple systems. However, doing so would put plain text data
It can be useful to manage confidential files, like SSH or GPG keys,
across multiple systems. However, doing so would put plain text data
into a Git repository, which often resides on a public system. yadm can
make it easy to encrypt and decrypt a set of files so the encrypted
version can be maintained in the Git repository. This feature will
make it easy to encrypt and decrypt a set of files so the encrypted
version can be maintained in the Git repository. This feature will
only work if a supported tool is available. Both gpg(1) and openssl(1)
are supported. gpg is used by default, but openssl can be configured
with the yadm.cypher configuration.
are supported. gpg is used by default, but openssl can be configured
with the yadm.cipher configuration.
To use this feature, a list of patterns must be created and saved as
$HOME/.config/yadm/encrypt. This list of patterns should be relative
To use this feature, a list of patterns must be created and saved as
$HOME/.config/yadm/encrypt. This list of patterns should be relative
to the configured work-tree (usually $HOME). For example:
.ssh/*.key
.gnupg/*.gpg
Standard filename expansions (*, ?, [) are supported. If you have Bash
version 4, you may use "**" to match all subdirectories. Other shell
version 4, you may use "**" to match all subdirectories. Other shell
expansions like brace and tilde are not supported. Spaces in paths are
supported, and should not be quoted. If a directory is specified, its
supported, and should not be quoted. If a directory is specified, its
contents will be included, but not recursively. Paths beginning with a
"!" will be excluded.
The yadm encrypt command will find all files matching the patterns, and
prompt for a password. Once a password has confirmed, the matching
files will be encrypted and saved as $HOME/.local/share/yadm/archive.
The "encrypt" and "archive" files should be added to the yadm reposi-
prompt for a password. Once a password has confirmed, the matching
files will be encrypted and saved as $HOME/.local/share/yadm/archive.
The "encrypt" and "archive" files should be added to the yadm reposi
tory so they are available across multiple systems.
To decrypt these files later, or on another system run yadm decrypt and
provide the correct password. After files are decrypted, permissions
provide the correct password. After files are decrypted, permissions
are automatically updated as described in the PERMISSIONS section.
Symmetric encryption is used by default, but asymmetric encryption may
Symmetric encryption is used by default, but asymmetric encryption may
be enabled using the yadm.gpg-recipient configuration.
NOTE: It is recommended that you use a private repository when keeping
NOTE: It is recommended that you use a private repository when keeping
confidential files, even though they are encrypted.
Patterns found in $HOME/.config/yadm/encrypt are automatically added to
the repository's info/exclude file every time yadm encrypt is run.
This is to prevent accidentally committing sensitive data to the repos-
the repository's info/exclude file every time yadm encrypt is run.
This is to prevent accidentally committing sensitive data to the repos
itory. This can be disabled using the yadm.auto-exclude configuration.
Using transcrypt or git-crypt
A completely separate option for encrypting data is to install and use
transcrypt or git-crypt. Once installed, you can use these tools by
running yadm transcrypt or yadm git-crypt. These tools enables trans-
running yadm transcrypt or yadm git-crypt. These tools enables trans
parent encryption and decryption of files in a git repository. See the
following web sites for more information:
@ -650,10 +663,8 @@
- https://github.com/AGWA/git-crypt
## PERMISSIONS
When files are checked out of a Git repository, their initial permis-
When files are checked out of a Git repository, their initial permis
sions are dependent upon the user's umask. Because of this, yadm will
automatically update the permissions of some file paths. The "group"
and "others" permissions will be removed from the following files:
@ -666,11 +677,11 @@
- The GPG directory and files, .gnupg/*
yadm will automatically update permissions by default. This can be dis-
abled using the yadm.auto-perms configuration. Even if disabled, per-
missions can be manually updated by running yadm perms. The .ssh
directory processing can be disabled using the yadm.ssh-perms configu-
ration. The .gnupg directory processing can be disabled using the
yadm will automatically update permissions by default. This can be dis
abled using the yadm.auto-perms configuration. Even if disabled, per
missions can be manually updated by running yadm perms. The .ssh di
rectory processing can be disabled using the yadm.ssh-perms configura
tion. The .gnupg directory processing can be disabled using the
yadm.gpg-perms configuration.
When cloning a repo which includes data in a .ssh or .gnupg directory,
@ -680,18 +691,18 @@
When running a Git command and .ssh or .gnupg directories do not exist,
yadm will create those directories with mask 0700 prior to running the
Git command. This can be disabled using the yadm.auto-private-dirs con-
Git command. This can be disabled using the yadm.auto-private-dirs con
figuration.
## HOOKS
For every command yadm supports, a program can be provided to run
before or after that command. These are referred to as "hooks". yadm
For every command yadm supports, a program can be provided to run be
fore or after that command. These are referred to as "hooks". yadm
looks for hooks in the directory $HOME/.config/yadm/hooks. Each hook
is named using a prefix of pre_ or post_, followed by the command which
should trigger the hook. For example, to create a hook which is run
after every yadm pull command, create a hook named post_pull. Hooks
must have the executable file permission set.
should trigger the hook. For example, to create a hook which is run af
ter every yadm pull command, create a hook named post_pull. Hooks must
have the executable file permission set.
If a pre_ hook is defined, and the hook terminates with a non-zero exit
status, yadm will refuse to run the yadm command. For example, if a
@ -722,15 +733,15 @@
## FILES
All of yadm's configurations are relative to the "yadm directory".
yadm uses the "XDG Base Directory Specification" to determine this
directory. If the environment variable $XDG_CONFIG_HOME is defined as
a fully qualified path, this directory will be $XDG_CONFIG_HOME/yadm.
yadm uses the "XDG Base Directory Specification" to determine this di
rectory. If the environment variable $XDG_CONFIG_HOME is defined as a
fully qualified path, this directory will be $XDG_CONFIG_HOME/yadm.
Otherwise it will be $HOME/.config/yadm.
Similarly, yadm's data files are relative to the "yadm data directory".
yadm uses the "XDG Base Directory Specification" to determine this
directory. If the environment variable $XDG_DATA_HOME is defined as a
fully qualified path, this directory will be $XDG_DATA_HOME/yadm. Oth-
yadm uses the "XDG Base Directory Specification" to determine this di
rectory. If the environment variable $XDG_DATA_HOME is defined as a
fully qualified path, this directory will be $XDG_DATA_HOME/yadm. Oth
erwise it will be $HOME/.local/share/yadm.
The following are the default paths yadm uses for its own data. Most
@ -738,7 +749,7 @@
section for details.
$HOME/.config/yadm
The yadm directory. By default, all configs yadm stores is rela-
The yadm directory. By default, all configs yadm stores is rela
tive to this directory.
$HOME/.local/share/yadm
@ -750,7 +761,7 @@
$YADM_DIR/alt
This is a directory to keep "alternate files" without having
them side-by-side with the resulting symlink or processed tem-
them side-by-side with the resulting symlink or processed tem
plate. Alternate files placed in this directory will be created
relative to $HOME instead.

View File

@ -1,7 +1,7 @@
%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}}
Name: yadm
Summary: Yet Another Dotfiles Manager
Version: 3.0.0
Version: 3.2.2
Group: Development/Tools
Release: 1%{?dist}
URL: https://yadm.io