mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-07 22:54:11 -05:00
Move running of git-restore-mtime to lib/fixup.rb and Simplify usage of @last_update_check (#12681)
* Move running of git-restore-mtime to lib/fixup.rb * Simplify usage of @last_update_check
This commit is contained in:
committed by
GitHub
parent
ea499756a2
commit
83587e5f3d
19
bin/crew
19
bin/crew
@@ -247,17 +247,10 @@ def update
|
||||
to_update = `cd #{CREW_LIB_PATH} && git show --name-only HEAD..FETCH_HEAD`.include?('lib/const.rb')
|
||||
system('git reset --hard FETCH_HEAD', chdir: CREW_LIB_PATH, exception: true)
|
||||
|
||||
system(<<~GIT_RESTORE_MTIME_COMMAND, chdir: CREW_LIB_PATH, exception: true) if File.file?("#{CREW_PREFIX}/bin/git-restore-mtime")
|
||||
# Set the mtime on each file in git to the date the file was added,
|
||||
# not to the date of the last git pull.
|
||||
git-restore-mtime -sq 2>/dev/null
|
||||
GIT_RESTORE_MTIME_COMMAND
|
||||
puts 'Updating RubyGems.'.orange
|
||||
system 'gem update -N --system'
|
||||
system 'gem cleanup'
|
||||
|
||||
if Time.now.to_i - @last_update_check > (CREW_UPDATE_CHECK_INTERVAL * 3600 * 24)
|
||||
puts 'Updating RubyGems.'.orange
|
||||
system 'gem update -N --system'
|
||||
system 'gem cleanup'
|
||||
end
|
||||
puts 'Package lists, crew, and library updated.'
|
||||
|
||||
# If lib/const.rb was changed, CREW_VERSION was bumped, so we re-run crew update.
|
||||
@@ -2054,9 +2047,9 @@ end
|
||||
|
||||
@device = ConvenienceFunctions.load_symbolized_json
|
||||
|
||||
@last_update_check = Dir["#{CREW_LIB_PATH}/{.git/FETCH_HEAD,lib/const.rb}"].compact.map { |i| File.mtime(i).utc.to_i }.max
|
||||
crewlog("The last update was #{MiscFunctions.time_difference(@last_update_check, Time.now.to_i)} ago.")
|
||||
if ARGV[0] != 'update' && Time.now.to_i - @last_update_check > ((CREW_UPDATE_CHECK_INTERVAL * 3600 * 24))
|
||||
last_update_check = Dir["#{CREW_LIB_PATH}/{.git/FETCH_HEAD,lib/const.rb}"].compact.map { |i| File.mtime(i).utc.to_i }.max
|
||||
crewlog("The last update was #{MiscFunctions.time_difference(last_update_check, Time.now.to_i)} ago.")
|
||||
if ARGV[0] != 'update' && Time.now.to_i - last_update_check > ((CREW_UPDATE_CHECK_INTERVAL * 3600 * 24))
|
||||
plural = CREW_UPDATE_CHECK_INTERVAL < 2 ? '' : 's'
|
||||
puts "It has been more than #{CREW_UPDATE_CHECK_INTERVAL} day#{plural} since crew was last updated. Please run 'crew update'.".lightpurple
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user