Merge pull request #133832 from teto/fix-vim-plugin-updater

update.py: fix vim's updater script
This commit is contained in:
Bernardo Meurer 2021-08-13 23:11:04 +00:00 committed by GitHub
commit d0ef2714a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,7 +86,7 @@ class PluginDesc:
owner: str owner: str
repo: str repo: str
branch: str branch: str
alias: str alias: Optional[str]
class Repo: class Repo:
@ -317,12 +317,10 @@ def get_current_plugins(editor: Editor) -> List[Plugin]:
def prefetch_plugin( def prefetch_plugin(
user: str, p: PluginDesc,
repo_name: str,
branch: str,
alias: Optional[str],
cache: "Optional[Cache]" = None, cache: "Optional[Cache]" = None,
) -> Tuple[Plugin, Dict[str, str]]: ) -> Tuple[Plugin, Dict[str, str]]:
user, repo_name, branch, alias = p.owner, p.repo, p.branch, p.alias
log.info(f"Fetching last commit for plugin {user}/{repo_name}@{branch}") log.info(f"Fetching last commit for plugin {user}/{repo_name}@{branch}")
repo = Repo(user, repo_name, branch, alias) repo = Repo(user, repo_name, branch, alias)
commit, date = repo.latest_commit() commit, date = repo.latest_commit()
@ -347,7 +345,7 @@ def prefetch_plugin(
def fetch_plugin_from_pluginline(plugin_line: str) -> Plugin: def fetch_plugin_from_pluginline(plugin_line: str) -> Plugin:
plugin, _ = prefetch_plugin(*parse_plugin_line(plugin_line)) plugin, _ = prefetch_plugin(parse_plugin_line(plugin_line))
return plugin return plugin
@ -466,11 +464,11 @@ class Cache:
def prefetch( def prefetch(
args: PluginDesc, cache: Cache pluginDesc: PluginDesc, cache: Cache
) -> Tuple[str, str, Union[Exception, Plugin], dict]: ) -> Tuple[str, str, Union[Exception, Plugin], dict]:
owner, repo = args.owner, args.repo owner, repo = pluginDesc.owner, pluginDesc.repo
try: try:
plugin, redirect = prefetch_plugin(owner, repo, args.branch, args.alias, cache) plugin, redirect = prefetch_plugin(pluginDesc, cache)
cache[plugin.commit] = plugin cache[plugin.commit] = plugin
return (owner, repo, plugin, redirect) return (owner, repo, plugin, redirect)
except Exception as e: except Exception as e:
@ -576,8 +574,9 @@ def update_plugins(editor: Editor, args):
if autocommit: if autocommit:
commit( commit(
nixpkgs_repo, nixpkgs_repo,
"{editor.get_drv_name name}: init at {version}".format( "{drv_name}: init at {version}".format(
editor=editor.name, name=plugin.normalized_name, version=plugin.version drv_name=editor.get_drv_name(plugin.normalized_name),
version=plugin.version
), ),
[args.outfile, args.input_file], [args.outfile, args.input_file],
) )