fix about Gemfile.lock.(Make the folder name be about revision(commit id) if gem package has an revision number)

This commit is contained in:
BOHUNG 2019-10-08 21:47:35 +08:00
parent 6e56a10e98
commit b890c6ec3b
2 changed files with 88 additions and 59 deletions

View File

@ -187,7 +187,6 @@ module Bundler
rescue PathError => e rescue PathError => e
Bundler.ui.trace e Bundler.ui.trace e
raise GitError, "#{to_s} is not yet checked out. Run `bundle install` first." raise GitError, "#{to_s} is not yet checked out. Run `bundle install` first."
git_proxy.checkout
end end
# This is the path which is going to contain a cache # This is the path which is going to contain a cache

View File

@ -75,36 +75,49 @@ module Bundler
Bundler.ui.confirm "Updating #{uri}" Bundler.ui.confirm "Updating #{uri}"
FileUtils.cd(path) FileUtils.cd(path)
git_retry %|fetch --force --quiet --tags #{uri_escaped} "refs/heads/*:refs/heads/*"| git_retry %|fetch --force --quiet --tags #{uri_escaped} "refs/heads/*:refs/heads/*"|
@commit_num = `git log -1 --pretty=format:"%H"`[0..11] if path.to_s.include?("cache")
@new_path = path.dirname @commit_num = `git log -1 --pretty=format:"%H"`[0..11] if revision.nil?
@old_folder_name = path.basename.to_s + '/' @commit_num = revision[0..11] if !revision.nil?
@fold_name ='' @new_path = path.dirname
@fold_name = path.basename.to_s @old_folder_name = path.basename.to_s + '/'
@fold_name = @fold_name.split('-')[0..-2].join('-') @fold_name =''
@new_path += (@fold_name + '-' + @commit_num) @fold_name = path.basename.to_s
path = @new_path @fold_name = @fold_name.split('-')[0..-2].join('-')
FileUtils.cd('..') @new_path += (@fold_name + '-' + @commit_num)
FileUtils.mv( @old_folder_name , path.basename.to_s+'/') if (Dir.exist? (path.basename.to_s+'/')) == false path = @new_path
FileUtils.cd(@new_path.to_s) FileUtils.cd('..')
@path_destination = Pathname.new(path.dirname) FileUtils.mv( @old_folder_name , path.basename.to_s+'/') if ( Dir.exist?(path.basename.to_s+'/')) == false
@path_destination= @path_destination.parent.parent.parent + Pathname.new("bundler/gems/#{path.basename}") FileUtils.rmdir @old_folder_name.to_s if ( Dir.exist?(@old_folder_name.to_s+'/') && (@old_folder_name.to_s != path.basename.to_s))
if (Dir.exist?(@path_destination.to_s)) == false FileUtils.cd(@new_path.to_s)
begin @path_destination = Pathname.new(path.dirname)
FileUtils.cd(@path_destination.dirname) @path_destination= @path_destination.parent.parent.parent + Pathname.new("bundler/gems/#{path.basename}")
rescue if (Dir.exist?(@path_destination.to_s)) == false
FileUtils.mkdir_p(@path_destination.dirname) begin
FileUtils.cd(@path_destination.dirname) FileUtils.cd(@path_destination.dirname)
rescue
FileUtils.mkdir_p(@path_destination.dirname)
FileUtils.cd(@path_destination.dirname)
end
FileUtils.mkdir(@path_destination.basename)
`cp -r "#{path}"/. "#{@path_destination}"/.git/`
FileUtils.cd(@path_destination.basename)
`git init`
`git checkout "#{ref}"`
end
@gemspec_name = ''
FileUtils.cd(@path_destination.to_s)
`ls`.split.each{|name| (@gemspec_name = name.to_s and break) if (name.include? '.gemspec') == true}
Dir.chdir(Bundler.root.to_s) do
Bundler::load_gemspec("#{@path_destination}/#{@gemspec_name}") rescue puts "you don't have .gemspec file at #{@path_destination}"
end
else
@gemspec_name = ''
FileUtils.cd(path.to_s)
`ls`.split.each{|name| (@gemspec_name = name.to_s and break) if (name.include? '.gemspec') == true}
Dir.chdir(Bundler.root.to_s) do
Bundler::load_gemspec("#{path}/#{@gemspec_name}") rescue puts "you don't have .gemspec file at #{path}"
end end
FileUtils.mkdir(@path_destination.basename)
`cp -r "#{path}"/. "#{@path_destination}"/.git/`
FileUtils.cd(@path_destination.basename)
`git init`
`git checkout "#{ref}"`
end end
@gemspec_name = ''
FileUtils.cd(@path_destination.to_s)
`ls`.split.each{|name| (@gemspec_name = name.to_s and break) if (name.include? '.gemspec') == true}
Bundler::load_gemspec("#{@path_destination}/#{@gemspec_name}") rescue puts "you don't have .gemspec file at #{@path_destination}"
FileUtils.cd(@old_pwd) FileUtils.cd(@old_pwd)
end end
else else
@ -112,38 +125,55 @@ module Bundler
if path != nil if path != nil
FileUtils.mkdir_p(path.dirname) FileUtils.mkdir_p(path.dirname)
git_retry %|clone #{uri_escaped} "#{path}" --bare --no-hardlinks --quiet| git_retry %|clone #{uri_escaped} "#{path}" --bare --no-hardlinks --quiet|
FileUtils.cd(path) if path.to_s.include?("cache")
git_retry %|fetch --all| FileUtils.cd(path)
@commit_num = `git log -1 --pretty=format:"%H"`[0..11] git_retry %|fetch --all|
@new_path = path.dirname @commit_num = `git log -1 --pretty=format:"%H"`[0..11] if revision.nil?
@old_folder_name = path.basename.to_s + '/' @commit_num = revision[0..11] if !revision.nil?
@fold_name ='' @new_path = path.dirname
@fold_name = path.basename.to_s @old_folder_name = path.basename.to_s + '/'
@fold_name = @fold_name.split('-')[0..-2].join('-') @fold_name =''
@new_path += (@fold_name + '-' + @commit_num) @fold_name = path.basename.to_s
path = @new_path @fold_name = @fold_name.split('-')[0..-2].join('-')
FileUtils.cd('..') @new_path += (@fold_name + '-' + @commit_num)
FileUtils.mv( @old_folder_name , path.basename.to_s+'/') if (Dir.exist? (path.basename.to_s+'/')) == false path = @new_path
FileUtils.cd(@new_path.to_s) FileUtils.cd('..')
@path_destination = Pathname.new(path.dirname) FileUtils.mv( @old_folder_name , path.basename.to_s+'/') if (Dir.exist? (path.basename.to_s+'/')) == false
@path_destination= @path_destination.parent.parent.parent + Pathname.new("bundler/gems/#{path.basename}") FileUtils.rmdir @old_folder_name.to_s if ( Dir.exist?(@old_folder_name.to_s+'/') && (@old_folder_name.to_s != path.basename.to_s))
if (Dir.exist?(@path_destination.to_s)) == false FileUtils.cd(@new_path.to_s)
begin @path_destination = Pathname.new(path.dirname)
FileUtils.cd(@path_destination.dirname) @path_destination= @path_destination.parent.parent.parent + Pathname.new("bundler/gems/#{path.basename}")
rescue if (Dir.exist?(@path_destination.to_s)) == false
FileUtils.mkdir_p(@path_destination.dirname) begin
FileUtils.cd(@path_destination.dirname) FileUtils.cd(@path_destination.dirname)
rescue
FileUtils.mkdir_p(@path_destination.dirname)
FileUtils.cd(@path_destination.dirname)
end
FileUtils.mkdir(@path_destination.basename)
`cp -r "#{path}"/. "#{@path_destination}"/.git/`
FileUtils.cd(@path_destination.basename)
`git init`
`git checkout "#{ref}"`
end
@gemspec_name = ''
FileUtils.cd(@path_destination.to_s)
`ls`.split.each{|name| (@gemspec_name = name.to_s and break) if (name.include? '.gemspec') == true}
@EXT_LOCK.synchronize do
Dir.chdir(Bundler.root.to_s) do
Bundler::load_gemspec("#{@path_destination}/#{@gemspec_name}") rescue puts "you don't have .gemspec file at #{@path_destination}"
end
end
else
@gemspec_name = ''
FileUtils.cd(path.to_s)
`ls`.split.each{|name| (@gemspec_name = name.to_s and break) if (name.include? '.gemspec') == true}
@EXT_LOCK.synchronize do
Dir.chdir(Bundler.root.to_s) do
Bundler::load_gemspec("#{path}/#{@gemspec_name}") rescue puts "you don't have .gemspec file at #{path}"
end
end end
FileUtils.mkdir(@path_destination.basename)
`cp -r "#{path}"/. "#{@path_destination}"/.git/`
FileUtils.cd(@path_destination.basename)
`git init`
`git checkout "#{ref}"`
end end
@gemspec_name = ''
FileUtils.cd(@path_destination.to_s)
`ls`.split.each{|name| (@gemspec_name = name.to_s and break) if (name.include? '.gemspec') == true}
Bundler::load_gemspec("#{@path_destination}/#{@gemspec_name}") rescue puts "you don't have .gemspec file at #{@path_destination}"
end end
end end
FileUtils.cd(@org_pwd) FileUtils.cd(@org_pwd)