Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'pathname'
- TYPE = 'code'
- TZCODEDIR = "C:/Downloads/tz#{TYPE}"
- S7Z = "\"C:/Program Files (x86)/7-Zip/7z.exe\""
- OUT = "D:/dev/tz#{TYPE}git"
- INIT = false
- def push_changes(f)
- gz = Pathname(f)
- dir = gz.dirname
- tar = gz.name
- name = tar.name
- system "#{S7Z} x #{gz} -y"
- list = `#{S7Z} l #{tar} -y`
- puts name
- t = list.scan(/^(\d\d\d\d)-(\d\d)-(\d\d)\s(\d\d):(\d\d):(\d\d)\s/).map{|y,mon,d,h,min,c|
- Time.local(y.to_i, mon.to_i, d.to_i, h.to_i, min.to_i, c.to_i).utc
- }.sort.last
- p t
- Dir['*'].select{|del| del !~ /\.git$/ && del !~ /#{tar}$/ }.each(&File.method(:delete))
- system "#{S7Z} x #{tar} -y"
- File.delete(tar)
- system "git add ."
- ENV['GIT_AUTHOR_DATE'] = t.to_s
- system "git commit -a --author \"tz <tz@elsie.nci.nih.gov>\" -m #{name}"
- system "git tag #{name}"
- system "git push"
- system "git push --tags"
- end
- def sorted_archives
- Dir[File.join(TZCODEDIR, "tz*#{TYPE}*.{gz,Z}")].sort_by{|a|
- v = a[/\d+[a-z]?(?=\.)/]
- n = v.to_i
- n += 1900 if n < 100
- "#{n}-#{v[/[a-z]/]}#{a =~ /tz(\d\d)/ ? "-#{$1}" : ""}"
- }
- end
- Pathname.class_eval {
- def name
- self.basename.sub(/#{self.extname}$/, '')
- end
- }
- Dir.chdir OUT
- if INIT
- system "git init"
- system "git config core.autocrlf input"
- sorted_archives.each{|f| push_changes(f) }
- else
- push_changes(sorted_archives.last)
- end
Add Comment
Please, Sign In to add comment