Skip to content

dotctl save should clean up stale data not listed in dotctl.yaml #45

@pankajackson

Description

@pankajackson

Currently, when running dotctl save, the tool saves dotfiles and configs listed in dotctl.yaml, but it does not remove previously saved files that were removed from the config.

This causes the .dot repository to accumulate stale or outdated files that are no longer being tracked in the latest config.

🔍 Steps to Reproduce:

  1. Add a config path ~/.bashrc to dotctl.yaml
  2. Run dotctl save → saves .bashrc to the dot repo
  3. Remove ~/.bashrc from dotctl.yaml
  4. Run dotctl save again
  5. .bashrc still exists in the dot repo

✅ Expected Behavior:
dotctl save should:

  • Detect and remove previously saved files in the dot repo that are no longer present in dotctl.yaml
  • Optionally log or warn about removed files for user awareness

💡 Suggested Fix:
During the save operation:

  1. Track the list of already saved paths (maybe in a cache file or scanning the dot repo)
  2. Compare against the current list in dotctl.yaml
  3. Remove any entries not in the config
  4. Optionally support a --prune flag if user wants to control this behavior

📌 Feature Summary:

  • Compare previously saved paths vs current dotctl.yaml
  • Remove orphaned files from the dot repo
  • Add optional --prune or config flag to toggle this behavior
  • Log removals for transparency

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