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

Code before:
  end
  local upstream = result.stdout:match('^(%x+)')
  if not upstream then
    return
  end
  if upstream:sub(1, #commit) ~= commit then
    vim.health.warn(
      ('Build is outdated. Local: %s, Latest: %s'):format(commit, upstream:sub(1, 12))
    )
  else
    vim.health.ok(('Using latest HEAD: %s'):format(upstream:sub(1, 12)))
  end
end

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

  -- Use :version because `vim.version().build` returns "Homebrew" for brew installs.
  local version_out = vim.api.nvim_exec2('version', { output = true }).output
  local nvim_version = version_out:match('NVIM (v[^\n]+)') or 'unknown'
  local commit --[[@type string]] = (version_out:match('%+g(%x+)') or ''):sub(1, 12)

  if vim.fn.executable('git') ~= 1 then
    vim.health.warn('Cannot check for updates: git not found')
  else
    if vim.trim(commit) ~= '' then
      check_head_hash(commit)
    else
      check_stable_version(nvim_version)
    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: `%s` %s'):format(nvim_version, commit))
  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(
      [[
    ## Problem

    ## Steps to reproduce

    ```

Review comment (suggestion):
can remove a level of nesting
```suggestion
  elseif vim.trim(commit) ~= '' then
    ...
  else
    ...
  end
```

Code after:
  local result = vim
    .system(
      { 'git', 'ls-remote', 'https://github.com/neovim/neovim', 'HEAD' },
      { text = true, timeout = 5000 }
    )
    :wait()
  if result.code ~= 0 or not result.stdout or result.stdout == '' then
    return
  end
  local upstream = result.stdout:match('^(%x+)')
  if not upstream then
    return
  end
  if not vim.startswith(upstream, commit) then
    vim.health.warn(
      ('Build is outdated. Local: %s, Latest: %s'):format(commit, upstream:sub(1, 12))
    )
  else
    vim.health.ok(('Using latest HEAD: %s'):format(upstream:sub(1, 12)))
  end
end

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

  -- Use :version because `vim.version().build` returns "Homebrew" for brew installs.
  local version_out = vim.api.nvim_exec2('version', { output = true }).output
  local nvim_version = version_out:match('NVIM (v[^\n]+)') or 'unknown'
  local commit --[[@type string]] = (version_out:match('%+g(%x+)') or ''):sub(1, 12)

  if vim.fn.executable('git') ~= 1 then
    vim.health.warn('Cannot check for updates: git not found')
  elseif vim.trim(commit) ~= '' then
    check_head_hash(commit)
  else
    check_stable_version(nvim_version)
  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: `%s` %s'):format(nvim_version, commit))
  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(