Class: Dependabot::FileFetchers::Base
- Inherits:
-
Object
- Object
- Dependabot::FileFetchers::Base
- Defined in:
- lib/dependabot/file_fetchers/base.rb
Constant Summary collapse
- CLIENT_NOT_FOUND_ERRORS =
[ Octokit::NotFound, Gitlab::Error::NotFound, Dependabot::Clients::Azure::NotFound, Dependabot::Clients::Bitbucket::NotFound, Dependabot::Clients::CodeCommit::NotFound ].freeze
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
- #commit ⇒ Object
- #directory ⇒ Object
- #files ⇒ Object
-
#initialize(source:, credentials:) ⇒ Base
constructor
A new instance of Base.
- #repo ⇒ Object
- #target_branch ⇒ Object
Constructor Details
#initialize(source:, credentials:) ⇒ Base
Returns a new instance of Base.
35 36 37 38 39 40 |
# File 'lib/dependabot/file_fetchers/base.rb', line 35 def initialize(source:, credentials:) @source = source @credentials = credentials @linked_paths = {} end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
17 18 19 |
# File 'lib/dependabot/file_fetchers/base.rb', line 17 def credentials @credentials end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
17 18 19 |
# File 'lib/dependabot/file_fetchers/base.rb', line 17 def source @source end |
Class Method Details
.required_files_in?(_filename_array) ⇒ Boolean
27 28 29 |
# File 'lib/dependabot/file_fetchers/base.rb', line 27 def self.required_files_in?(_filename_array) raise NotImplementedError end |
.required_files_message ⇒ Object
31 32 33 |
# File 'lib/dependabot/file_fetchers/base.rb', line 31 def self. raise NotImplementedError end |
Instance Method Details
#commit ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/dependabot/file_fetchers/base.rb', line 58 def commit return source.commit if source.commit branch = target_branch || default_branch_for_repo @commit ||= client_for_provider.fetch_commit(repo, branch) rescue *CLIENT_NOT_FOUND_ERRORS raise Dependabot::BranchNotFound, branch rescue Octokit::Conflict => e raise unless e..include?("Repository is empty") end |
#directory ⇒ Object
46 47 48 |
# File 'lib/dependabot/file_fetchers/base.rb', line 46 def directory Pathname.new(source.directory || "/").cleanpath.to_path end |
#files ⇒ Object
54 55 56 |
# File 'lib/dependabot/file_fetchers/base.rb', line 54 def files @files ||= fetch_files end |
#repo ⇒ Object
42 43 44 |
# File 'lib/dependabot/file_fetchers/base.rb', line 42 def repo source.repo end |
#target_branch ⇒ Object
50 51 52 |
# File 'lib/dependabot/file_fetchers/base.rb', line 50 def target_branch source.branch end |