[SCM] vim-addon-manager packaging branch, master, updated. b31130973799a11c994e0ac1f3e1e118bd22f5d8

James Vega jamessan at debian.org
Mon Aug 24 12:20:26 UTC 2009


The following commit has been merged in the master branch:
commit b31130973799a11c994e0ac1f3e1e118bd22f5d8
Author: James Vega <jamessan at debian.org>
Date:   Sat Aug 22 15:59:36 2009 -0400

    Remove empty directories left behind when removing addons.
    
    Signed-off-by: James Vega <jamessan at debian.org>

diff --git a/debian/changelog b/debian/changelog
index a2511fa..418e080 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ vim-addon-manager (0.4.2) UNRELEASED; urgency=low
   * Rename amend sub-command to enable.  Leave amend as an undocumented
     command for a little while for people that are used to the old name.
     (Closes: #501439)
+  * Remove empty directories left behind when removing addons.
 
  -- James Vega <jamessan at debian.org>  Fri, 24 Jul 2009 19:56:48 +0200
 
diff --git a/src/vim/addon-manager.rb b/src/vim/addon-manager.rb
index 86e812f..3d87164 100644
--- a/src/vim/addon-manager.rb
+++ b/src/vim/addon-manager.rb
@@ -58,24 +58,33 @@ module Vim
     end
 
     def remove(addons)
-      # TODO remove empty directories (recursively toward the top of ~/.vim/,
-      # a la rmdir -p)
       removed_files = []
-      rmlink = lambda {|file| File.delete(File.join(@target_dir, file)) }
+      rmdirs = lambda do |file|
+	File.delete(File.join(@target_dir, file))
+	paths = File.split(File.dirname(file))
+	while paths.size
+	  begin
+	    FileUtils.rmdir(File.join(@target_dir, paths))
+	  rescue Errno::ENOTEMPTY
+	    break
+	  end
+	  paths.pop
+	end
+      end
       addons.each do |addon|
 	status = addon.status(@target_dir)
 	case status.status
 	when :installed
 	  Vim.info "removing installed addon '#{addon}'"
-	  addon.files.each(&rmlink)
-          removed_files.concat(addon.files.to_a)
+	  addon.files.each(&rmdirs)
+	  removed_files.concat(addon.files.to_a)
 	when :broken
 	  Vim.info "removing broken addon '#{addon}'"
-          files = (addon.files - status.missing_files)
-	  files.each(&rmlink)
-          removed_files.concat(files.to_a)
-        else
-          Vim.info "ignoring '#{addon}' which is neither installed nor broken"
+	  files = (addon.files - status.missing_files)
+	  files.each(&rmdirs)
+	  removed_files.concat(files.to_a)
+	else
+	  Vim.info "ignoring '#{addon}' which is neither installed nor broken"
 	end
       end
       rebuild_tags(removed_files)
@@ -133,7 +142,7 @@ module Vim
     end
 
     private
-    
+
     def map_override_lines
       override_lines = []
       override_file = Vim.override_file @target_dir

-- 
vim-addon-manager packaging



More information about the pkg-vim-maintainers mailing list