Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Poetry 1.5 lockfiles #7834

Merged
merged 4 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require "dependabot/python/file_parser/python_requirement_parser"
require "dependabot/python/file_parser/subdependency_type_parser"
require "dependabot/python/file_updater"
require "dependabot/python/helpers"
require "dependabot/python/native_helpers"
require "dependabot/python/name_normaliser"

Expand Down Expand Up @@ -197,24 +198,7 @@ def run_poetry_update_command
end

def run_poetry_command(command, fingerprint: nil)
start = Time.now
command = SharedHelpers.escape_command(command)
stdout, process = Open3.capture2e(command)
time_taken = Time.now - start

# Raise an error with the output from the shell session if Pipenv
# returns a non-zero status
return if process.success?

raise SharedHelpers::HelperSubprocessFailed.new(
message: stdout,
error_context: {
command: command,
fingerprint: fingerprint,
time_taken: time_taken,
process_exit_value: process.to_s
}
)
Helpers.run_poetry_command(command, fingerprint: fingerprint)
end

def write_temporary_dependency_files(pyproject_content)
Expand Down
34 changes: 34 additions & 0 deletions python/lib/dependabot/python/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require "time"
require "open3"

require "dependabot/errors"
require "dependabot/shared_helpers"

module Dependabot
module Python
module Helpers
def self.run_poetry_command(command, fingerprint: nil)
start = Time.now
command = SharedHelpers.escape_command(command)
stdout, process = Open3.capture2e(command)
time_taken = Time.now - start

# Raise an error with the output from the shell session if Pipenv
jeffwidman marked this conversation as resolved.
Show resolved Hide resolved
# returns a non-zero status
return if process.success?

raise SharedHelpers::HelperSubprocessFailed.new(
message: stdout,
error_context: {
command: command,
fingerprint: fingerprint,
time_taken: time_taken,
process_exit_value: process.to_s
}
)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require "dependabot/python/update_checker"
require "dependabot/python/version"
require "dependabot/python/requirement"
require "dependabot/python/helpers"
require "dependabot/python/native_helpers"
require "dependabot/python/authed_url_builder"
require "dependabot/python/name_normaliser"
Expand Down Expand Up @@ -315,24 +316,7 @@ def lockfile
end

def run_poetry_command(command, fingerprint: nil)
start = Time.now
command = SharedHelpers.escape_command(command)
stdout, process = Open3.capture2e(command)
time_taken = Time.now - start

# Raise an error with the output from the shell session if poetry
# returns a non-zero status
return if process.success?

raise SharedHelpers::HelperSubprocessFailed.new(
message: stdout,
error_context: {
command: command,
fingerprint: fingerprint,
time_taken: time_taken,
process_exit_value: process.to_s
}
)
Helpers.run_poetry_command(command, fingerprint: fingerprint)
end

def normalise(name)
Expand Down