about summary refs log tree commit diff
path: root/pkgs/misc/vim-plugins
diff options
context:
space:
mode:
authorryneeverett <ryneeverett@gmail.com>2020-03-26 06:11:20 +0000
committerryneeverett <ryneeverett@gmail.com>2020-03-27 15:30:54 +0000
commit7cc024b59e03b33de0a073f9205f47dc18029bde (patch)
tree6046c91e9c4d053d4a6af0c86504726d96096fec /pkgs/misc/vim-plugins
parentb886ad90e7395d98d9c4956eef817e29bfce71a5 (diff)
downloadnixlib-7cc024b59e03b33de0a073f9205f47dc18029bde.tar
nixlib-7cc024b59e03b33de0a073f9205f47dc18029bde.tar.gz
nixlib-7cc024b59e03b33de0a073f9205f47dc18029bde.tar.bz2
nixlib-7cc024b59e03b33de0a073f9205f47dc18029bde.tar.lz
nixlib-7cc024b59e03b33de0a073f9205f47dc18029bde.tar.xz
nixlib-7cc024b59e03b33de0a073f9205f47dc18029bde.tar.zst
nixlib-7cc024b59e03b33de0a073f9205f47dc18029bde.zip
vimPlugins: Automatic rename deprecations
When an updated redirect results in a package name change, not just an
owner change, throw an error to warn users the package names has
changed.
Diffstat (limited to 'pkgs/misc/vim-plugins')
-rw-r--r--pkgs/misc/vim-plugins/aliases.nix15
-rw-r--r--pkgs/misc/vim-plugins/deprecated.json6
-rwxr-xr-xpkgs/misc/vim-plugins/update.py23
3 files changed, 27 insertions, 17 deletions
diff --git a/pkgs/misc/vim-plugins/aliases.nix b/pkgs/misc/vim-plugins/aliases.nix
index 627008a2aebf..645b8db7db44 100644
--- a/pkgs/misc/vim-plugins/aliases.nix
+++ b/pkgs/misc/vim-plugins/aliases.nix
@@ -31,11 +31,12 @@ let
                               (checkInPkgs n alias)))
                      aliases;
 
-  deprecateName = oldName: newName:
-    throw "${oldName} was renamed to ${newName}. Please update to ${newName}.";
-in
+  deprecations = lib.mapAttrs (old: new:
+    throw "${old} was renamed to ${new}. Please update to ${new}."
+  ) (builtins.fromJSON (builtins.readFile ./deprecated.json));
 
-mapAliases {
+in
+mapAliases ({
   airline             = vim-airline;
   alternative         = a-vim; # backwards compat, added 2014-10-21
   bats                = bats-vim;
@@ -71,7 +72,6 @@ mapAliases {
   ghcmod              = ghcmod-vim;
   goyo                = goyo-vim;
   Gist                = vim-gist;
-  gist-vim            = deprecateName "vim-gist" "gist-vim"; # backwards compat, added 2020-3-22
   gitgutter           = vim-gitgutter;
   gundo               = gundo-vim;
   Gundo               = gundo-vim; # backwards compat, added 2015-10-03
@@ -129,17 +129,14 @@ mapAliases {
   unite               = unite-vim;
   UltiSnips           = ultisnips;
   vim-addon-vim2nix   = vim2nix;
-  vim-jade            = deprecateName "vim-pug" "vim-jade"; # backwards compat, added 2020-3-22
   vimproc             = vimproc-vim;
   vimshell            = vimshell-vim;
   vinegar             = vim-vinegar;
-  vundle              = deprecateName "Vundle-vim" "vundle"; # backwards compat, added 2020-3-22
   watchdogs           = vim-watchdogs;
   WebAPI              = webapi-vim;
   wombat256           = wombat256-vim; # backwards compat, added 2015-7-8
   yankring            = YankRing-vim;
   Yankring            = YankRing-vim;
-  youcompleteme       = deprecateName "YouCompleteMe" "youcompleteme"; # backwards compat, added 2020-3-22
   xterm-color-table   = xterm-color-table-vim;
   zeavim              = zeavim-vim;
-}
+} // deprecations)
diff --git a/pkgs/misc/vim-plugins/deprecated.json b/pkgs/misc/vim-plugins/deprecated.json
new file mode 100644
index 000000000000..bb4ad18c3ecd
--- /dev/null
+++ b/pkgs/misc/vim-plugins/deprecated.json
@@ -0,0 +1,6 @@
+{
+    "gist-vim": "vim-gist",
+    "vim-jade": "vim-pug",
+    "vundle": "Vundle.vim",
+    "youcompleteme": "YouCompleteMe"
+}
\ No newline at end of file
diff --git a/pkgs/misc/vim-plugins/update.py b/pkgs/misc/vim-plugins/update.py
index ac959f055b48..d513669d0f32 100755
--- a/pkgs/misc/vim-plugins/update.py
+++ b/pkgs/misc/vim-plugins/update.py
@@ -34,6 +34,7 @@ ATOM_UPDATED = "{http://www.w3.org/2005/Atom}updated"  # "
 ROOT = Path(__file__).parent
 DEFAULT_IN = ROOT.joinpath("vim-plugin-names")
 DEFAULT_OUT = ROOT.joinpath("generated.nix")
+DEPRECATED = ROOT.joinpath("deprecated.json")
 
 import time
 from functools import wraps
@@ -130,9 +131,6 @@ class Repo:
             new_plugin = plugin_line.format(owner=new_owner, name=new_name)
             self.redirect[old_plugin] = new_plugin
 
-            if new_name != self.name:
-                print(f"Plugin Name Changed: {self.name} -> {new_name}")
-
     def prefetch_git(self, ref: str) -> str:
         data = subprocess.check_output(
             ["nix-prefetch-git", "--fetch-submodules", self.url(""), ref]
@@ -421,6 +419,17 @@ def rewrite_input(input_file: Path, output_file: Path, redirects: dict):
 
     if redirects:
         lines = [redirects.get(line, line) for line in lines]
+
+        with open(DEPRECATED, "r") as f:
+            deprecations = json.load(f)
+        for old, new in redirects.items():
+            old_name = old.split("/")[1].split(" ")[0].strip("\n")
+            new_name = new.split("/")[1].split(" ")[0].strip("\n")
+            if old_name != new_name:
+                deprecations[old_name] = new_name
+        with open(DEPRECATED, "w") as f:
+            json.dump(deprecations, f, indent=4, sort_keys=True)
+
         print(
             f"""\
 Redirects have been detected and {input_file} has been updated. Please take the
@@ -428,13 +437,11 @@ following steps:
     1. Go ahead and commit just the updated expressions as you intended to do:
             git add {output_file}
             git commit -m "vimPlugins: Update"
-    2. If any of the plugin names were changed, throw an error in aliases.nix:
-            <oldName> = deprecateName "<oldName>" "<newName>"; # backwards compat, added YYYY-MM-DD
-    3. Run this script again so these changes will be reflected in the
+    2. Run this script again so these changes will be reflected in the
     generated expressions:
             ./update.py
-    4. Commit {input_file} along with aliases and generated expressions:
-            git add {output_file} {input_file} aliases.nix
+    3. Commit {input_file} along with deprecations and generated expressions:
+            git add {output_file} {input_file} {DEPRECATED}
             git commit -m "vimPlugins: Update redirects"
         """
         )