Class: Datadog::CI::Git::SearchCommits
- Inherits:
-
Object
- Object
- Datadog::CI::Git::SearchCommits
- Defined in:
- lib/datadog/ci/git/search_commits.rb
Defined Under Namespace
Classes: ApiError
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
- #call(repository_url, commits) ⇒ Object
-
#initialize(api:) ⇒ SearchCommits
constructor
A new instance of SearchCommits.
Constructor Details
#initialize(api:) ⇒ SearchCommits
Returns a new instance of SearchCommits.
20 21 22 |
# File 'lib/datadog/ci/git/search_commits.rb', line 20 def initialize(api:) @api = api end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
18 19 20 |
# File 'lib/datadog/ci/git/search_commits.rb', line 18 def api @api end |
Instance Method Details
#call(repository_url, commits) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/datadog/ci/git/search_commits.rb', line 24 def call(repository_url, commits) raise ApiError, "test visibility API is not configured" if api.nil? http_response = api.api_request( path: Ext::Transport::DD_API_GIT_SEARCH_COMMITS_PATH, payload: request_payload(repository_url, commits) ) Transport::Telemetry.api_requests( Ext::Telemetry::METRIC_GIT_REQUESTS_SEARCH_COMMITS, 1, compressed: http_response.request_compressed ) Utils::Telemetry.distribution(Ext::Telemetry::METRIC_GIT_REQUESTS_SEARCH_COMMITS_MS, http_response.duration_ms) unless http_response.ok? Transport::Telemetry.api_requests_errors( Ext::Telemetry::METRIC_GIT_REQUESTS_SEARCH_COMMITS_ERRORS, 1, error_type: http_response.telemetry_error_type, status_code: http_response.code ) raise ApiError, "Failed to search commits: #{http_response.inspect}" end response_payload = parse_json_response(http_response) extract_commits(response_payload) end |