Method: Datadog::CI::Git::LocalRepository.git_branch

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

.git_branchObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/datadog/ci/git/local_repository.rb', line 121

def self.git_branch
  Telemetry.git_command(Ext::Telemetry::Command::GET_BRANCH)
  res = nil

  duration_ms = Core::Utils::Time.measure(:float_millisecond) do
    res = exec_git_command("git rev-parse --abbrev-ref HEAD")
  end

  Telemetry.git_command_ms(Ext::Telemetry::Command::GET_BRANCH, duration_ms)
  res
rescue => e
  log_failure(e, "git branch")
  telemetry_track_error(e, Ext::Telemetry::Command::GET_BRANCH)
  nil
end