Skip to content

Panic: Runtime Error: index out of range #242

@anschmieg

Description

@anschmieg

My local repo has the following changes:

git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   .idea/.gitignore
	new file:   .idea/coproxy-openai.iml
	new file:   .idea/inspectionProfiles/Project_Default.xml
	new file:   .idea/modules.xml
	new file:   .idea/vcs.xml
	new file:   .wrangler/state/v3/kv/efb1a94d5dfc4f4db24bc86549dba1ae/blobs/1f9532186fa93d36ddefffa02f435efaeaac25a05ce82634ea1833deb56ffd2300000196726e16f5
	new file:   .wrangler/state/v3/kv/miniflare-KVNamespaceObject/8522b4937dc3b73e5a0ad21318c4000645084080b5825af2326d4bd4f046e952.sqlite
	modified:   local-redirection-proxy.go
	modified:   src/worker.mjs
	modified:   wrangler.toml

when I ran git commit with the pre-commit hook installed previously, when I had no staged changes, it generated a commit message describing an added file. I then staged some files and ran git commit again, causing:

git commit
Summarizing commit message using gemini-2.5-flash-preview-04-17 model
Summarizing git diff...
Prompt tokens: 4455, Completion tokens: 0, Total tokens: 5455
Generating title for pull request...
Prompt tokens: 178, Completion tokens: 0, Total tokens: 1178
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/appleboy/CodeGPT/cmd.init.func7(0x105be3780, {0x10523ed80?, 0x4?, 0x10523ed84?})
	github.com/appleboy/CodeGPT/cmd/commit.go:176 +0x1b24
github.com/spf13/cobra.(*Command).execute(0x105be3780, {0x140000af7c0, 0x4, 0x4})
	github.com/spf13/[email protected]/command.go:1015 +0x844
github.com/spf13/cobra.(*Command).ExecuteC(0x105be1ec0)
	github.com/spf13/[email protected]/command.go:1148 +0x384
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
	github.com/spf13/[email protected]/command.go:1080
github.com/appleboy/CodeGPT/cmd.Execute({0x1055b4e60?, 0x140000c8a00?})
	github.com/appleboy/CodeGPT/cmd/cmd.go:171 +0x54
main.main()
	github.com/appleboy/CodeGPT/cmd/codegpt/main.go:11 +0x3c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions