Skip to content

Commit

Permalink
Ruby better.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavera committed Nov 30, 2022
1 parent 5e2488e commit 6707673
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions common/lib/dependabot/dependency_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module Dependabot
class DependencyFile
attr_accessor :name, :content, :directory, :type, :support_file,
:symlink_target, :content_encoding, :operation
:symlink_target, :content_encoding, :operation, :mode

class ContentEncoding
UTF_8 = "utf-8"
Expand Down Expand Up @@ -40,17 +40,19 @@ def initialize(name:, content:, directory: "/", type: "file",
# support_file flag instead)
@type = type

return unless (type == "symlink") ^ symlink_target

raise "Symlinks must specify a target!" unless symlink_target
raise "Only symlinked files must specify a target!" if symlink_target

begin
mode = File.stat((symlink_target || path).sub(%r{^/}, "")).mode.to_s(8)
rescue
mode = nil
end
@mode = mode

return unless (type == "symlink") ^ symlink_target

raise "Symlinks must specify a target!" unless symlink_target
raise "Only symlinked files must specify a target!" if symlink_target


end

def to_h
Expand Down

0 comments on commit 6707673

Please sign in to comment.