Skip to content

Instantly share code, notes, and snippets.

@aapis
Created April 15, 2016 20:06
Show Gist options
  • Select an option

  • Save aapis/40858949b99ecad0a4898b5fd8f84a51 to your computer and use it in GitHub Desktop.

Select an option

Save aapis/40858949b99ecad0a4898b5fd8f84a51 to your computer and use it in GitHub Desktop.
Check if there are any uncommitted changes in your working directories at the end of the day (or, whenever)
#! /usr/bin/ruby
require 'notifaction'
require 'pathname'
def update(path)
Dir.chdir(path)
print_successes = false
resp = `git status -s`.size
if resp === 0
if print_successes
Notify.success path
end
else
Notify.warning path
end
end
def rec_path(path)
path.children.collect do |child|
if child.directory?
if Dir.exist?("#{child}/.git")
update(child.to_s)
else
rec_path(child) + [child]
end
end
end.select { |x| x }.flatten(1)
end
Notify.sinfo("Checking working directories for uncommitted changes\nDirectories printed below have uncommitted changes and require updating")
dir = '/path/to/your/working/directory'
rec_path(Pathname.new(dir))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment