[file-store-4] rename task file && remove abf.yml check && some optimize
This commit is contained in:
parent
541a739c12
commit
0d893c4b20
|
@ -15,7 +15,7 @@ rclient = RestClient::Resource.new(url, :user => ARGF.argv[0]) # user auth token
|
||||||
|
|
||||||
Dir.glob("*.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z}").uniq.sort.each do |file|
|
Dir.glob("*.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z}").uniq.sort.each do |file|
|
||||||
begin
|
begin
|
||||||
puts "Work with file \"#{file}\""
|
puts " work with file \"#{file}\""
|
||||||
next if File.size(file) < MAX_SIZE
|
next if File.size(file) < MAX_SIZE
|
||||||
|
|
||||||
sha1 = Digest::SHA1.file(file).hexdigest
|
sha1 = Digest::SHA1.file(file).hexdigest
|
||||||
|
|
|
@ -29,25 +29,29 @@ namespace :project do
|
||||||
path = "#{ENV['CLONE_PATH'].chomp('/')}/repos/#{project.name_with_owner}"
|
path = "#{ENV['CLONE_PATH'].chomp('/')}/repos/#{project.name_with_owner}"
|
||||||
FileUtils.rm_rf path
|
FileUtils.rm_rf path
|
||||||
project_path = project.path#"#{ENV['GIT_PROJECTS_DIR']}/#{project.name_with_owner}/.git"
|
project_path = project.path#"#{ENV['GIT_PROJECTS_DIR']}/#{project.name_with_owner}/.git"
|
||||||
system "git clone --mirror #{project_path} #{path}/.git"
|
|
||||||
archives_exists = false
|
archives_exists = false
|
||||||
Dir.chdir(path) do
|
Dir.chdir(project_path) do
|
||||||
system 'git config --bool core.bare false && git checkout -f HEAD' # hack for refs/heads
|
|
||||||
%w(tar.bz2 tar.gz bz2 rar gz tar tbz2 tgz zip Z 7z).each do |ext|
|
%w(tar.bz2 tar.gz bz2 rar gz tar tbz2 tgz zip Z 7z).each do |ext|
|
||||||
archives_exists=true and break if `git log --all --format='%H' -- *.#{ext}`.present?
|
archives_exists=true and break if `git log --all --format='%H' -- *.#{ext}`.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if `cd #{path} && git log --all -- abf.yml`.present? # already have abf.yml in repo?
|
#if `cd #{project_path} && git log --all -- abf.yml`.present? # already have abf.yml in repo?
|
||||||
message="Skipping project with abf.yml file #{project_stats}"
|
# message="Skipping project with abf.yml file #{project_stats}"
|
||||||
say message
|
# say message
|
||||||
abf_existing_log.puts message
|
# abf_existing_log.puts message
|
||||||
`rm -rf #{path}`
|
# `rm -rf #{path}`
|
||||||
elsif archives_exists.present?
|
#elsif archives_exists.present?
|
||||||
|
if archives_exists.present?
|
||||||
|
#-- hack for refs/heads (else git branch return only master)
|
||||||
|
system "git clone --mirror #{project_path} #{path}/.git"
|
||||||
|
system "cd #{path} && git config --bool core.bare false && git checkout -f HEAD"
|
||||||
system "bin/calc_sha #{path} #{token}" # FIXME change filename
|
system "bin/calc_sha #{path} #{token}" # FIXME change filename
|
||||||
|
#--
|
||||||
|
|
||||||
#####
|
#####
|
||||||
# This is dangerous !!!
|
# This is dangerous !!!
|
||||||
system "rm -rf #{project_path} && git clone --bare #{path} #{project_path} && rm -rf #{path}"
|
#system "rm -rf #{project_path} && git clone --bare #{path} #{project_path} && rm -rf #{path}"
|
||||||
|
system "rm -rf #{path}"
|
||||||
#####
|
#####
|
||||||
|
|
||||||
say "Worked with #{project.name_with_owner}: #{(Time.now - time).truncate} sec."
|
say "Worked with #{project.name_with_owner}: #{(Time.now - time).truncate} sec."
|
Loading…
Reference in New Issue