Commits

Alessio Caiazza committed 6ee80ac

fixed .hgignore
gemspec should use hg locate instead of git ls-files
Gem#git_version can extrach hash from hg summary
autoload GemHelperMercurial

  • Participants
  • Parent commits a7aa126

Comments (0)

Files changed (4)

   autoload :Environment,         'bundler/environment'
   autoload :Fetcher,             'bundler/fetcher'
   autoload :GemHelper,           'bundler/gem_helper'
+  autoload :GemHelperMercurial,  'bundler/gem_helper_mercurial'
   autoload :Graph,               'bundler/graph'
   autoload :Index,               'bundler/index'
   autoload :Installer,           'bundler/installer'

lib/bundler/rubygems_ext.rb

     end
 
     def git_version
-      if @loaded_from && File.exist?(File.join(full_gem_path, ".git"))
-        sha = Dir.chdir(full_gem_path){ `git rev-parse HEAD`.strip }
-        " #{sha[0..6]}"
+      if @loaded_from
+        if File.exist?(File.join(full_gem_path, ".git"))
+          sha = Dir.chdir(full_gem_path){ `git rev-parse HEAD`.strip }
+          " #{sha[0..6]}"
+        elsif File.exist?(File.join(full_gem_path, '.hg'))
+          " #{$1}" if  /\b\d+:(\w{12})\b/ =~ `hg summary`
+        end
       end
     end
 

lib/bundler/templates/newgem/hgignore.tt

-glob: *.gem
-relre: ^\.bundle/
-glob: Gemfile.lock
-relre: ^pkg/
+syntax: glob 
+
+*.gem
+Gemfile.lock
+
+syntax: regexp
+
+^\.bundle/
+^pkg/

lib/bundler/templates/newgem/newgem.gemspec.tt

   s.description = %q{TODO: Write a gem description}
 
   s.rubyforge_project = <%=config[:name].inspect%>
-
+<% if config[:hg]%>
+  s.files         = `hg locate`.split("\n")
+  s.test_files    = `hg locate {test,spec,features}/*`.split("\n")
+  s.executables   = `hg locate bin/*`.split("\n").map{ |f| File.basename(f) }
+<% else %>
   s.files         = `git ls-files`.split("\n")
   s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
   s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+<% end %>
   s.require_paths = ["lib"]
 end