Class: Git::Set::Mtime::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/git/set/mtime.rb

Instance Method Summary collapse

Instance Method Details

#applyObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/git/set/mtime.rb', line 8

def apply
  files = `git ls-files`
  files.each_line do |file|
    file = file.strip
    mtime_str = `git log -n 1 --date=local | head -n 3 | tail -n 1`.tr('Date:', '').strip
    mtime = Time.parse(mtime_str)
    File.utime(File.atime(file), mtime, file)
    puts "#{mtime} #{file}"
  end
end