mirror of
https://github.com/gosticks/brew.git
synced 2026-08-12 04:30:21 +00:00
Add audit check to see if both version and checksum changed.
This commit is contained in:
@@ -1,3 +1,31 @@
|
||||
require "open3"
|
||||
|
||||
module Git
|
||||
module_function
|
||||
|
||||
def last_revision_commit_of_file(repo, file, before_commit: nil)
|
||||
args = [before_commit.nil? ? "--skip=1" : before_commit.split("..").first]
|
||||
|
||||
out, = Open3.capture3(
|
||||
HOMEBREW_SHIMS_PATH/"scm/git", "-C", repo,
|
||||
"log", "--oneline", "--max-count=1", *args, "--", file
|
||||
)
|
||||
out.split(" ").first
|
||||
end
|
||||
|
||||
def last_revision_of_file(repo, file, before_commit: nil)
|
||||
relative_file = Pathname(file).relative_path_from(repo)
|
||||
|
||||
commit_hash = last_revision_commit_of_file(repo, file, before_commit: before_commit)
|
||||
|
||||
out, = Open3.capture3(
|
||||
HOMEBREW_SHIMS_PATH/"scm/git", "-C", repo,
|
||||
"show", "#{commit_hash}:#{relative_file}"
|
||||
)
|
||||
out
|
||||
end
|
||||
end
|
||||
|
||||
module Utils
|
||||
def self.git_available?
|
||||
return @git if instance_variable_defined?(:@git)
|
||||
|
||||
Reference in New Issue
Block a user