Class: Insup::Git
- Inherits:
-
Object
- Object
- Insup::Git
- Defined in:
- lib/insup/git.rb
Instance Method Summary collapse
-
#initialize(base) ⇒ Git
constructor
A new instance of Git.
- #status ⇒ Object
Constructor Details
#initialize(base) ⇒ Git
Returns a new instance of Git.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/insup/git.rb', line 3 def initialize(base) Dir.chdir(base) do `git status 2>&1` if $?.exitstatus == 128 raise Insup::Exceptions::NotAGitRepositoryError, 'Not a GIT repository' end end @base = base end |
Instance Method Details
#status ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/insup/git.rb', line 15 def status files = ls_files ignore = ignored_files Dir.chdir(@base) do Dir.glob('**/*', File::FNM_DOTMATCH) do |file| next if files[file] || File.directory?(file) || ignore.include?(file) || file =~ /^.git\/.+/ files[file] = {:path => file, :untracked => true} end end diff_files.each do |path, data| files[path] ? files[path].merge!(data) : files[path] = data end diff_index('HEAD').each do |path, data| files[path] ? files[path].merge!(data) : files[path] = data end files.each do |k, file_hash| file_hash end files end |