Module: Guard::Notifier::GitAutoCommit
- Extended by:
- GitAutoCommit
- Included in:
- GitAutoCommit
- Defined in:
- lib/version.rb,
lib/guard/notifiers/git_auto_commit.rb
Constant Summary collapse
- VERSION =
"0.1.2"
Instance Method Summary collapse
-
#available?(silent = false) ⇒ Boolean
Test if the current directory is managed using git.
-
#notify(type, title, message, image, options = { }) ⇒ Object
Show a system notification.
Instance Method Details
#available?(silent = false) ⇒ Boolean
Test if the current directory is managed using git.
14 15 16 |
# File 'lib/guard/notifiers/git_auto_commit.rb', line 14 def available?(silent = false) system("git status > /dev/null 2> /dev/null") end |
#notify(type, title, message, image, options = { }) ⇒ Object
Show a system notification.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/guard/notifiers/git_auto_commit.rb', line 28 def notify(type, title, , image, = { }) = [type, title, ].join(' ').gsub(/\r|\n/, '') << "\n\n" system("git add -u") << `git diff --cached` File.popen("git commit -F -", "r+") do |fd| fd.write fd.close end # notify untracked files untracked_files = `git ls-files --exclude-standard --others`.split("\n") unless untracked_files.select { |path| ! File.basename(path).match(/^\.|~$/) }.empty? warn "\e[35mYou have untracked file\e[0m" end end |