Skip to content

Commit

Permalink
Removed yaml creation code
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtom committed Nov 6, 2010
1 parent 4e66536 commit d16fc98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 185 deletions.
46 changes: 5 additions & 41 deletions README.markdown
Expand Up @@ -44,11 +44,8 @@ Create a vimball and upload it to vim.org with
[vimscriptuploader.rb](http://github.org/tomtom/vimscriptuploader.rb):

rm myplugin.yml || echo ignore error
vimball.rb -u --save-yaml -- vba myplugin.recipe
# myplugin.yml is created by vimball.rb
# A more sophisticated solution wouldn't remove the older yaml file
# but compare timestamps.
if [ -e myplugin.yml ]; then
if vimball.rb -u --save-yaml -- vba myplugin.recipe | grep "vimball: Save as"; then
vimscriptdef.rb --recipe myplugin.recipe
vimscriptuploader.rb --user foo --password bar myplugin.yml
fi

Expand All @@ -62,41 +59,6 @@ Install a vimball as a "bundle" (i.e. in its own directory under
vimball.rb --repo install myplugin.vba


Uploading vimballs to vim.org
-----------------------------

vimball.rb doesn't upload files by itself but it can save a script
definition as yaml file, which can be fed to
[vimscriptuploader.rb](http://github.org/tomtom/vimscriptuploader.rb).

In order to make this work, your scripts have to comply to the following
convention:

* At least one file must contain a `GetLatestVimScripts` tagline. If the
file is "foo.vim", the line must look somewhat like:

`" GetLatestVimScripts: 123 0 :AutoInstall: foo.vim`

* At least one file must set a global `loaded_PLUGIN` variable. If the
plugin is "bar", the corresponding line must look like:

`let loaded_bar = VERSION_NUMBER`

where `VERSION_NUMBER` is an integer that complies with vim's version
numbering system (see :help v:version).

* If you use tags, vimball.rb will compile the comment version from the
commit messages since the latest tag. The following tag formats are
supported (e.g. if the version number is 1.02): v102, 102, 1.02.

If you don't use tags, version comments are limited to simple messages
if the configuration file defines a field `history_fmt` that must
contain one `%s`, which will be filled in with the plugin name, the
formatted string will be posted as version comment.

The MD5 checksum will be added to the version comment.


Dependencies
------------

Expand All @@ -105,4 +67,6 @@ Dependencies


<!-- 2010-11-01; @Last Change: 2010-11-01. -->
<!-- vi: ft=markdown:tw=72:ts=4 -->
<!--
vi: ft=markdown:tw=72:ts=4
-->
144 changes: 0 additions & 144 deletions vimball.rb
Expand Up @@ -148,21 +148,6 @@ def with_args(args)
exit
end

opts.on('--print-version NAME', String, 'Print the plugins current version number') do |value|
recipe = File.join(config['outdir'], "#{value}.recipe")
puts Vimball.new(config).get_version(recipe, value)
exit
end

opts.on('--print-saved-version NAME', String, 'Print the plugins last saved version number') do |value|
yaml = File.join(config['outdir'], "#{value}.yml")
if File.exist?(yaml)
script_def = YAML.load_file(yaml)
puts script_def['version']
end
exit
end

opts.on('-R', '--[no-]recipe', 'On install, save the recipe in DESTDIR/vimballs/recipes') do |bool|
config['save_recipes'] = bool
end
Expand All @@ -179,10 +164,6 @@ def with_args(args)
config['update'] = bool
end

opts.on('-y', '--save-yaml [YAML]', String, 'Save a YAML script definition that can be fed to vimscriptuploader.rb') do |value|
config['script_def_yaml'] = value
end

opts.on('-z', '--gzip', 'Save as vba.gz') do |value|
config['compress'] = value
end
Expand Down Expand Up @@ -377,10 +358,6 @@ def do_vba(recipe)
end
end

if @config.has_key?('script_def_yaml')
get_script_def(name)
end

end


Expand Down Expand Up @@ -561,127 +538,6 @@ def filename_on_disk(name, file, filename)
end
end


def get_script_def(name)
recipe = File.join(@config['outdir'], "#{name}.recipe")
vimball = File.join(@config['outdir'], "#{name}.vba")
script_yml = @config['script_def_yaml'] || File.join(@config['outdir'], "#{name}.yml")
if File.exist?(script_yml)
script_def = YAML.load_file(script_yml)
else
script_def = {}
end

script_id = get_id(name, recipe)
if script_id.nil?
$logger.error "No Script ID found"
elsif (script_def.has_key?('id') and script_def['id'] != script_id)
$logger.error "Script ID mismatch: Expected #{script_def['id']} but got #{script_id}"
return nil
end
script_def['id'] = script_id

script_def['version'] = get_version(recipe, name)
if script_def['version'].nil?
return nil
end

script_def['message'] = ""
if @repo and File.exist?(File.join(@repo, '.git'))
FileUtils.cd(@repo) do
tags = `git tag`.split(/\n/)
unless tags.empty?
tags.sort! do |a, b|
if a =~ /^v?(\d+)$/
a = $1
af = a.to_f / 100
else
af = a.to_f
end
if b =~ /^v?(\d+)$/
b = $1
bf = b.to_f / 100
else
bf = b.to_f
end
if af == 0 and bf == 0
a <=> b
else
af <=> bf
end
end
latest_tag = tags.last
$logger.debug "git log --oneline #{latest_tag}.."
changes = `git log --oneline #{latest_tag}..`
unless changes.empty?
changes = changes.split(/\n/).map do |line|
line.sub(/^\S+/, '-')
end
if @config['ignore_git_messages_rx']
ignore_git_messages_rx = Regexp.new(@config['ignore_git_messages_rx'])
changes.delete_if {|line| line =~ ignore_git_messages_rx}
end
script_def['message'] = changes.join("\n")
script_def['message'] << "\n" unless script_def['message'].empty?
end
end
end
end
# p "DBG", script_def['message']
if script_def['message'].empty? and @config.has_key?('history_fmt')
script_def['message'] = @config['history_fmt'] % name
script_def['message'] << "\n"
end
vba = File.open(vimball, 'rb') {|io| io.read}
script_def['message'] << "MD5 checksum: #{Digest::MD5.hexdigest(vba)}"

script_def['file'] = vimball

File.open(script_yml, 'w') {|io| YAML.dump(script_def, io)}
return script_def
end


def get_id(name, recipe)
File.readlines(recipe).each do |line|
file = line.chomp
filename = filename_on_disk(name, file, file)
bname = File.basename(filename)
File.readlines(filename).each do |line|
if line.chomp =~ /^" GetLatestVimScripts: (\d+) +\d+ +(:AutoInstall: +)?#{bname}$/
id = $1
if id and !id.empty? and id.to_i != 0 and id =~ /[1-9]/
$logger.debug "#{name}: Script ID is ##{id}"
return id
end
end
end
end
return nil
end


def get_version(recipe, name)
$logger.debug "Get version number for #{name} (#{recipe})"
File.readlines(recipe).each do |line|
file = line.chomp
filename = filename_on_disk(name, file, file)
$logger.debug "Get version number in #{filename}"
File.readlines(filename).each do |line|
if line.chomp =~ /^let (g:)?loaded_#{name} = (\d+)$/
version = $2.to_i
major = version / 100
minor = version - major * 100
majmin = "%d.%02d" % [major, minor]
$logger.debug "#{name}: Version number is #{majmin}"
return majmin
end
end
end
$logger.error "Cannot find version number: #{recipe}"
return nil
end

end


Expand Down

0 comments on commit d16fc98

Please sign in to comment.