Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
remove files from standard_todo.yml as they are committed
#!/usr/bin/env ruby
require 'pathname'
require "tempfile"
require "fileutils"
base = ENV.fetch("STANDARD_UPDATE_BASE") { "$HEAD" }
files = `git diff #{base} --name-only --staged`.split("\n")
app_root = Pathname.new File.expand_path('../../', __FILE__)
todo_path = File.join(app_root, ".standard_todo.yml")
Tempfile.create do |tempfile|
File.foreach(todo_path) do |line|
trimmed = line.gsub(/^\s+- /, "").chomp
if files.include?(trimmed)
puts line
else
tempfile << line
end
end
tempfile.flush
FileUtils.cp(tempfile.path, todo_path)
end
`git add .standard_todo.yml`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment