Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.1.1 #29

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ jobs:
- name: Cargo check
run: cargo check
- name: Run tests
run: cargo nextest run
run: |
cargo build
cargo nextest run
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.1](https://github.com/elkowar/yolk/compare/v0.1.0...v0.1.1) - 2025-01-26

### Added

- run canonicalization for git through git filters

## [0.1.0](https://github.com/elkowar/yolk/compare/v0.0.16...v0.1.0) - 2025-01-06

### Added
Expand Down
36 changes: 35 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "yolk_dots"
authors = ["ElKowar <[email protected]>"]
description = "Templated dotfile management without template files"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
repository = "https://github.com/elkowar/yolk"
homepage = "https://elkowar.github.io/yolk"
Expand Down Expand Up @@ -51,6 +51,7 @@ winnow = { version = "0.6.20", features = ["unstable-recover"] }
cov-mark = "2.0.0"
arbitrary = { version = "1.4.1", features = ["derive"] }
symlink = "0.1.0"
hex = "0.4.3"
# rhai-autodocs = { version = "0.7.0", path = "../../clones/rhai-autodocs" }

[dev-dependencies]
Expand All @@ -68,6 +69,7 @@ test-log = { version = "0.2.16", default-features = false, features = [
"color",
"trace",
] }
assert_cmd = "2.0.16"

[profile.dev.package]
insta = { opt-level = 3 }
Expand Down
10 changes: 3 additions & 7 deletions docs/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,15 @@ back to the alacritty egg directory `~/.config/yolk/eggs/alacritty`.
### Committing your dots to git

Now, we want to make sure our dotfiles are in version control and pushed to our git host of choice.
Every interaction with git should be done through the `yolk git` command.
This ensures that git sees the canonical (stable) representation of your files, and automatically performs them from within the yolk directory.
Yolk sets up a [git-filter in your .gitattributes](https://git-scm.com/docs/gitattributes#_long_running_filter_process) to ensure that git sees the canonical (stable) representation of your files.
For convenience, you can use the `yolk git` command to interact with your git repository from anywhere on your system.

```bash
$ yolk git init
$ yolk safeguard
$ yolk git add --all
$ yolk git commit -m "Setup alacritty"
```

To understand what `yolk safeguard` does, see [safeguarding git](./git_concepts.md#safeguarding-git).

You can now set up your git reomte and use git as usual -- just remember to always use `yolk git`, especially when you're committing your files.
You can now set up your git reomte and use git as usual.

### Baby's first template

Expand Down
22 changes: 3 additions & 19 deletions docs/src/git_concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,17 @@

Basic familiarity with git is assumed.

## Safeguarding git
## How yolk works with git

Yolk wraps the git CLI to ensure that git only ever interacts with your dotfiles in their canonical state.
If it didn't do that, you would end up committing the local state of your dotfiles,
which would conflict with their state from another machine -- which is what yolk is trying to solve.

To ensure that you're not accidentally using the regular git CLI for your dotfiles, it is recommended to "safeguard" your dotfiles' git directory.
To do this, simply run

```bash
$ yolk safeguard
```

after cloning or initializing your dotfiles.

This simply renames the `.git` directory to `.yolk_git`, which means the regular git CLI won't see the repository anymore.
You are now more or less forced to use the `yolk git` command instead -- which conveniently doesn't just ensure consistency of the git state,
but also works from anywhere in your filesystem!
An important part of how yolk works is that your dotfiles will always be committed in a "canonical" state, no matter from what system.
Yolk achieves this by setting up a git filter that will automatically transform all templated files into their canonical variants whenever git is reading them.

## Cloning your dotfiles

To clone your dotfiles on a new machine, simply clone the repository to `.config/yolk`, and safeguard your git directory.

```bash
$ git clone <your-dots-repo> "$XDG_CONFIG_HOME/yolk"
$ yolk safeguard
```

After that, you can start `yolk sync`ing your eggs!
Expand All @@ -42,4 +27,3 @@ So, instead of
- `git commit -m "cool changes"`, you run `yolk git commit -m "cool changes`,

and so on.
This ensures the files are always in the correct canonical state, and makes it possible to interact with a safeguarded git repository.
32 changes: 32 additions & 0 deletions docs/src/yolk_rhai.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,35 @@ To look at the contents of those variables or try out your logic, you can always
```bash
$ yolk eval 'print(SYSTEM)'
```

## Splitting up into multiple files

Rhai allows you to import other files into your scripts.
For example, let's say you want to keep your color theme definition in a separate file.
Simply create a new `colors.rhai` file next to your `yolk.rhai`, and make sure to explicitly declare exported variables as `export`:

```rust
export let gruvbox = #{
background: "#282828",
foreground: "#ebdbb2",
};

fn some_function() {
print("hi")
}
```

Note that functions are exported by default.

Now, in your `yolk.rhai`, import this script, giving the module an explict name:

```rs
import "colors" as colors;
```

Now you can refer to anything exported from that file as `colors::thing`, i.e.:

```rs
let theme = colors::gruvbox;
colors::some_function();
```
2 changes: 2 additions & 0 deletions src/eggs_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ impl EggConfig {
.collect()
}

/// Expand the glob patterns in the `templates` field to a list of paths.
/// The globbed paths are considered relative to `in_dir`. The resulting list of paths will contain absolute paths.
pub fn templates_globexpanded(&self, in_dir: impl AsRef<Path>) -> miette::Result<Vec<PathBuf>> {
let in_dir = in_dir.as_ref();
let mut paths = Vec::new();
Expand Down
Loading
Loading