Skip to content

Instantly share code, notes, and snippets.

@allynbauer
Created July 11, 2011 05:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allynbauer/1075357 to your computer and use it in GitHub Desktop.
Save allynbauer/1075357 to your computer and use it in GitHub Desktop.
a ruby script that uses applescript to build a git commit from taskpaper based on @done items
rvm use 1.8.7
ruby taskpaper_git_commit.rb ~/Desktop/TODO.taskpaper
#!/usr/bin/env ruby
# MUST BE RUBY 1.8.7
require 'rubygems'
require 'appscript' # sudo gem install rb-appscript
include Appscript
TaskPaper = app('TaskPaper')
if !TaskPaper.is_running? && ARGV.length > 0
TaskPaper.launch
TaskPaper.open(ARGV[0])
elsif TaskPaper.is_running?
TaskPaper.document.save
else
puts "TaskPaper is not running and no file to open provided; aborting"
exit
end
entries = TaskPaper.document.entries.get.flatten
done_entries = entries.select { |entry| entry.tags.get.any? { |tag| tag.name.get == "done" } }
if done_entries.empty?
puts "TaskPaper has no done tagged entries; aborting"
exit
end
git_message = done_entries.collect { |entry| "FIXED: #{entry.name.get}" }.join("\n")
puts "committing with message:\n#{git_message}\n"
system("git add .")
system("git commit -m \"#{git_message}\"")
done_entries.each { |entry| entry.delete }
TaskPaper.document.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment