daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Mar 14th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. require 'pathname'
  3.  
  4. TYPE = 'code'
  5. TZCODEDIR = "C:/Downloads/tz#{TYPE}"
  6. S7Z = "\"C:/Program Files (x86)/7-Zip/7z.exe\""
  7. OUT = "D:/dev/tz#{TYPE}git"
  8. INIT = false
  9.  
  10. def push_changes(f)
  11.   gz = Pathname(f)
  12.   dir = gz.dirname
  13.   tar = gz.name
  14.   name = tar.name  
  15.  
  16.   system "#{S7Z} x #{gz} -y"
  17.   list = `#{S7Z} l #{tar} -y`
  18.   puts name
  19.   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|
  20.     Time.local(y.to_i, mon.to_i, d.to_i, h.to_i, min.to_i, c.to_i).utc
  21.   }.sort.last
  22.   p t
  23.   Dir['*'].select{|del| del !~ /\.git$/ && del !~ /#{tar}$/ }.each(&File.method(:delete))    
  24.   system "#{S7Z} x #{tar} -y"
  25.   File.delete(tar)
  26.  
  27.   system "git add ."  
  28.   ENV['GIT_AUTHOR_DATE'] = t.to_s
  29.   system "git commit -a --author \"tz <tz@elsie.nci.nih.gov>\"  -m #{name}"
  30.   system "git tag #{name}"
  31.   system "git push"
  32.   system "git push --tags"
  33. end
  34.  
  35. def sorted_archives
  36.   Dir[File.join(TZCODEDIR, "tz*#{TYPE}*.{gz,Z}")].sort_by{|a|
  37.     v = a[/\d+[a-z]?(?=\.)/]
  38.     n = v.to_i
  39.     n += 1900 if n < 100
  40.     "#{n}-#{v[/[a-z]/]}#{a =~ /tz(\d\d)/ ? "-#{$1}" : ""}"
  41.   }
  42. end
  43.  
  44. Pathname.class_eval {
  45.   def name
  46.     self.basename.sub(/#{self.extname}$/, '')
  47.   end
  48. }
  49.  
  50. Dir.chdir OUT
  51.  
  52. if INIT
  53.   system "git init"
  54.   system "git config core.autocrlf input"
  55.  
  56.   sorted_archives.each{|f| push_changes(f) }
  57. else
  58.   push_changes(sorted_archives.last)
  59. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top