Skip to content

Commit

Permalink
Git class updates
Browse files Browse the repository at this point in the history
  • Loading branch information
GarryHurleyJr committed May 29, 2024
1 parent aa9e64e commit e610181
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions common/lib/dependabot/workspace/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Git < Base

USER = "dependabot[bot]"
EMAIL = T.let("#{USER}@users.noreply.github.com".freeze, String)
lfsEnabled = nil

sig { returns(String) }
attr_reader :initial_head_sha
Expand All @@ -22,6 +23,7 @@ def initialize(path)
super(path)
@initial_head_sha = T.let(head_sha, String)
configure_git
run_shell_command("git lfs install") if isLfsEnabled(path.to_s)
end

sig { returns(T::Boolean) }
Expand Down Expand Up @@ -168,6 +170,16 @@ def run_shell_command(*args, **kwargs)
def debug(message)
Dependabot.logger.debug("[workspace] #{message}")
end

sig { params(path: String).returns(T::Boolean) }
def isLfsEnabled(path)
filepath = File.join(path,".gitattributes")
lfsEnabled = FIle.exist?(filepath) && File.readable?(filepath) && SharedHelpers.run_shell_command("cat #{filepath} | grep \"filter=lfs\"") if lfsEnabled.nil?
rescue
# this should not be needed, but I don't trust 'should'
lfsEnabled = false
end

end
end
end

0 comments on commit e610181

Please sign in to comment.