Skip to content
Browse files

vim-plugin-manager: Automatically generate addon-info.json (VAM)

See issue xolox/vim-misc#4 on GitHub:
  xolox/vim-misc#4
  • Loading branch information...
1 parent 5479ac9 commit 90aa93df848a4b8221c7f00fffc3da75ee5b8012 @xolox committed Jun 22, 2013
Showing with 25 additions and 4 deletions.
  1. +25 −4 vim-plugin-manager.py
View
29 vim-plugin-manager.py
@@ -4,7 +4,7 @@
# Publish Vim plug-ins to GitHub and Vim Online.
#
# Author: Peter Odding <peter@peterodding.com>
-# Last Change: June 2, 2013
+# Last Change: June 22, 2013
# URL: http://peterodding.com/code/vim/tools/
#
# TODO Automatically run tests before release? (first have to start writing them!)
@@ -39,6 +39,7 @@
import codecs
import ConfigParser
import getopt
+import json
import logging
import netrc
import os
@@ -514,6 +515,7 @@ def run_precommit_hooks(self):
self.logger.info("Running pre-commit hooks ..")
plugin_name = self.find_current_plugin()
self.check_gitignore_file(plugin_name)
+ self.update_vam_addon_info(plugin_name)
self.update_copyright(plugin_name)
self.run_vimdoctool(plugin_name)
self.run_html2vimdoc(plugin_name)
@@ -522,11 +524,11 @@ def check_gitignore_file(self, plugin_name):
"""
Make sure .gitignore excludes doc/tags.
"""
- self.logger.debug("Checking if .gitignore excludes doc/tags ..")
+ self.logger.verbose("Checking if .gitignore excludes doc/tags ..")
directory = self.plugins[plugin_name]['directory']
# Make sure there is an initial commit, otherwise git on Ubuntu 10.04
# will error out with "fatal: No HEAD commit to compare with (yet)".
- self.logger.debug("Checking whether there is an initial commit ..")
+ self.logger.verbose("Checking whether there is an initial commit ..")
try:
run('git', 'rev-parse', 'HEAD', capture=True)
except ExternalCommandFailed:
@@ -538,13 +540,32 @@ def check_gitignore_file(self, plugin_name):
self.logger.fatal("The .gitignore file does not exclude doc/tags! Please resolve before committing.")
sys.exit(1)
+ def update_vam_addon_info(self, plugin_name):
+ """
+ Make sure addon-info.json is up to date. This file is used by
+ vim-addon-manager (VAM).
+ """
+ self.logger.verbose("Updating addon-info.json ..")
+ directory = self.plugins[plugin_name]['directory']
+ addon_info_file = os.path.join(directory, 'addon-info.json')
+ addon_info = dict(name=plugin_name.split('/')[-1],
+ homepage=self.plugins[plugin_name]['homepage'],
+ dependencies=dict())
+ if plugin_name != 'xolox/vim-misc':
+ addon_info['dependencies']['vim-misc'] = dict()
+ if 'script-id' in self.plugins[plugin_name]:
+ addon_info['vim_script_nr'] = int(self.plugins[plugin_name]['script-id'])
+ with open(addon_info_file, 'w') as handle:
+ handle.write(json.dumps(addon_info))
+ run('git', 'add', addon_info_file, cwd=directory)
+
def update_copyright(self, plugin_name):
"""
Update the year of copyright in README.md when needed.
"""
contents = []
updated_copyright = False
- self.logger.debug("Checking if copyright in README is up to date ..")
+ self.logger.verbose("Checking if copyright in README is up to date ..")
directory = self.plugins[plugin_name]['directory']
filename = os.path.join(directory, 'README.md')
with codecs.open(filename, 'r', 'utf-8') as handle:

0 comments on commit 90aa93d

Please sign in to comment.
Something went wrong with that request. Please try again.