Method: CongressForms::Repo#find

Defined in:
lib/congress_forms/repo.rb

#find(file) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/congress_forms/repo.rb', line 64

def find(file)
  lock do
    clone unless initialized?

    update if auto_update? && age > 5*60 # update every 5m

    repo_file = system(
      "git",
      "-C", location.to_s,
      "ls-files", "--error-unmatch",
      "--", file
    )

    raise Errno::ENOENT, file unless repo_file

    path = location.join(file).to_s

    [File.read(path), File.mtime(path)]
  end
end