Skip to content

Remove dead restic wrapper layer#12

Merged
wnstfy merged 1 commit into
developfrom
chore/dead-code-restic
Jun 21, 2026
Merged

Remove dead restic wrapper layer#12
wnstfy merged 1 commit into
developfrom
chore/dead-code-restic

Conversation

@wnstfy

@wnstfy wnstfy commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Part of a grouped dead-code cleanup (3 PRs, split by area so each can be reviewed independently). This PR removes the unused wrapper layer in lib/restic.sh.

lib/restic.sh exported 30 functions wrapping the restic binary, but the generated backup/restore/verify scripts call restic directly. Only four helpers have real callers:

  • get_restic_repo, init_restic_repo, repo_exists — used by generators.sh and setup.sh
  • apply_retention_days — used by backup.sh

The verify_quick/verify_full copies were additionally shadowed by lib/verify.sh's later definitions, so they could never run.

Changes

  • Drop 30 zero-caller functions from lib/restic.sh (517 → 73 lines)
  • Trim tests/unit/restic.bats to the surviving helpers

Why it's safe

Every removed function was verified to have zero production callers (including inside the generated-script heredocs). No behaviour change.

Testing

  • ./tests/run-tests.sh --syntax — 22 files pass
  • ./tests/run-tests.sh --unit — all unit tests pass
  • shellcheck -x -s bash -S warning backupd.sh lib/*.sh — clean

Targets develop. Hold for green CI + review before merge.

lib/restic.sh exported 30 wrapper functions around the restic binary, but
the generated backup/restore/verify scripts call restic directly. Only four
have real callers (get_restic_repo, init_restic_repo, repo_exists used by
generators/setup; apply_retention_days used by backup.sh). The verify_quick/
verify_full copies were also shadowed by lib/verify.sh's later definitions.

Drop the 30 dead functions and trim restic.bats to the surviving helpers.
No behaviour change: every deleted function had zero production callers.
@greptile-apps

greptile-apps Bot commented Jun 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR removes 30 zero-caller wrapper functions from lib/restic.sh (517 → 73 lines) and trims the corresponding unit tests, leaving only the four helpers that have confirmed callers in generators.sh, setup.sh, and backup.sh.

  • lib/restic.sh: All removed functions were verified to have no production callers; the four retained helpers (get_restic_repo, init_restic_repo, repo_exists, apply_retention_days) remain intact and are explicitly sourced by the generated backup scripts.
  • tests/unit/restic.bats: --retry-lock presence and lockless-function checks are correctly narrowed to match only the surviving functions; unlock_repo and check_locks are cleanly removed from the lockless-check list since they no longer exist in the source.

Confidence Score: 5/5

Safe to merge — removes only dead code, leaves all four actively-used helpers in place, and the generated scripts continue to source restic.sh correctly.

Every removed function was cross-checked against callers in the rest of the codebase and in generated-script heredocs; none had callers. The four retained functions (get_restic_repo, init_restic_repo, repo_exists, apply_retention_days) are each called from confirmed production paths. The test trim is consistent with the source changes and the logic of both bats tests remains correct for the surviving helpers.

No files require special attention.

Important Files Changed

Filename Overview
lib/restic.sh Drops 30 dead wrapper functions (517→73 lines), keeping the four helpers (get_restic_repo, init_restic_repo, repo_exists, apply_retention_days) that have confirmed callers in generators.sh, setup.sh, and backup.sh.
tests/unit/restic.bats Trims the --retry-lock presence and lockless-function tests to match only the four surviving helpers; removed functions are correctly absent from both test lists.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph callers["Production Callers"]
        GEN["lib/generators.sh\n(generated script heredocs)"]
        SETUP["lib/setup.sh"]
        BACKUP["lib/backup.sh"]
    end

    subgraph restic_sh["lib/restic.sh (after PR)"]
        GRR["get_restic_repo()"]
        IRR["init_restic_repo()"]
        RE["repo_exists()"]
        ARD["apply_retention_days()"]
    end

    subgraph removed["Removed (0 callers)"]
        RM["30 functions:\nunlock_repo, backup_database_stdin,\nbackup_files, restore_database,\nverify_quick/full/partial,\nlist_snapshots, get_repo_stats,\nrun_restic, check_locks, ..."]
    end

    GEN -->|sources restic.sh, calls| GRR
    GEN -->|calls| IRR
    GEN -->|calls| RE
    SETUP -->|calls| IRR
    SETUP -->|calls| RE
    BACKUP -->|calls| ARD

    style removed fill:#f8d7da,stroke:#dc3545
    style restic_sh fill:#d4edda,stroke:#28a745
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    subgraph callers["Production Callers"]
        GEN["lib/generators.sh\n(generated script heredocs)"]
        SETUP["lib/setup.sh"]
        BACKUP["lib/backup.sh"]
    end

    subgraph restic_sh["lib/restic.sh (after PR)"]
        GRR["get_restic_repo()"]
        IRR["init_restic_repo()"]
        RE["repo_exists()"]
        ARD["apply_retention_days()"]
    end

    subgraph removed["Removed (0 callers)"]
        RM["30 functions:\nunlock_repo, backup_database_stdin,\nbackup_files, restore_database,\nverify_quick/full/partial,\nlist_snapshots, get_repo_stats,\nrun_restic, check_locks, ..."]
    end

    GEN -->|sources restic.sh, calls| GRR
    GEN -->|calls| IRR
    GEN -->|calls| RE
    SETUP -->|calls| IRR
    SETUP -->|calls| RE
    BACKUP -->|calls| ARD

    style removed fill:#f8d7da,stroke:#dc3545
    style restic_sh fill:#d4edda,stroke:#28a745
Loading

Reviews (1): Last reviewed commit: "Remove unused restic wrapper functions" | Re-trigger Greptile

@wnstfy
wnstfy merged commit b950222 into develop Jun 21, 2026
4 checks passed
@wnstfy
wnstfy deleted the chore/dead-code-restic branch June 21, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant