Method: Datadog::CI::Git::LocalRepository.git_commits

Defined in:
lib/datadog/ci/git/local_repository.rb

.git_commitsObject

returns maximum of 1000 latest commits in the last month



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/datadog/ci/git/local_repository.rb', line 177

def self.git_commits
  Telemetry.git_command(Ext::Telemetry::Command::GET_LOCAL_COMMITS)

  output = nil
  duration_ms = Core::Utils::Time.measure(:float_millisecond) do
    output = exec_git_command("git log --format=%H -n 1000 --since=\"1 month ago\"")
  end

  Telemetry.git_command_ms(Ext::Telemetry::Command::GET_LOCAL_COMMITS, duration_ms)

  return [] if output.nil?

  # @type var output: String
  output.split("\n")
rescue => e
  log_failure(e, "git commits")
  telemetry_track_error(e, Ext::Telemetry::Command::GET_LOCAL_COMMITS)
  []
end