]> git.scottworley.com Git - pinch/blobdiff - pinch.py
Better error message for running "update" before "pin"
[pinch] / pinch.py
index a7d5b65dc6af1b58625f2a9ab1801629bb67fc67..f84440c5c0fd54e4831b893edc4c7ed94a446909 100644 (file)
--- a/pinch.py
+++ b/pinch.py
@@ -25,6 +25,9 @@ from typing import (
     Tuple,
 )
 
+import xdg
+
+
 Digest16 = NewType('Digest16', str)
 Digest32 = NewType('Digest32', str)
 
@@ -216,9 +219,9 @@ def fetch_resources(v: Verification, channel: Channel) -> None:
 
 
 def git_cachedir(git_repo: str) -> str:
-    # TODO: Consider using pyxdg to find this path.
-    return os.path.expanduser(
-        '~/.cache/pinch/git/%s' %
+    return os.path.join(
+        xdg.XDG_CACHE_HOME,
+        'pinch/git',
         digest_string(
             git_repo.encode()))
 
@@ -506,6 +509,11 @@ def update(args: argparse.Namespace) -> None:
                 assert 'git_repo' not in config[section]
                 continue
 
+            if 'git_repo' not in config[section] or 'release_name' not in config[section]:
+                raise Exception(
+                    'Cannot update unpinned channel "%s" (Run "pin" before "update")' %
+                    section)
+
             if 'channel_url' in config[section]:
                 tarball = fetch_with_nix_prefetch_url(
                     v, config[section]['tarball_url'], Digest16(