The packaged copies use config.default_path() and pipeline._history_path(): files next to the sources in a checkout, ~/.config/<name> and ~/.local/state/<name> when installed. The copies now differ from the originals only in the neutral defaults. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -148,7 +148,7 @@ def main(argv=None) -> int:
|
||||
|
||||
args = p.parse_args(argv)
|
||||
color(sys.stdout.isatty() and not args.no_color)
|
||||
cfg_path = Path(args.config) if args.config else Path(__file__).resolve().parent.parent / "deploy.toml"
|
||||
cfg_path = Path(args.config) if args.config else config.default_path()
|
||||
try:
|
||||
cfg = config.load(cfg_path)
|
||||
except (OSError, config.ConfigError) as e:
|
||||
|
||||
@@ -211,3 +211,11 @@ def append_apps(path: Path, apps: list[App], drafts: list[App] = ()) -> None:
|
||||
block = "".join(f"# {line}\n" for line in app_to_toml(a).splitlines())
|
||||
text = text.rstrip("\n") + "\n\n# TODO: check src / build / dest, then uncomment\n" + block
|
||||
path.write_text(text)
|
||||
|
||||
|
||||
def default_path() -> Path:
|
||||
"""deploy.toml next to the sources (a checkout), else ~/.config/deployer/deploy.toml (an installed package)."""
|
||||
local = Path(__file__).resolve().parent.parent / "deploy.toml"
|
||||
if local.exists():
|
||||
return local
|
||||
return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "deployer" / "deploy.toml"
|
||||
|
||||
@@ -13,8 +13,17 @@ from . import kinds, remote, snapshots
|
||||
from .config import App, Config
|
||||
from .kinds import Options, Plan
|
||||
|
||||
# Das OS package: /usr/lib is read-only, so the history goes to the user's state dir
|
||||
HISTORY = Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "deployer" / "history.log"
|
||||
|
||||
|
||||
def _history_path() -> Path:
|
||||
"""history.log next to the sources (a checkout), else ~/.local/state/deployer/ (an installed package)."""
|
||||
local = Path(__file__).resolve().parent.parent
|
||||
if os.access(local, os.W_OK):
|
||||
return local / "history.log"
|
||||
return Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "deployer" / "history.log"
|
||||
|
||||
|
||||
HISTORY = _history_path()
|
||||
|
||||
|
||||
class DeployError(RuntimeError):
|
||||
|
||||
Reference in New Issue
Block a user