1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

331 Commits

Author SHA1 Message Date
Erik Flodin
66e509d2e4 Don't always run auto-alt (and -perms) after invoking git command
Improve performance (#505) by only running auto-alt (and auto-perms)
when HEAD has changed after calling a git command, e.g. after committing
or pulling new changes.

Also use this new information to remove stale symlinks when an alt file
has been removed.
2025-04-06 20:57:34 +02:00
Erik Flodin
bbb58e6625 Add support for "seed" template (#435)
The file will only be created from the template the first run. On
subsequent runs it will not be updated, even if the template has
changed.
2025-03-23 21:32:50 +01:00
Erik Flodin
4214de8d91 Change handling of dirs with alt conditions
Instead of creating symlinks pointing at the directory, create individual
symlinks for each file within the dir alternate (fixes #490).

Also rework how stale symlinks are removed. Now a (stale) symlink will only be
removed if it's pointing at a file that's an altnerate file (fixes #236).
2025-03-18 20:50:34 +01:00
Erik Flodin
4f4c5e2914 Update CHANGES and prepare for 3.5.0 2025-03-04 00:03:44 +01:00
Erik Flodin
0e0172769d Add yadm.filename variable to default template processor
Similar to yadm.source but reflects the current file also in included
files (#520).
2025-03-03 23:47:16 +01:00
Erik Flodin
bee1558a4e Minor cleanups of alt handling
Also correct alt conditions precedence list in manual.
2025-03-02 22:18:09 +01:00
AaronYoung5
9ff5e09650 Add support for negative alt conditions (#522) 2025-03-02 22:06:12 +01:00
Erik Flodin
d4796108f4 Automatically exclude alt links and template files
unless yadm.auto-exclude is set to false (#234, #465).

Alt files exclude pattern will be written to $GIT_DIR/info/exclude.yadm-alt and
encrypt files exclude patthern to ...yadm-encrypt. Then these two files will be
merged together and added to $GIT_DIR/info/exclude whenever one of them has
changed.
2025-03-02 21:05:43 +01:00
Erik Flodin
6726730701 parse_encrypt: Don't let e.g. "*.ext" match files in subdirs
This matches the behavior before 3.4.0.

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

Fix the patterns written to info/exclude so that they match the same files as
are encrypted (e.g. *.key should only match .key files in the topdir, not in
subdirs).
2025-02-25 23:04:23 +01:00
Erik Flodin
c90aa86051 Update CHANGES and prepare for 3.4.0 2025-02-09 22:24:18 +01:00
Erik Flodin
02b4019bc6 Add support and tests for clone --recurse-submodules
Including tests for clone --recursive.
2025-01-20 00:01:22 +01:00
Christof Warlich
a86f2381b6 Make "yadm clone --recursive" work as expected (#517)
The --recursive switch was ignored when YADM clones a dotfile repository.
This commit causes "yadm clone --recursive" to also clone submodules
in one go, similar to what GIT does when given the --recursive switch.
2025-01-14 22:45:50 +01:00
Erik Flodin
119d1ddbaa Refactor template handling
Move common template logic out to a new template() function that calls one of
the existing template processors and then handles writing the result and
copying permissions.
2024-12-15 16:15:14 +01:00
Erik Flodin
eb819782ee Merge pull request #466 from rasa/improve-template-logic 2024-12-15 16:14:50 +01:00
Ross Smith II
7a4de1a247 Always remove temp_file on failure, other cleanup 2024-12-15 16:13:25 +01:00
Erik Flodin
f5dfc7ab01 Format yadm and bootstrap with shfmt
Command: shfmt -w -ln bash -i 2 -ci <file>
2024-12-11 20:07:38 +01:00
Erik Flodin
4511f5d9c6 Use git ls-files to list files to encrypt
By using git ls-files instead of bash we can support ** also on macOS where the
included bash version (3) doesn't support globstar.
2024-12-10 21:51:58 +01:00
Erik Flodin
8c2f833b43 Support overriding distro and distro family
Fixes #430.
2024-12-10 18:35:26 +01:00
Erik Flodin
c092b7c099 Ignore case in alt and default template processor conditions
This aligns all conditions with distro and distro_family.

Suggestion from #456.
2024-12-09 23:50:49 +01:00
Erik Flodin
6c1970fb41 Set distro family from ID line if no ID_LIKE line is found
See #456.
2024-12-09 23:13:43 +01:00
Erik Flodin
18d5f66542 Ignore case for yadm.distro and .distro_family in default template
Same as b2b0b14 but for if statements in default template processor.
2024-12-09 22:54:41 +01:00
Erik Flodin
b2b0b143d6 Refactor alt handling
* Simplify score_file() by using case in instead of nested ifs with regexps.
* Merge record_score() and record_template().
* Alt condition processing no longer stops when a template condition is seen
  but continues processing to verify that all conditions are valid (as the
  documentation says it should). Fixes #478.
* Support alt dirs with deeply nested tracked files (fixes #490).
* Use git ls-files to filter out which tracked files to consider for alt
  processing. Should speed up auto-alt (#505).
* Use nocasematch when comparing distro and distro_family. Fixed #455.
2024-12-06 23:10:52 +01:00
Erik Flodin
b164d03594 Make relative_path match full dir and not just a prefix
Before this change, relative_path "/A/B/C" "/A/B/CD" would return "" instead of
the correct "../CD".
2024-12-06 23:10:49 +01:00
Erik Flodin
0b91140ea8 Output the actual paths in help message
Fixes #376.
2024-12-06 00:07:45 +01:00
Erik Flodin
6ee9b472d1 Merge pull request #507 from AVM-Martin/fix/reset-yadm-work-index
fix(clone): reset index of YADM_WORK
2024-11-29 23:10:35 +01:00
AVM.Martin
ae3a149449 style: use pathspec for consistency 2024-11-26 19:22:18 +07:00
Erik Flodin
640b324401 Prepare for version 3.3.0
* Support nested ifs in default template (#436)
 * Support include and ifs in default template includes (#406)
 * Support environment variables in ifs in default template (#488)
 * Support != in default template (#358, #477)
 * Fix multiple classes in default template on macOS (#437)
2024-11-08 20:23:23 +01:00
Erik Flodin
8e5d4b1578 Pass classes as separate arguments to template_default
To work around problem with passing newlines in variable with awk on
darwin. This fixes #437.
2024-11-08 19:54:14 +01:00
Erik Flodin
8ba9823407 Rewrite default template to handle nested ifs, != and env vars in if
The awk script now performs all processing in the BEGIN block using an
implementation that is capable of handling if statements which contain nested
if statments (fixes #436). To make nested ifs look better, if, else and endif
lines can now have optional whitespace before {%.

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

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

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

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

A non-existing yadm or env variable is now replaced with the empty string.
2024-11-04 22:30:23 +01:00
AVM.Martin
aba434274e fix(clone): reset index of YADM_WORK 2024-07-21 07:02:49 +07:00
Ross Smith II
95d7bae7b3 Improve and harden alt file regeneration
Improvements include:

1. Skip writing a temporary file if the file contents are unchanged
2. Better error reporting if templating program fails
3. Better error reporting/handling if file creation, mv, or chmod fail
4. Quiet logs by not outputing "Creating output..." line twice (debug & loud)
2023-10-11 14:58:27 -07:00
Tim Byrne
f9e0368385 Changes for new shellcheck compliance 2023-07-12 09:19:59 -05: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
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
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
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
46f72c2768 Add local.arch to config introspection 2022-02-21 14:09:57 -06:00
Tim Byrne
ebb6715aad Reduce supported labels for architecture 2022-02-21 14:01:08 -06:00
Tim Byrne
50bf8716cd Unify template support for classes (#185) 2022-02-21 11:31:44 -06:00
Tim Byrne
0b75e71237 Merge pull request #347 from rasa/develop 2022-02-17 16:45:45 -06:00
Tim Byrne
027c7359ac Merge pull request #304 from erijo/multiple-classes 2022-01-22 18:14:23 -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
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
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
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