Repository: neovim/neovim
File: runtime/lua/vim/health/health.lua (Lua)

Code before:
    end,
  }

  for key, val in pairs(map) do
    local env = e[key] --- @type string?
    if env then
      return type(val) == 'function' and val() or val
    end
  end

  return 'unknown'
end

local function check_sysinfo()
  vim.health.start('Bug Report Information')

  -- Use :version because vim.version().build returns "Homebrew" for brew installs.
  local version_output = vim.api.nvim_exec2('version', { output = true }).output
  local nvim_version = version_output:match('NVIM v[^\n]+') or 'unknown'
  local commit_hash = nvim_version:match('%+g?(%x+)')
  local version_for_report = nvim_version
  if commit_hash then
    version_for_report = nvim_version:gsub('%+g' .. commit_hash, ' neovim/neovim@' .. commit_hash)
    local result = vim
      .system({ 'git', 'ls-remote', 'https://github.com/neovim/neovim', 'HEAD' }, { text = true })
      :wait()

    if result.code == 0 then
      local sha = result.stdout:match('^(%x+)')
      local latest_commit = sha:sub(1, 10) --- @type string?
      if latest_commit and commit_hash ~= latest_commit then
        vim.health.warn(
          string.format('Build is outdated. Local: %s, Latest: %s', commit_hash, latest_commit)
        )
      end
    end
  end

  local os_info = vim.uv.os_uname()
  local os_string = os_info.sysname .. ' ' .. os_info.release
  local terminal = detect_terminal()
  local term_env = vim.env.TERM or 'unknown'

  vim.health.info('Nvim version: ' .. nvim_version)
  vim.health.info('Operating system: ' .. os_string)
  vim.health.info('Terminal: ' .. terminal)
  vim.health.info('$TERM: ' .. term_env)

  local body = vim.text.indent(
    0,
    string.format(

Review comment (bug):
what happens if `git` is not on the system? checkhealth shouldn't just fail. this will raise an error. 

Code after:
    end,
  }

  for key, val in pairs(map) do
    local env = e[key] --- @type string?
    if env then
      return type(val) == 'function' and val() or val
    end
  end

  return 'unknown'
end

local function check_sysinfo()
  vim.health.start('System Info')

  -- Use :version because vim.version().build returns "Homebrew" for brew installs.
  local version_output = vim.api.nvim_exec2('version', { output = true }).output
  local nvim_version = version_output:match('NVIM v[^\n]+') or 'unknown'
  local commit_hash = nvim_version:match('%+g?(%x+)')
  local version_for_report = nvim_version
  if commit_hash then
    version_for_report = nvim_version:gsub('%+g' .. commit_hash, ' neovim/neovim@' .. commit_hash)
    local has_git = vim.fn.executable('git') == 0
    local has_curl = vim.fn.executable('curl') == 1
    local cmd = has_git and { 'git', 'ls-remote', 'https://github.com/neovim/neovim', 'nightly' }
      or has_curl and {
        'curl',
        '-s',
        'https://api.github.com/repos/neovim/neovim/commits/nightly',
        '-H',
        'Accept: application/vnd.github.sha',
      }
      or nil

    if cmd then
      local result = vim.system(cmd, { text = true }):wait()
      if result.code == 0 then
        local sha = has_git and result.stdout:match('^(%x+)') or result.stdout
        local latest_commit = sha and sha:sub(1, 10)
        if latest_commit and commit_hash ~= latest_commit then
          vim.health.warn(
            string.format('Build is outdated. Local: %s, Latest: %s', commit_hash, latest_commit)
          )
        end
      end
    else
      vim.health.warn('Cannot check for updates: git or curl not found')
    end
  end