Class: Git::Conform::Repo

Inherits:
Rugged::Repository
  • Object
show all
Defined in:
lib/git/conform/repo.rb

Instance Method Summary collapse

Instance Method Details

#binary_patternsObject



30
31
32
33
34
35
# File 'lib/git/conform/repo.rb', line 30

def binary_patterns
  @binary_patterns ||= begin
                         # TODO: make this work via Rugged (why doesn't `Rugged::Config.new()` work?!?)
                         `git config -f #{git_conform_path} --get-all git.conform.binary`.chomp.split($RS)
                       end
end

#conformity_checkersObject



23
24
25
26
27
28
# File 'lib/git/conform/repo.rb', line 23

def conformity_checkers
  @conformity_checkers ||= begin
                             # TODO: make this work via Rugged (why doesn't `Rugged::Config.new()` work?!?)
                             `git config -f #{git_conform_path} --get-all git.conform.checker`.chomp.split($RS)
                           end
end

#exclusion_patternsObject



37
38
39
40
41
42
# File 'lib/git/conform/repo.rb', line 37

def exclusion_patterns
  @exclusion_patterns ||= begin
                            # TODO: make this work via Rugged (why doesn't `Rugged::Config.new()` work?!?)
                            `git config -f #{git_conform_path} --get-all git.conform.exclusion`.chomp.split($RS)
                          end
end

#files(options = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git/conform/repo.rb', line 50

def files(options = {})
  type = options[:type] || :all
  @files ||= {}
  @files[type] ||= begin
                     files = []
                     repo.lookup(head.target.oid).tree.walk_blobs { |root, entry|
                       entry_path = (root.empty? ? entry[:name] : File.join(root, entry[:name]))
                       files << entry_path if binary?(entry) ? (type != :text) : (type != :binary)
                     }
                     files
                   end
end

#git_conform_enabled?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/git/conform/repo.rb', line 19

def git_conform_enabled?
  File.exist? git_conform_path
end

#git_conform_pathObject



14
15
16
17
# File 'lib/git/conform/repo.rb', line 14

def git_conform_path
  repo_path = File.join(workdir, '.gitconform')
  File.exist?(repo_path) ? repo_path : Git::Conform::DEFAULT_PATH
end

#repoObject



7
8
9
10
11
12
# File 'lib/git/conform/repo.rb', line 7

def repo
  # a bug/feature in Rugged prevents us from using instances of a subclass of Rugged::Repository
  # in certain methods/places; instead it insists on an instance of Rugged::Repository itself...
  # (meaning we can't use `self` on those occasions!) where is Barbara Liskov when you need her?
  @repo ||= Rugged::Repository.new(path)
end

#verifyObject



44
45
46
47
48
# File 'lib/git/conform/repo.rb', line 44

def verify
  conformity_checkers.each do |checker|
    constantize "Git::Conform::#{checker}"
  end
end