Last active
February 20, 2025 10:12
Revisions
-
ttscoff revised this gist
Jun 13, 2013 . 1 changed file with 65 additions and 48 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,80 +1,97 @@ #!/usr/bin/env ruby require 'time' require 'erb' require 'cgi' filename = "~/.gitlogger" ## File format, One per line # Repo Name:/path/to/base dayone = false # log to day one? (true or false) textlog = false # "~/Dropbox/nvALT2.2/GitLogger.md" # set to false to disable git_user = %x{git config --get user.name}.strip git_user = ENV['GIT_AUTHOR_NAME'] if git_user == '' git_user = '.' if git_user == '' entrytext = "" File.open(File.expand_path(filename), 'r') do |infile| while (line = infile.gets) name, path = line.strip.split(':') Dir.chdir(path) repo_log = '' repo_log = %x{git log --first-parent --no-merges --author="#{git_user}" --pretty=format:"%%NEWLINE**[#{name}]** %%%ct%%: %s (%h)%n %+b%n" --since="yesterday"}.gsub(/%(\d+)%/) { |timestamp| timestamp.gsub!(/%/,'') Time.at(timestamp.to_i).strftime("%H:%M").gsub(/^0/,'') } # if no remote repository is specified, `git fetch` will output # error messages; so we silence them repo_log = %x{git fetch 2>/dev/null && git log --remotes --first-parent --no-merges --author="#{git_user}" --pretty=format:"* **[#{name}]** %%%ct%%: %s (%h)%n %+b%n" --since="yesterday"}.gsub(/%(\d+)%/) { |timestamp| timestamp.gsub!(/%/,'') Time.at(timestamp.to_i).strftime("%H:%M").gsub(/^0/,'') } if repo_log == '' entrytext += repo_log end end exit if entrytext.strip == "" # remove the weird empty lines at the beginning entrytext = entrytext.gsub(/^\s{4}\n/,"").gsub(/\n{3,}/m,"\n\n") entries = entrytext.split('%NEWLINE') output = [] # the first line is always empty gibberish and will be omitted entries[1..-1].each do |entry| entry.gsub!(/^(.+)$/, ' \1') entry[0] = "*" output << entry end entrytext = output.join entrytext << "\n" if dayone uuid = %x{uuidgen}.gsub(/-/,'').strip datestamp = Time.now.utc.iso8601 starred = false dayonedir = %x{ls ~/Library/Mobile\\ Documents/|grep dayoneapp}.strip dayonepath = "~/Dropbox/Apps/Day\ One/Journal.dayone/entries/" #"~/Library/Mobile\ Documents/#{dayonedir}/Documents/Journal_dayone/entries/" entry = CGI.escapeHTML("Git Log #{Time.now.strftime("%Y-%m-%d")}:\n\n#{entrytext}") template = ERB.new <<-XMLTEMPLATE <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Creation Date</key> <date><%= datestamp %></date> <key>Entry Text</key> <string><%= entry %></string> <key>Starred</key> <<%= starred %>/> <key>UUID</key> <string><%= uuid %></string> </dict> </plist> XMLTEMPLATE fh = File.new(File.expand_path(dayonepath+uuid+".doentry"),'w+') fh.puts template.result(binding) fh.close # puts "ENTRY ADDED" # puts "------------------------" # puts "Time: " + datestamp # puts "UUID: " + uuid # puts "Starred: " + starred.to_s # puts "Entry: " + entrytext end if textlog entry = "---\n\n### #{Time.now.strftime("%D")}:\n\n#{entrytext}" open(File.expand_path(textlog), 'a') { |f| f.puts entry } end -
ttscoff revised this gist
Aug 3, 2012 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,14 +9,17 @@ dayone = true # log to day one? (true or false) textlog = "~/Dropbox/nvALT2.2/GitLogger.md" # set to false to disable git_user = %x{git config --get user.name}.strip git_user = ENV['GIT_AUTHOR_NAME'] if git_user == '' git_user = '.' if git_user == '' entrytext = "" File.open(File.expand_path(filename),'r') do |infile| while (line = infile.gets) name,path = line.strip.split(':') Dir.chdir(path) repo_log = '' repo_log = %x{git log --first-parent --no-merges --author="#{git_user}" --pretty=format:"* **[#{name}]** %%%ct%%: %s (%h)%n %+b%n" --since="yesterday"}.gsub(/%(\d+)%/) { |timestamp| timestamp.gsub!(/%/,'') -
ttscoff revised this gist
Aug 3, 2012 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,15 +14,24 @@ while (line = infile.gets) name,path = line.strip.split(':') Dir.chdir(path) git_user = %x{git config --get user.name}.strip git_user = ENV['GIT_AUTHOR_NAME'] if git_user == '' git_user = '.' if git_user == '' repo_log = '' repo_log = %x{git log --first-parent --no-merges --author="#{git_user}" --pretty=format:"* **[#{name}]** %%%ct%%: %s (%h)%n %+b%n" --since="yesterday"}.gsub(/%(\d+)%/) { |timestamp| timestamp.gsub!(/%/,'') Time.at(timestamp.to_i).strftime("%I:%M %p").gsub(/^0/,'') } repo_log = %x{git fetch && git log --remotes --first-parent --no-merges --author="#{git_user}" --pretty=format:"* **[#{name}]** %%%ct%%: %s (%h)%n %+b%n" --since="yesterday"}.gsub(/%(\d+)%/) { |timestamp| timestamp.gsub!(/%/,'') Time.at(timestamp.to_i).strftime("%I:%M %p").gsub(/^0/,'') } if repo_log == '' entrytext += repo_log end end exit if entrytext.strip == "" entrytext += "\n" if dayone -
ttscoff revised this gist
Aug 1, 2012 . 1 changed file with 17 additions and 16 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ #!/usr/bin/ruby require 'time' require 'erb' require 'cgi' filename = "~/.gitlogger" ## File format, One per line @@ -31,23 +32,23 @@ dayonedir = %x{ls ~/Library/Mobile\\ Documents/|grep dayoneapp}.strip dayonepath = "~/Library/Mobile\ Documents/#{dayonedir}/Documents/Journal_dayone/entries/" entry = CGI.escapeHTML("## Git Log #{Time.now.strftime("%D")}:\n\n#{entrytext.gsub(/^\s{4}\n/,"").gsub(/\n{3,}/m,"\n\n")}") template = ERB.new <<-XMLTEMPLATE <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Creation Date</key> <date><%= datestamp %></date> <key>Entry Text</key> <string><%= entry %></string> <key>Starred</key> <<%= starred %>/> <key>UUID</key> <string><%= uuid %></string> </dict> </plist> XMLTEMPLATE fh = File.new(File.expand_path(dayonepath+uuid+".doentry"),'w+') fh.puts template.result(binding) -
ttscoff revised this gist
May 22, 2012 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,10 @@ while (line = infile.gets) name,path = line.strip.split(':') Dir.chdir(path) git_user = %x{git config --get user.name} git_user = ENV['GIT_AUTHOR_NAME'] if git_user == '' git_user = '.' if git_user == '' entrytext += %x{git fetch && git log --remotes --first-parent --no-merges --author="#{git_user}" --pretty=format:"* **[#{name}]** %%%ct%%: %s (%h)%n%n %b%n" --since="yesterday"}.gsub(/%(\d+)%/) { |timestamp| timestamp.gsub!(/%/,'') Time.at(timestamp.to_i).strftime("%I:%M %p").gsub(/^0/,'') } @@ -57,8 +60,8 @@ # puts "Entry: " + entrytext end if textlog entry = "---\n\n### #{Time.now.strftime("%D")}:\n\n#{entrytext.gsub(/^\s{4}\n/,"").gsub(/\n{3,}/m,"\n\n")}" open(File.expand_path(textlog), 'a') { |f| f.puts entry } end -
ttscoff created this gist
May 8, 2012 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ #!/usr/bin/ruby require 'time' require 'erb' filename = "~/.gitlogger" ## File format, One per line # Repo Name:/path/to/base dayone = true # log to day one? (true or false) textlog = "~/Dropbox/nvALT2.2/GitLogger.md" # set to false to disable entrytext = "" File.open(File.expand_path(filename),'r') do |infile| while (line = infile.gets) name,path = line.strip.split(':') Dir.chdir(path) entrytext += %x{git log --pretty=format:"* **[#{name}]** %%%ct%%: %s (%h)%n%n %b%n" --since="yesterday"}.gsub(/%(\d+)%/) { |timestamp| timestamp.gsub!(/%/,'') Time.at(timestamp.to_i).strftime("%I:%M %p").gsub(/^0/,'') } end end entrytext += "\n" if dayone uuid = %x{uuidgen}.gsub(/-/,'').strip datestamp = Time.now.utc.iso8601 starred = false dayonedir = %x{ls ~/Library/Mobile\\ Documents/|grep dayoneapp}.strip dayonepath = "~/Library/Mobile\ Documents/#{dayonedir}/Documents/Journal_dayone/entries/" entry = "## Git Log #{Time.now.strftime("%D")}:\n\n#{entrytext.gsub(/^\s{4}\n/,"").gsub(/\n{3,}/m,"\n\n")}" template = ERB.new <<-XMLTEMPLATE <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Creation Date</key> <date><%= datestamp %></date> <key>Entry Text</key> <string><%= entry %></string> <key>Starred</key> <<%= starred %>/> <key>UUID</key> <string><%= uuid %></string> </dict> </plist> XMLTEMPLATE fh = File.new(File.expand_path(dayonepath+uuid+".doentry"),'w+') fh.puts template.result(binding) fh.close # puts "ENTRY ADDED" # puts "------------------------" # puts "Time: " + datestamp # puts "UUID: " + uuid # puts "Starred: " + starred.to_s # puts "Entry: " + entrytext end if textlog entry = "### #{Time.now.strftime("%D")}:\n\n#{entrytext.gsub(/^\s{4}\n/,"").gsub(/\n{3,}/m,"\n\n")}" open(File.expand_path(textlog), 'a') { |f| f.puts entry } end