]> git.scottworley.com Git - pinch/commitdiff
Require type to be specified in config
authorScott Worley <scottworley@scottworley.com>
Mon, 15 Jun 2020 18:38:12 +0000 (11:38 -0700)
committerScott Worley <scottworley@scottworley.com>
Thu, 18 Jun 2020 06:15:29 +0000 (23:15 -0700)
channels
default.nix
pinch.py
setup.py
tests/alias.sh
tests/lib/test-setup.sh
tests/multi-update.sh
tests/reject-partially-unpinned.sh

index dc1f75454751822a85518060fbb7a155aad940ee..a4b984d53cce3d81ea0c07de46eb1168441f6cb0 100644 (file)
--- a/channels
+++ b/channels
@@ -1,9 +1,11 @@
 [nixos]
 [nixos]
+type = channel
 channel_url = https://channels.nixos.org/nixos-20.03
 git_repo = https://github.com/NixOS/nixpkgs.git
 git_ref = nixos-20.03
 
 [nixos-hardware]
 channel_url = https://channels.nixos.org/nixos-20.03
 git_repo = https://github.com/NixOS/nixpkgs.git
 git_ref = nixos-20.03
 
 [nixos-hardware]
+type = git
 git_repo = https://github.com/NixOS/nixos-hardware.git
 git_ref = master
 
 git_repo = https://github.com/NixOS/nixos-hardware.git
 git_ref = master
 
index c2c751cdcb18517e407df9ea8373f77dc06ed366..3209685a0cdc7fb17244ca945fe34383b3ec9163 100644 (file)
@@ -3,7 +3,7 @@ pkgs.python3Packages.callPackage
 ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, }:
   buildPythonPackage rec {
     pname = "pinch";
 ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, }:
   buildPythonPackage rec {
     pname = "pinch";
-    version = "1.5.1";
+    version = "2.0.0-pre";
     src = lib.cleanSource ./.;
     checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ];
     doCheck = true;
     src = lib.cleanSource ./.;
     checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ];
     doCheck = true;
index f5fbb481bea3cb0df30bf45f12c40d58dda55f83..ea380a3a332137e2b70fbcb507603c800687ebdb 100644 (file)
--- a/pinch.py
+++ b/pinch.py
@@ -22,9 +22,11 @@ from typing import (
     Dict,
     Iterable,
     List,
     Dict,
     Iterable,
     List,
+    Mapping,
     NamedTuple,
     NewType,
     Tuple,
     NamedTuple,
     NewType,
     Tuple,
+    Type,
     Union,
 )
 
     Union,
 )
 
@@ -585,11 +587,12 @@ def git_revision_name(v: Verification, channel: TarrableSearchPath) -> str:
 
 
 def read_search_path(conf: configparser.SectionProxy) -> SearchPath:
 
 
 def read_search_path(conf: configparser.SectionProxy) -> SearchPath:
-    if 'alias_of' in conf:
-        return AliasSearchPath(**dict(conf.items()))
-    if 'channel_url' in conf:
-        return ChannelSearchPath(**dict(conf.items()))
-    return GitSearchPath(**dict(conf.items()))
+    mapping: Mapping[str, Type[SearchPath]] = {
+        'alias': AliasSearchPath,
+        'channel': ChannelSearchPath,
+        'git': GitSearchPath,
+    }
+    return mapping[conf['type']](**dict(conf.items()))
 
 
 def read_config(filename: str) -> configparser.ConfigParser:
 
 
 def read_config(filename: str) -> configparser.ConfigParser:
index b7d3a26206ab5a80672513c0c21638749fd3fee5..e5d1ebe6aa0a4418b309ecf54deae1fd84b7974e 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup
 
 setup(
     name="pinch",
 
 setup(
     name="pinch",
-    version="1.5.1",
+    version="2.0.0-pre",
     py_modules=['pinch'],
     entry_points={"console_scripts": ["pinch = pinch:main"]},
 )
     py_modules=['pinch'],
     entry_points={"console_scripts": ["pinch = pinch:main"]},
 )
index 928ceabee147c1cce50fa56c2b5ca8badc6215be..dce5747beebc7b859477da1fd525685f6d5a6db4 100755 (executable)
@@ -6,6 +6,7 @@ foo_setup
 
 cat >> "$conf" <<EOF
 [bar]
 
 cat >> "$conf" <<EOF
 [bar]
+type = alias
 alias_of = foo
 EOF
 
 alias_of = foo
 EOF
 
index 66d13eb8b776c5886873f0645118163306737735..4742ff02a354a4b667ea2abaf552aa5c5e00465f 100644 (file)
@@ -28,6 +28,7 @@ foo_setup() {
   conf="`mktemp`"
   cat > "$conf" <<EOF
 [foo]
   conf="`mktemp`"
   cat > "$conf" <<EOF
 [foo]
+type = git
 git_repo = file://$repo
 git_ref = master
 EOF
 git_repo = file://$repo
 git_ref = master
 EOF
index cd6e90bd707acee40714af68ce4a801b37a1de22..aa617c8b90db3c7c01207c23bd7d0750c2477f94 100755 (executable)
@@ -7,6 +7,7 @@ foo_setup
 conf2="`mktemp`"
 cat > "$conf2" <<EOF
 [bar]
 conf2="`mktemp`"
 cat > "$conf2" <<EOF
 [bar]
+type = alias
 alias_of = foo
 EOF
 
 alias_of = foo
 EOF
 
index 5fc61fdaadcacec795413c0e9a3000f3943f3d07..b2eca0a3842bee620881929af0199c0f5797fea5 100755 (executable)
@@ -8,6 +8,7 @@ python3 ./pinch.py pin "$conf"
 
 cat >> "$conf" <<EOF
 [bar]
 
 cat >> "$conf" <<EOF
 [bar]
+type = git
 git_repo = file://$repo
 git_ref = master
 EOF
 git_repo = file://$repo
 git_ref = master
 EOF