Skip to content

Commit

Permalink
Update python to work with requirements of form file:.
Browse files Browse the repository at this point in the history
Currently if a requirement file contains a path dependency where the
path starts with `file:`, the file fetcher will try and find a file
called `/file:./setup.py`, which fails because it should be looking for
`setup.py`.

This commit updates Dependabot::Python::FileFetcher to ignore the
`file:` part if it is present.
  • Loading branch information
lfdebrux committed Sep 10, 2020
1 parent 8e79d25 commit aaacc97
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/lib/dependabot/python/file_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,14 @@ def requirement_in_path_setup_file_paths
def parse_path_setup_paths(req_file)
uneditable_reqs =
req_file.content.
scan(/^['"]?(?<path>\..*?)(?=\[|#|'|"|$)/).
scan(/^['"]?(?:file:)?(?<path>\..*?)(?=\[|#|'|"|$)/).
flatten.
map(&:strip).
reject { |p| p.include?("://") }

editable_reqs =
req_file.content.
scan(/^(?:-e)\s+['"]?(?<path>.*?)(?=\[|#|'|"|$)/).
scan(/^(?:-e)\s+['"]?(?:file:)?(?<path>.*?)(?=\[|#|'|"|$)/).
flatten.
map(&:strip).
reject { |p| p.include?("://") || p.include?("git@") }
Expand Down
3 changes: 3 additions & 0 deletions python/spec/dependabot/python/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,9 @@
body: fixture("github", "setup_content.json"),
headers: { "content-type" => "application/json" }
)
stub_request(:get, url + "file:./setup.py?ref=sha").
with(headers: { "Authorization" => "token token" }).
to_return(status: 404)
end

it "fetches the path dependencies" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"git_url": "https://api.github.com/repos/gocardless/bump/git/blobs/8d9a77a86256c11409622fd16d799d9718f1ff62",
"download_url": "https://raw.githubusercontent.com/gocardless/bump/master/requirements.txt?token=ABMwe8vXxd4DBCEsxz3jMusk5sr_fFsoks5WJWE-wA%3D%3D",
"type": "file",
"content": "LWUgLgotZSAiLi9teSIKLWUgJy4vbXktc2luZ2xlJwoKLi9teS1vdGhlcgou\nL3NvbWUvemlwLWZpbGUudGFyLmd6Cg==\n",
"content": "LWUgLgotZSAiLi9teSIKLWUgJy4vbXktc2luZ2xlJwoKLi9teS1vdGhlcgouL3NvbWUvemlwLWZpbGUudGFyLmd6CgpmaWxlOi4KLWUgZmlsZTouCg==\n",
"encoding": "base64",
"_links": {
"self": "https://api.github.com/repos/gocardless/bump/contents/requirements.txt?ref=master",
Expand Down

0 comments on commit aaacc97

Please sign in to comment.