Skip to content

[BUG] Refuse to deploy a template onto its own source #218

Description

@viktorashi

Environment

  • OS: Ubuntu
  • Dotter version: 0.13.5
  • Additional relevant information

Description

Crazy schizo edge-case, but if a directory is deployed as a single symlink (recurse = false) and a file inside that directory is also configured as a template, the template's target path resolves through the directory symlink back to the template's own source file.

Reproduction

[nvim.files]
"files/nvim" = { target = "~/.config/nvim", type = "symbolic", recurse = false }
"files/nvim/lua/keys.lua" = { target = "~/.config/nvim/lua/keys.lua", type = "template" }

Without --force this is reported as target file already exists. Skipping., which is misleading but harmless. With --force, dotter removes the target — which is the source — and then fails reading it:

[WARN] Creating template "files/nvim/lua/keys.lua" -> ".../.config/nvim/lua/keys.lua" but target file already exists. Forcing.
[ERROR] Failed to create template ...
Caused by:
    perform template cache
    read template source file
    read from file
   No such file or directory (os error 2)

The file is gone from the repository, and there is nothing to recover it from.

Expected behavior

A check should be added that a template's source and target are not the same file.

Actual behavior

The file is gone from the repository, and there is nothing to recover it from.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions