Skip to content

Commit

Permalink
vim-plugin-manager: Automatically generate addon-info.json (VAM)
Browse files Browse the repository at this point in the history
See issue xolox/vim-misc#4 on GitHub:
  xolox/vim-misc#4
  • Loading branch information
xolox committed Jun 22, 2013
1 parent 5479ac9 commit 90aa93d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions vim-plugin-manager.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Publish Vim plug-ins to GitHub and Vim Online. # Publish Vim plug-ins to GitHub and Vim Online.
# #
# Author: Peter Odding <peter@peterodding.com> # Author: Peter Odding <peter@peterodding.com>
# Last Change: June 2, 2013 # Last Change: June 22, 2013
# URL: http://peterodding.com/code/vim/tools/ # URL: http://peterodding.com/code/vim/tools/
# #
# TODO Automatically run tests before release? (first have to start writing them!) # TODO Automatically run tests before release? (first have to start writing them!)
Expand Down Expand Up @@ -39,6 +39,7 @@
import codecs import codecs
import ConfigParser import ConfigParser
import getopt import getopt
import json
import logging import logging
import netrc import netrc
import os import os
Expand Down Expand Up @@ -514,6 +515,7 @@ def run_precommit_hooks(self):
self.logger.info("Running pre-commit hooks ..") self.logger.info("Running pre-commit hooks ..")
plugin_name = self.find_current_plugin() plugin_name = self.find_current_plugin()
self.check_gitignore_file(plugin_name) self.check_gitignore_file(plugin_name)
self.update_vam_addon_info(plugin_name)
self.update_copyright(plugin_name) self.update_copyright(plugin_name)
self.run_vimdoctool(plugin_name) self.run_vimdoctool(plugin_name)
self.run_html2vimdoc(plugin_name) self.run_html2vimdoc(plugin_name)
Expand All @@ -522,11 +524,11 @@ def check_gitignore_file(self, plugin_name):
""" """
Make sure .gitignore excludes doc/tags. 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'] directory = self.plugins[plugin_name]['directory']
# Make sure there is an initial commit, otherwise git on Ubuntu 10.04 # 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)". # 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: try:
run('git', 'rev-parse', 'HEAD', capture=True) run('git', 'rev-parse', 'HEAD', capture=True)
except ExternalCommandFailed: except ExternalCommandFailed:
Expand All @@ -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.") self.logger.fatal("The .gitignore file does not exclude doc/tags! Please resolve before committing.")
sys.exit(1) 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): def update_copyright(self, plugin_name):
""" """
Update the year of copyright in README.md when needed. Update the year of copyright in README.md when needed.
""" """
contents = [] contents = []
updated_copyright = False 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'] directory = self.plugins[plugin_name]['directory']
filename = os.path.join(directory, 'README.md') filename = os.path.join(directory, 'README.md')
with codecs.open(filename, 'r', 'utf-8') as handle: with codecs.open(filename, 'r', 'utf-8') as handle:
Expand Down

0 comments on commit 90aa93d

Please sign in to comment.