Compare commits
18 commits
40c03e1230
...
68cc5e3a02
Author | SHA1 | Date | |
---|---|---|---|
68cc5e3a02 | |||
|
640b324401 | ||
|
8e5d4b1578 | ||
|
d74a41b1b4 | ||
|
144f35b82d | ||
|
8ba9823407 | ||
|
6d3b9dac71 | ||
|
e097d16d88 | ||
|
3ecbe7ec27 | ||
|
38880abc68 | ||
|
0a5e7aa353 | ||
|
040dd461bd | ||
9f852c1ad4 | |||
8bfc09c0d8 | |||
a72c566da8 | |||
630b677269 | |||
6d305b2b80 | |||
c6b63cf94b |
20 changed files with 359 additions and 255 deletions
30
.github/CONTRIBUTING.md
vendored
30
.github/CONTRIBUTING.md
vendored
|
@ -1,7 +1,7 @@
|
|||
# Introduction
|
||||
|
||||
Thank you for considering contributing to **yadm**. I develop this project in my
|
||||
limited spare time, so help is very appreciated.
|
||||
Thank you for considering contributing to **yadm**. We develop this project in
|
||||
our limited spare time, so help is very appreciated.
|
||||
|
||||
All contributors must follow our [Code of Conduct][conduct]. Please make sure
|
||||
you are welcoming and friendly during your interactions, and report any
|
||||
|
@ -17,7 +17,8 @@ To contribute, you can:
|
|||
* Star the yadm repo, the star count helps others discover yadm.
|
||||
* Report [bugs](#reporting-a-bug)
|
||||
* Request [features/enhancements](#suggesting-a-feature-or-enhancement)
|
||||
* Contribute changes to [code, tests](#contributing-code), and [documentation](#improving-documentation)
|
||||
* Contribute changes to [code, tests](#contributing-code), and
|
||||
[documentation](#improving-documentation)
|
||||
* Maintain installation [packages](#maintaining-packages)
|
||||
* Help other users by [answering support questions](#answering-support-questions)
|
||||
|
||||
|
@ -70,14 +71,14 @@ Consider trying to reproduce the bug inside a docker container using the
|
|||
[yadm/testbed][] docker image. Doing so will greatly increase the likelihood of
|
||||
the problem being fixed.
|
||||
|
||||
The easiest way to start this container, is to clone the [TheLocehiliosan/yadm
|
||||
The easiest way to start this container, is to clone the [yadm
|
||||
repo][yadm-repo], and use the `scripthost` make target. _(You will need `make`
|
||||
and `docker` installed.)_
|
||||
|
||||
For example:
|
||||
|
||||
```text
|
||||
$ git clone https://github.com/TheLocehiliosan/yadm.git
|
||||
$ git clone https://github.com/yadm-dev/yadm.git
|
||||
$ cd yadm
|
||||
$ make scripthost version=1.12.0
|
||||
Starting scripthost version="1.12.0" (recording script)
|
||||
|
@ -203,7 +204,7 @@ these principles when making changes.
|
|||
3. Add the official repository (`upstream`) as a remote repository.
|
||||
|
||||
```text
|
||||
$ git remote add upstream https://github.com/TheLocehiliosan/yadm.git
|
||||
$ git remote add upstream https://github.com/yadm-dev/yadm.git
|
||||
```
|
||||
|
||||
4. Verify you can run the test harness. _(This will require dependencies:
|
||||
|
@ -361,25 +362,24 @@ see if you can help.
|
|||
[attach-help]: https://help.github.com/en/articles/file-attachments-on-issues-and-pull-requests
|
||||
[commit-style]: https://chris.beams.io/posts/git-commit/#seven-rules
|
||||
[conduct]: CODE_OF_CONDUCT.md
|
||||
[contrib-hooks]: https://github.com/TheLocehiliosan/yadm/tree/master/contrib/hooks
|
||||
[contrib-hooks]: https://github.com/yadm-dev/yadm/tree/master/contrib/hooks
|
||||
[flake8]: https://pypi.org/project/flake8/
|
||||
[groff-man]: https://www.gnu.org/software/groff/manual/html_node/man.html
|
||||
[hooks-help]: https://github.com/TheLocehiliosan/yadm/blob/master/yadm.md#hooks
|
||||
[hooks-help]: https://github.com/yadm-dev/yadm/blob/master/yadm.md#hooks
|
||||
[html-proofer]: https://github.com/gjtorikian/html-proofer
|
||||
[jekyll]: https://jekyllrb.com
|
||||
[new-bug]: https://github.com/TheLocehiliosan/yadm/issues/new?template=BUG_REPORT.md
|
||||
[new-feature]: https://github.com/TheLocehiliosan/yadm/issues/new?template=FEATURE_REQUEST.md
|
||||
[open-issues]: https://github.com/TheLocehiliosan/yadm/issues
|
||||
[new-bug]: https://github.com/yadm-dev/yadm/issues/new?template=BUG_REPORT.md
|
||||
[new-feature]: https://github.com/yadm-dev/yadm/issues/new?template=FEATURE_REQUEST.md
|
||||
[open-issues]: https://github.com/yadm-dev/yadm/issues
|
||||
[pr-help]: https://help.github.com/en/articles/creating-a-pull-request-from-a-fork
|
||||
[pylint]: https://pylint.org/
|
||||
[pytest]: https://pytest.org/
|
||||
[questions]: https://github.com/TheLocehiliosan/yadm/labels/question
|
||||
[refactor]: https://github.com/TheLocehiliosan/yadm/issues/146
|
||||
[questions]: https://github.com/yadm-dev/yadm/labels/question
|
||||
[shellcheck]: https://www.shellcheck.net
|
||||
[signing-commits]: https://help.github.com/en/articles/signing-commits
|
||||
[tpope-style]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
||||
[yadm-man]: https://github.com/TheLocehiliosan/yadm/blob/master/yadm.md
|
||||
[yadm-repo]: https://github.com/TheLocehiliosan/yadm
|
||||
[yadm-man]: https://github.com/yadm-dev/yadm/blob/master/yadm.md
|
||||
[yadm-repo]: https://github.com/yadm-dev/yadm
|
||||
[yadm/jekyll]: https://hub.docker.com/r/yadm/jekyll
|
||||
[yadm/testbed]: https://hub.docker.com/r/yadm/testbed
|
||||
[yamllint]: https://github.com/adrienverge/yamllint
|
||||
|
|
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
|
@ -1,6 +1,6 @@
|
|||
<!--
|
||||
Before submitting, please search open and closed issues at
|
||||
https://github.com/TheLocehiliosan/yadm/issues to avoid duplication.
|
||||
https://github.com/yadm-dev/yadm/issues to avoid duplication.
|
||||
|
||||
If you have found a security vulnerability, do NOT open an issue.
|
||||
Email yadm@yadm.io instead.
|
||||
|
|
6
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
6
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
|
@ -8,7 +8,7 @@ assignees: ''
|
|||
---
|
||||
<!--
|
||||
Before submitting, please search open and closed issues at
|
||||
https://github.com/TheLocehiliosan/yadm/issues to avoid duplication.
|
||||
https://github.com/yadm-dev/yadm/issues to avoid duplication.
|
||||
|
||||
If you have found a security vulnerability, do NOT open an issue.
|
||||
Email yadm@yadm.io instead.
|
||||
|
@ -25,10 +25,10 @@ Can this be reproduced with the yadm/testbed docker image: [Yes/No]
|
|||
Consider trying to reproduce the bug inside a docker container using the
|
||||
yadm/testbed docker image. https://hub.docker.com/r/yadm/testbed
|
||||
|
||||
The easiest way to start this container, is to clone the TheLocehiliosan/yadm
|
||||
The easiest way to start this container, is to clone the yadm-dev/yadm
|
||||
repo, and use the "scripthost" make target. For example:
|
||||
|
||||
$ git clone https://github.com/TheLocehiliosan/yadm.git
|
||||
$ git clone https://github.com/yadm-dev/yadm.git
|
||||
$ cd yadm
|
||||
$ make scripthost version=1.11.0
|
||||
Starting scripthost version="1.11.0" (recording script)
|
||||
|
|
2
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
2
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
|
@ -8,7 +8,7 @@ assignees: ''
|
|||
---
|
||||
<!--
|
||||
Before submitting, please search open and closed issues at
|
||||
https://github.com/TheLocehiliosan/yadm/issues to avoid duplication.
|
||||
https://github.com/yadm-dev/yadm/issues to avoid duplication.
|
||||
-->
|
||||
|
||||
### Is your feature request related to a problem? Please describe.
|
||||
|
|
2
.github/ISSUE_TEMPLATE/OTHER.md
vendored
2
.github/ISSUE_TEMPLATE/OTHER.md
vendored
|
@ -8,7 +8,7 @@ assignees: ''
|
|||
---
|
||||
<!--
|
||||
Before submitting, please search open and closed issues at
|
||||
https://github.com/TheLocehiliosan/yadm/issues to avoid duplication.
|
||||
https://github.com/yadm-dev/yadm/issues to avoid duplication.
|
||||
-->
|
||||
|
||||
### This issue is about
|
||||
|
|
4
.github/ISSUE_TEMPLATE/SUPPORT.md
vendored
4
.github/ISSUE_TEMPLATE/SUPPORT.md
vendored
|
@ -8,11 +8,11 @@ assignees: ''
|
|||
---
|
||||
<!--
|
||||
Before submitting, please search open and closed issues at
|
||||
https://github.com/TheLocehiliosan/yadm/issues to avoid duplication.
|
||||
https://github.com/yadm-dev/yadm/issues to avoid duplication.
|
||||
|
||||
Please also consult:
|
||||
* The FAQ: https://yadm.io/docs/faq
|
||||
* The manual: https://github.com/TheLocehiliosan/yadm/blob/master/yadm.md
|
||||
* The manual: https://github.com/yadm-dev/yadm/blob/master/yadm.md
|
||||
-->
|
||||
|
||||
### This question is about
|
||||
|
|
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -29,6 +29,6 @@ Be sure to preface the issue/PR numbers with a "#".
|
|||
|
||||
Please review [yadm's Contributing Guide][3] for best practices.
|
||||
|
||||
[1]: https://github.com/TheLocehiliosan/yadm/blob/master/.github/CONTRIBUTING.md#test-conventions
|
||||
[1]: https://github.com/yadm-dev/yadm/blob/master/.github/CONTRIBUTING.md#test-conventions
|
||||
[2]: https://help.github.com/en/articles/signing-commits
|
||||
[3]: https://github.com/TheLocehiliosan/yadm/blob/master/.github/CONTRIBUTING.md
|
||||
[3]: https://github.com/yadm-dev/yadm/blob/master/.github/CONTRIBUTING.md
|
||||
|
|
2
.github/workflows/schedule.yml
vendored
2
.github/workflows/schedule.yml
vendored
|
@ -14,7 +14,7 @@ jobs:
|
|||
docker create -t
|
||||
--name yadm-website
|
||||
--entrypoint test/validate
|
||||
yadm/jekyll:2019-10-17;
|
||||
yadm/jekyll:2024-10-31;
|
||||
docker cp ./ yadm-website:/srv/jekyll
|
||||
- name: Test Site
|
||||
run: docker start yadm-website -a
|
||||
|
|
7
CHANGES
7
CHANGES
|
@ -1,3 +1,10 @@
|
|||
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)
|
||||
|
||||
3.2.2
|
||||
* Support spaces in distro/distro-family (#432)
|
||||
* Fix zsh hanging when tab completing add/checkout (#417)
|
||||
|
|
10
CONTRIBUTORS
10
CONTRIBUTORS
|
@ -25,9 +25,9 @@ Paulo Köch
|
|||
Oren Zipori
|
||||
Daniel Gray
|
||||
Paraplegic Racehorse
|
||||
japm48
|
||||
Siôn Le Roux
|
||||
Mateusz Piotrowski
|
||||
japm48
|
||||
Uroš Golja
|
||||
Satoshi Ohki
|
||||
Jonas
|
||||
|
@ -35,18 +35,20 @@ Franciszek Madej
|
|||
Daniel Wagenknecht
|
||||
Stig Palmquist
|
||||
Patrick Hof
|
||||
con-f-use
|
||||
Samisafool
|
||||
LFdev
|
||||
con-f-use
|
||||
Bram Ceulemans
|
||||
Travis A. Everett
|
||||
Sheng Yang
|
||||
Jared Smartt
|
||||
Adam Jimerson
|
||||
dessert1
|
||||
addshore
|
||||
Tim Condit
|
||||
Thomas Luzat
|
||||
Russ Allbery
|
||||
Patrick Roddy
|
||||
dessert1
|
||||
Brayden Banks
|
||||
Alexandre GV
|
||||
addshore
|
||||
Felipe S. S. Schneider
|
||||
|
|
43
README.md
43
README.md
|
@ -56,32 +56,31 @@ The star count helps others discover yadm.
|
|||
[Git]: https://git-scm.com/
|
||||
[GnuPG]: https://gnupg.org/
|
||||
[OpenSSL]: https://www.openssl.org/
|
||||
[arch-badge]: https://img.shields.io/archlinux/v/community/any/yadm
|
||||
[arch-link]: https://archlinux.org/packages/community/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
|
||||
[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/yadm-dev/yadm/test.yml?branch=dev-pages
|
||||
[develop-badge]: https://img.shields.io/github/actions/workflow/status/yadm-dev/yadm/test.yml?branch=develop
|
||||
[develop-commits]: https://github.com/yadm-dev/yadm/commits/develop
|
||||
[develop-date]: https://img.shields.io/github/last-commit/yadm-dev/yadm/develop.svg?label=develop
|
||||
[dotfiles]: https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory
|
||||
[gh-pages-badge]: https://img.shields.io/github/actions/workflow/status/TheLocehiliosan/yadm/test.yml?branch=gh-pages
|
||||
[gh-pages-badge]: https://img.shields.io/github/actions/workflow/status/yadm-dev/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/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.2.2-blue
|
||||
[license-badge]: https://img.shields.io/github/license/yadm-dev/yadm.svg
|
||||
[license-link]: https://github.com/yadm-dev/yadm/blob/master/LICENSE
|
||||
[master-badge]: https://img.shields.io/github/actions/workflow/status/yadm-dev/yadm/test.yml?branch=master
|
||||
[master-commits]: https://github.com/yadm-dev/yadm/commits/master
|
||||
[master-date]: https://img.shields.io/github/last-commit/yadm-dev/yadm/master.svg?label=master
|
||||
[obs-badge]: https://img.shields.io/badge/OBS-v3.3.0-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
|
||||
[releases-badge]: https://img.shields.io/github/tag/yadm-dev/yadm.svg?label=latest+release
|
||||
[releases-link]: https://github.com/yadm-dev/yadm/releases
|
||||
[transcrypt]: https://github.com/elasticdog/transcrypt
|
||||
[travis-ci]: https://travis-ci.com/TheLocehiliosan/yadm/branches
|
||||
[website-commits]: https://github.com/TheLocehiliosan/yadm/commits/gh-pages
|
||||
[website-date]: https://img.shields.io/github/last-commit/TheLocehiliosan/yadm/gh-pages.svg?label=website
|
||||
[website-commits]: https://github.com/yadm-dev/yadm/commits/gh-pages
|
||||
[website-date]: https://img.shields.io/github/last-commit/yadm-dev/yadm/gh-pages.svg?label=website
|
||||
[website-link]: https://yadm.io/
|
||||
[workflow-dev-pages]: https://github.com/thelocehiliosan/yadm/actions?query=workflow%3a%22test+site%22+branch%3adev-pages
|
||||
[workflow-develop]: https://github.com/TheLocehiliosan/yadm/actions?query=workflow%3ATests+branch%3Adevelop
|
||||
[workflow-gh-pages]: https://github.com/thelocehiliosan/yadm/actions?query=workflow%3a%22test+site%22+branch%3agh-pages
|
||||
[workflow-master]: https://github.com/TheLocehiliosan/yadm/actions?query=workflow%3ATests+branch%3Amaster
|
||||
[workflow-dev-pages]: https://github.com/yadm-dev/yadm/actions?query=workflow%3a%22test+site%22+branch%3adev-pages
|
||||
[workflow-develop]: https://github.com/yadm-dev/yadm/actions?query=workflow%3ATests+branch%3Adevelop
|
||||
[workflow-gh-pages]: https://github.com/yadm-dev/yadm/actions?query=workflow%3a%22test+site%22+branch%3agh-pages
|
||||
[workflow-master]: https://github.com/yadm-dev/yadm/actions?query=workflow%3ATests+branch%3Amaster
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
# source <(curl -L bootstrap.yadm.io)
|
||||
#
|
||||
|
||||
YADM_REPO="https://github.com/TheLocehiliosan/yadm"
|
||||
YADM_REPO="https://github.com/yadm-dev/yadm"
|
||||
YADM_RELEASE=${release:-master}
|
||||
REPO_URL=""
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ Load `_yadm` as a plugin in your `.zshrc`:
|
|||
|
||||
```zsh
|
||||
fpath=("$ZPLUG_HOME/bin" $fpath)
|
||||
zplug "TheLocehiliosan/yadm", use:"completion/zsh/_yadm", as:command, defer:2
|
||||
zplug "yadm-dev/yadm", use:"completion/zsh/_yadm", as:command, defer:2
|
||||
```
|
||||
|
||||
## Fish (manual installation)
|
||||
|
|
|
@ -11,4 +11,4 @@ this is a place to share it.
|
|||
I recommend *careful review* of any code from here before using it. No
|
||||
guarantees of code quality is assumed.
|
||||
|
||||
[hooks-help]: https://github.com/TheLocehiliosan/yadm/blob/master/yadm.md#hooks
|
||||
[hooks-help]: https://github.com/yadm-dev/yadm/blob/master/yadm.md#hooks
|
||||
|
|
|
@ -57,8 +57,8 @@ RUN mkdir /yadm \
|
|||
&& echo "\t@false" >> /yadm/Makefile
|
||||
|
||||
# Include released versions of yadm to test upgrades
|
||||
ADD https://raw.githubusercontent.com/TheLocehiliosan/yadm/1.12.0/yadm /usr/local/bin/yadm-1.12.0
|
||||
ADD https://raw.githubusercontent.com/TheLocehiliosan/yadm/2.5.0/yadm /usr/local/bin/yadm-2.5.0
|
||||
ADD https://raw.githubusercontent.com/yadm-dev/yadm/1.12.0/yadm /usr/local/bin/yadm-1.12.0
|
||||
ADD https://raw.githubusercontent.com/yadm-dev/yadm/2.5.0/yadm /usr/local/bin/yadm-2.5.0
|
||||
RUN chmod +x /usr/local/bin/yadm-*
|
||||
|
||||
# Configure git to make it easier to test yadm manually
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Unit tests: template_default"""
|
||||
|
||||
import os
|
||||
|
||||
FILE_MODE = 0o754
|
||||
|
@ -12,6 +13,7 @@ LOCAL_HOST = "default_Test+@-!^Host"
|
|||
LOCAL_USER = "default_Test+@-!^User"
|
||||
LOCAL_DISTRO = "default_Test+@-!^Distro"
|
||||
LOCAL_DISTRO_FAMILY = "default_Test+@-!^Family"
|
||||
ENV_VAR = "default_Test+@-!^Env"
|
||||
TEMPLATE = f"""
|
||||
start of template
|
||||
default class = >{{{{yadm.class}}}}<
|
||||
|
@ -30,6 +32,9 @@ Included section from else
|
|||
{{% if yadm.class == "wrongclass1" %}}
|
||||
wrong class 1
|
||||
{{% endif %}}
|
||||
{{% if yadm.class != "wronglcass" %}}
|
||||
Included section from !=
|
||||
{{% endif\t\t %}}
|
||||
{{% if yadm.class == "{LOCAL_CLASS}" %}}
|
||||
Included section for class = {{{{yadm.class}}}} ({{{{yadm.class}}}} repeated)
|
||||
Multiple lines
|
||||
|
@ -97,6 +102,13 @@ Included section for distro_family = \
|
|||
{{% if yadm.distro_family == "wrongfamily2" %}}
|
||||
wrong family 2
|
||||
{{% endif %}}
|
||||
{{% if env.VAR == "{ENV_VAR}" %}}
|
||||
Included section for env.VAR = {{{{env.VAR}}}} ({{{{env.VAR}}}} again)
|
||||
{{% endif %}}
|
||||
{{% if env.VAR == "wrongenvvar" %}}
|
||||
wrong env.VAR
|
||||
{{% endif %}}
|
||||
yadm.no_such_var="{{{{ yadm.no_such_var }}}}" and env.NO_SUCH_VAR="{{{{ env.NO_SUCH_VAR }}}}"
|
||||
end of template
|
||||
"""
|
||||
EXPECTED = f"""
|
||||
|
@ -111,6 +123,7 @@ default distro_family = >{LOCAL_DISTRO_FAMILY}<
|
|||
classes = >{LOCAL_CLASS2}
|
||||
{LOCAL_CLASS}<
|
||||
Included section from else
|
||||
Included section from !=
|
||||
Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
|
||||
Multiple lines
|
||||
Included section for second class
|
||||
|
@ -121,6 +134,8 @@ 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)
|
||||
Included section for env.VAR = {ENV_VAR} ({ENV_VAR} again)
|
||||
yadm.no_such_var="" and env.NO_SUCH_VAR=""
|
||||
end of template
|
||||
"""
|
||||
|
||||
|
@ -138,7 +153,7 @@ The first line
|
|||
An empty file removes the line above
|
||||
{%include basic%}
|
||||
{% include "./variables.{{ yadm.os }}" %}
|
||||
{% include dir/nested %}
|
||||
{% include dir/nested %}
|
||||
Include basic again:
|
||||
{% include basic %}
|
||||
"""
|
||||
|
@ -154,6 +169,42 @@ Include basic again:
|
|||
basic
|
||||
"""
|
||||
|
||||
TEMPLATE_NESTED_IFS = """\
|
||||
{% if yadm.user == "me" %}
|
||||
print1
|
||||
{% if yadm.user == "me" %}
|
||||
print2
|
||||
{% else %}
|
||||
no print1
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if yadm.user == "me" %}
|
||||
no print2
|
||||
{% else %}
|
||||
no print3
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if yadm.user != "me" %}
|
||||
no print4
|
||||
{% if yadm.user == "me" %}
|
||||
no print5
|
||||
{% else %}
|
||||
no print6
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if yadm.user == "me" %}
|
||||
print3
|
||||
{% else %}
|
||||
no print7
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
"""
|
||||
EXPECTED_NESTED_IFS = """\
|
||||
print1
|
||||
print2
|
||||
print3
|
||||
"""
|
||||
|
||||
|
||||
def test_template_default(runner, yadm, tmpdir):
|
||||
"""Test template_default"""
|
||||
|
@ -182,7 +233,7 @@ def test_template_default(runner, yadm, tmpdir):
|
|||
local_distro_family="{LOCAL_DISTRO_FAMILY}"
|
||||
template_default "{input_file}" "{output_file}"
|
||||
"""
|
||||
run = runner(command=["bash"], inp=script)
|
||||
run = runner(command=["bash"], inp=script, env={"VAR": ENV_VAR})
|
||||
assert run.success
|
||||
assert run.err == ""
|
||||
assert output_file.read() == EXPECTED
|
||||
|
@ -243,12 +294,30 @@ def test_include(runner, yadm, tmpdir):
|
|||
assert os.stat(output_file).st_mode == os.stat(input_file).st_mode
|
||||
|
||||
|
||||
def test_nested_ifs(runner, yadm, tmpdir):
|
||||
"""Test nested if statements"""
|
||||
|
||||
input_file = tmpdir.join("input")
|
||||
input_file.write(TEMPLATE_NESTED_IFS, ensure=True)
|
||||
output_file = tmpdir.join("output")
|
||||
|
||||
script = f"""
|
||||
YADM_TEST=1 source {yadm}
|
||||
set_awk
|
||||
local_user="me"
|
||||
template_default "{input_file}" "{output_file}"
|
||||
"""
|
||||
run = runner(command=["bash"], inp=script)
|
||||
assert run.success
|
||||
assert run.err == ""
|
||||
assert output_file.read() == EXPECTED_NESTED_IFS
|
||||
|
||||
|
||||
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"""
|
||||
|
|
195
yadm
195
yadm
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
# yadm - Yet Another Dotfiles Manager
|
||||
# Copyright (C) 2015-2023 Tim Byrne
|
||||
# Copyright (C) 2015-2024 Tim Byrne
|
||||
|
||||
# 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
|
||||
|
@ -21,7 +21,7 @@ if [ -z "$BASH_VERSION" ]; then
|
|||
[ "$YADM_TEST" != 1 ] && exec bash "$0" "$@"
|
||||
fi
|
||||
|
||||
VERSION=3.2.2
|
||||
VERSION=3.3.0
|
||||
|
||||
YADM_WORK="$HOME"
|
||||
YADM_DIR=
|
||||
|
@ -204,6 +204,7 @@ function score_file() {
|
|||
return
|
||||
fi
|
||||
elif [[ "$label" =~ ^(d|distro)$ ]]; then
|
||||
value=$("${AWK_PROGRAM[0]}" '{print tolower($0)}' <<<"$value")
|
||||
if [ "${value/\ /_}" = "${local_distro/\ /_}" ]; then
|
||||
score=$((score + 4))
|
||||
else
|
||||
|
@ -211,6 +212,7 @@ function score_file() {
|
|||
return
|
||||
fi
|
||||
elif [[ "$label" =~ ^(f|distro_family)$ ]]; then
|
||||
value=$("${AWK_PROGRAM[0]}" '{print tolower($0)}' <<<"$value")
|
||||
if [ "${value/\ /_}" = "${local_distro_family/\ /_}" ]; then
|
||||
score=$((score + 8))
|
||||
else
|
||||
|
@ -368,87 +370,114 @@ function template_default() {
|
|||
# the explicit "space + tab" character class used below is used because not
|
||||
# all versions of awk seem to support the POSIX character classes [[:blank:]]
|
||||
read -r -d '' awk_pgm << "EOF"
|
||||
# built-in default template processor
|
||||
BEGIN {
|
||||
blank = "[ ]"
|
||||
c["class"] = class
|
||||
c["classes"] = classes
|
||||
c["arch"] = arch
|
||||
c["os"] = os
|
||||
c["hostname"] = host
|
||||
c["user"] = user
|
||||
c["distro"] = distro
|
||||
c["distro_family"] = distro_family
|
||||
c["source"] = source
|
||||
ifs = "^{%" blank "*if"
|
||||
els = "^{%" blank "*else" blank "*%}$"
|
||||
end = "^{%" blank "*endif" blank "*%}$"
|
||||
skp = "^{%" blank "*(if|else|endif)"
|
||||
vld = conditions()
|
||||
inc_start = "^{%" blank "*include" blank "+\"?"
|
||||
inc_end = "\"?" blank "*%}$"
|
||||
inc = inc_start ".+" inc_end
|
||||
prt = 1
|
||||
err = 0
|
||||
}
|
||||
END { exit err }
|
||||
{ replace_vars() } # variable replacements
|
||||
$0 ~ vld, $0 ~ end {
|
||||
if ($0 ~ vld || $0 ~ end) prt=1;
|
||||
if ($0 ~ els) prt=0;
|
||||
if ($0 ~ skp) next;
|
||||
}
|
||||
($0 ~ ifs && $0 !~ vld), $0 ~ end {
|
||||
if ($0 ~ ifs && $0 !~ vld) prt=0;
|
||||
if ($0 ~ els || $0 ~ end) prt=1;
|
||||
if ($0 ~ skp) next;
|
||||
}
|
||||
{ if (!prt) next }
|
||||
$0 ~ inc {
|
||||
file = $0
|
||||
sub(inc_start, "", file)
|
||||
sub(inc_end, "", file)
|
||||
sub(/^[^\/].*$/, source_dir "/&", file)
|
||||
classes = ARGV[2]
|
||||
for (i = 3; i < ARGC; ++i) {
|
||||
classes = classes "\n" ARGV[i]
|
||||
}
|
||||
yadm["class"] = class
|
||||
yadm["classes"] = classes
|
||||
yadm["arch"] = arch
|
||||
yadm["os"] = os
|
||||
yadm["hostname"] = host
|
||||
yadm["user"] = user
|
||||
yadm["distro"] = distro
|
||||
yadm["distro_family"] = distro_family
|
||||
yadm["source"] = source
|
||||
|
||||
while ((res = getline <file) > 0) {
|
||||
replace_vars()
|
||||
print
|
||||
}
|
||||
if (res < 0) {
|
||||
printf "%s:%d: error: could not read '%s'\n", FILENAME, NR, file | "cat 1>&2"
|
||||
err = 1
|
||||
}
|
||||
close(file)
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
function replace_vars() {
|
||||
for (label in c) {
|
||||
gsub(("{{" blank "*yadm\\." label blank "*}}"), c[label])
|
||||
}
|
||||
for (label in ENVIRON) {
|
||||
gsub(("{{" blank "*env\\." label blank "*}}"), ENVIRON[label])
|
||||
}
|
||||
}
|
||||
function condition_helper(label, value) {
|
||||
gsub(/[\\.^$(){}\[\]|*+?]/, "\\\\&", value)
|
||||
return sprintf("yadm\\.%s" blank "*==" blank "*\"%s\"", label, value)
|
||||
}
|
||||
function conditions() {
|
||||
pattern = ifs blank "+("
|
||||
for (label in c) {
|
||||
if (label != "class") {
|
||||
value = c[label]
|
||||
pattern = sprintf("%s%s|", pattern, condition_helper(label, value));
|
||||
}
|
||||
}
|
||||
VARIABLE = "(env|yadm)\\.[a-zA-Z0-9_]+"
|
||||
|
||||
current = 0
|
||||
filename[current] = ARGV[1]
|
||||
line[current] = 0
|
||||
|
||||
level = 0
|
||||
skip[level] = 0
|
||||
|
||||
for (; current >= 0; --current) {
|
||||
while ((res = getline <filename[current]) > 0) {
|
||||
++line[current]
|
||||
if ($0 ~ "^[ \t]*\\{%[ \t]*if[ \t]+" VARIABLE "[ \t]*[!=]=[ \t]*\".*\"[ \t]*%\\}$") {
|
||||
if (skip[level]) { skip[++level] = 1; continue }
|
||||
|
||||
match($0, VARIABLE)
|
||||
lhs = substr($0, RSTART, RLENGTH)
|
||||
match($0, /[!=]=/)
|
||||
op = substr($0, RSTART, RLENGTH)
|
||||
match($0, /".*"/)
|
||||
rhs = replace_vars(substr($0, RSTART + 1, RLENGTH - 2))
|
||||
|
||||
if (lhs == "yadm.class") {
|
||||
lhs = "not" rhs
|
||||
split(classes, cls_array, "\n")
|
||||
for (idx in cls_array) {
|
||||
value = cls_array[idx]
|
||||
pattern = sprintf("%s%s|", pattern, condition_helper("class", value));
|
||||
if (rhs == cls_array[idx]) { lhs = rhs; break }
|
||||
}
|
||||
sub(/\|$/, ")" blank "*%}$", pattern)
|
||||
return pattern
|
||||
}
|
||||
else {
|
||||
lhs = replace_vars("{{" lhs "}}")
|
||||
}
|
||||
|
||||
if (op == "==") { skip[++level] = lhs != rhs }
|
||||
else { skip[++level] = lhs == rhs }
|
||||
}
|
||||
else if (/^[ \t]*\{%[ \t]*else[ \t]*%\}$/) {
|
||||
if (level == 0 || skip[level] < 0) { error("else without matching if") }
|
||||
skip[level] = skip[level] ? skip[level - 1] : -1
|
||||
}
|
||||
else if (/^[ \t]*\{%[ \t]*endif[ \t]*%\}$/) {
|
||||
if (--level < 0) { error("endif without matching if") }
|
||||
}
|
||||
else if (!skip[level]) {
|
||||
$0 = replace_vars($0)
|
||||
if (match($0, /^[ \t]*\{%[ \t]*include[ \t]+("[^"]+"|[^"]+)[ \t]*%\}$/)) {
|
||||
include = $0
|
||||
sub(/^[ \t]*\{%[ \t]*include[ \t]+"?/, "", include)
|
||||
sub(/"?[ \t]*%\}$/, "", include)
|
||||
if (index(include, "/") != 1) {
|
||||
include = source_dir "/" include
|
||||
}
|
||||
filename[++current] = include
|
||||
line[current] = 0
|
||||
}
|
||||
else { print }
|
||||
}
|
||||
}
|
||||
if (res >= 0) { close(filename[current]) }
|
||||
else if (current == 0) { error("could not read input file") }
|
||||
else { --current; error("could not read include file '" filename[current + 1] "'") }
|
||||
}
|
||||
if (level > 0) {
|
||||
current = 0
|
||||
error("unterminated if")
|
||||
}
|
||||
exit 0
|
||||
}
|
||||
function error(text) {
|
||||
printf "%s:%d: error: %s\n",
|
||||
filename[current], line[current], text > "/dev/stderr"
|
||||
exit 1
|
||||
}
|
||||
function replace_vars(input) {
|
||||
output = ""
|
||||
while (match(input, "\\{\\{[ \t]*" VARIABLE "[ \t]*\\}\\}")) {
|
||||
if (RSTART > 1) {
|
||||
output = output substr(input, 0, RSTART - 1)
|
||||
}
|
||||
data = substr(input, RSTART + 2, RLENGTH - 4)
|
||||
input = substr(input, RSTART + RLENGTH)
|
||||
|
||||
gsub(/[ \t]+/, "", data)
|
||||
split(data, fields, /\./)
|
||||
|
||||
if (fields[1] == "env") {
|
||||
output = output ENVIRON[fields[2]]
|
||||
}
|
||||
else {
|
||||
output = output yadm[fields[2]]
|
||||
}
|
||||
}
|
||||
return output input
|
||||
}
|
||||
EOF
|
||||
|
||||
|
@ -462,9 +491,8 @@ EOF
|
|||
-v distro_family="$local_distro_family" \
|
||||
-v source="$input" \
|
||||
-v source_dir="$(dirname "$input")" \
|
||||
-v classes="$(join_string $'\n' "${local_classes[@]}")" \
|
||||
"$awk_pgm" \
|
||||
"$input" > "$temp_file" || rm -f "$temp_file"
|
||||
"$input" "${local_classes[@]}" > "$temp_file" || rm -f "$temp_file"
|
||||
|
||||
move_file "$input" "$output" "$temp_file"
|
||||
}
|
||||
|
@ -1522,7 +1550,7 @@ function query_distro() {
|
|||
fi
|
||||
done < "$OS_RELEASE"
|
||||
fi
|
||||
echo "$distro"
|
||||
"${AWK_PROGRAM[0]}" '{print tolower($0)}' <<<"$distro"
|
||||
}
|
||||
|
||||
function query_distro_family() {
|
||||
|
@ -1533,10 +1561,13 @@ function query_distro_family() {
|
|||
family="${line#ID_LIKE=}"
|
||||
family="${family//\"}"
|
||||
break
|
||||
elif [[ -z "$family" && "$line" = ID=* ]]; then
|
||||
family="${line#ID=}"
|
||||
family="${family//\"}"
|
||||
fi
|
||||
done < "$OS_RELEASE"
|
||||
fi
|
||||
echo "$family"
|
||||
"${AWK_PROGRAM[0]}" '{print tolower($0)}' <<<"$distro"
|
||||
}
|
||||
|
||||
function process_global_args() {
|
||||
|
|
4
yadm.1
4
yadm.1
|
@ -1,5 +1,5 @@
|
|||
.\" vim: set spell so=8:
|
||||
.TH yadm 1 "23 January 2023" "3.2.2"
|
||||
.TH yadm 1 "8 November 2024" "3.3.0"
|
||||
|
||||
.SH NAME
|
||||
|
||||
|
@ -989,7 +989,7 @@ Commit a new set of encrypted files
|
|||
|
||||
Report issues or create pull requests at GitHub:
|
||||
|
||||
https://github.com/TheLocehiliosan/yadm/issues
|
||||
https://github.com/yadm-dev/yadm/issues
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
|
|
14
yadm.md
14
yadm.md
|
@ -1,6 +1,4 @@
|
|||
|
||||
|
||||
|
||||
## NAME
|
||||
yadm - Yet Another Dotfiles Manager
|
||||
|
||||
|
@ -516,10 +514,10 @@
|
|||
|
||||
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
|
||||
"default" or just leave the value off (e.g. "##template").
|
||||
very basic, with a Jinja-like syntax. The advantage of this
|
||||
processor 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
|
||||
|
@ -798,7 +796,7 @@
|
|||
## REPORTING BUGS
|
||||
Report issues or create pull requests at GitHub:
|
||||
|
||||
https://github.com/TheLocehiliosan/yadm/issues
|
||||
https://github.com/yadm-dev/yadm/issues
|
||||
|
||||
|
||||
## AUTHOR
|
||||
|
@ -810,5 +808,3 @@
|
|||
|
||||
https://yadm.io/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}}
|
||||
Name: yadm
|
||||
Summary: Yet Another Dotfiles Manager
|
||||
Version: 3.2.2
|
||||
Version: 3.3.0
|
||||
Group: Development/Tools
|
||||
Release: 1%{?dist}
|
||||
URL: https://yadm.io
|
||||
|
|
Loading…
Reference in a new issue