Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh repo garden panics on a short repository name #14372

Description

@lenamonj

Describe the bug

gh repo garden panics on a repository whose full name is short.

computeSeed in pkg/cmd/repo/garden/garden.go concatenates the decimal code point of each rune of the repository name and slices the first ten characters unconditionally. A name such as a/b yields six digits, so the slice panics before any API call. Two other unchecked slices in the same file, commit.Sha[0:6] and the three sha[i:j] reads in shaToColorFunc, assume a sha length the commits API does not guarantee.

Affected version

Built from trunk at 0d121e8 (2026-09-05); the code is unchanged in the current release.

Steps to reproduce the behavior

  1. Run gh repo garden a/b on a terminal.
  2. See the panic.

Expected vs actual behavior

Expected: the garden renders, or a normal error message. Actual:

panic: runtime error: slice bounds out of range [:10] with length 6

Logs

Same as above; the panic is the whole output.

A fix that takes the digits that exist, bounds the sha slices, and drops the panic calls is ready; happy to open the PR if this is labelled help wanted.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-reporelating to the gh repo commandpriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions