Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository.Push panics when it tries to push a tag with an empty name #929

Closed
peterzandbergen opened this issue Nov 16, 2023 · 0 comments · Fixed by #950
Closed

Repository.Push panics when it tries to push a tag with an empty name #929

peterzandbergen opened this issue Nov 16, 2023 · 0 comments · Fixed by #950

Comments

@peterzandbergen
Copy link

peterzandbergen commented Nov 16, 2023

When I Clone a remote repo in memory with no working area, tag the head with an empty tag name and then push it back to origin, Push panics.

Steps to reproduce:

  1. Clone a repo from e.g. github in memory
  2. tag the head with an empty tag name
  3. Push to origin, this panixs
// 1
repo, _ := git.CloneContext(ctx, memory.NewStorage(), nil, &co)

// 2
repo.CreateTag("", hash, opts)

// 
repo.PushContext(ctx, opts) // This generates a panic.

A test with my program using your great package (serious now)

# This command completes successfully.
 peza  c5361530-pop-os  ~  DevProjects  ggit  ERROR  $  go run ./cmd/ggit/     --repo-url https://gitlab.com/peterzandbergen/ggit-test.git      --loglevel debug     --branch main     --user peterzandbergen     --password *************     --name "Peter Zandbergen"     --email peter.zandbergen@myhops.nl     --message "Hallo daar"     --tag "new-tag-1"
time=2023-11-16T10:17:12.377+01:00 level=DEBUG msg="create logger" application=ggit loglevel=DEBUG logformat=text
time=2023-11-16T10:17:12.377+01:00 level=DEBUG msg="execute started" application=ggit
time=2023-11-16T10:17:12.377+01:00 level=DEBUG msg="using basic auth" application=ggit
time=2023-11-16T10:17:12.377+01:00 level=DEBUG msg="authenticator created" application=ggit
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="repo cloned" application=ggit
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="creating annotated tagger" application=ggit taggerName="Peter Zandbergen" taggerEmail=peter.zandbergen@myhops.nl
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="creating annotated tagger" application=ggit taggerName="Peter Zandbergen" taggerEmail=peter.zandbergen@myhops.nl
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="annotated tag" application=ggit
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="head tagged" application=ggit
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="created tag ref spec" application=ggit tagRefSpec=refs/tags/*:refs/tags/*
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="using auth" application=ggit auth.String="http-basic-auth - peterzandbergen:*******" auth.Name=http-basic-auth
time=2023-11-16T10:17:13.968+01:00 level=DEBUG msg="tags pushed" application=ggit


# When removing the --tag option the code panics
 peza  c5361530-pop-os  ~  DevProjects  ggit  $  go run ./cmd/ggit/     --repo-url https://gitlab.com/peterzandbergen/ggit-test.git      --loglevel debug     --branch main     --user peterzandbergen     --password *********     --name "Peter Zandbergen"     --email peter.zandbergen@myhops.nl     --message "Hallo daar" 
time=2023-11-16T10:17:34.943+01:00 level=DEBUG msg="create logger" application=ggit loglevel=DEBUG logformat=text
time=2023-11-16T10:17:34.943+01:00 level=DEBUG msg="execute started" application=ggit
time=2023-11-16T10:17:34.943+01:00 level=DEBUG msg="using basic auth" application=ggit
time=2023-11-16T10:17:34.943+01:00 level=DEBUG msg="authenticator created" application=ggit
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="repo cloned" application=ggit
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="creating annotated tagger" application=ggit taggerName="Peter Zandbergen" taggerEmail=peter.zandbergen@myhops.nl
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="creating annotated tagger" application=ggit taggerName="Peter Zandbergen" taggerEmail=peter.zandbergen@myhops.nl
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="annotated tag" application=ggit
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="head tagged" application=ggit
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="created tag ref spec" application=ggit tagRefSpec=refs/tags/*:refs/tags/*
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="using auth" application=ggit auth.String="http-basic-auth - peterzandbergen:*******" auth.Name=http-basic-auth
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/go-git/go-git/v5/plumbing/object.(*Tag).Decode(0xc000416160, {0xac05a0, 0xc00011ebc0})
	/home/peza/DevProjects/go-git/plumbing/object/tag.go:119 +0x7f2
github.com/go-git/go-git/v5/plumbing/object.DecodeTag({0x7f693642e860?, 0xc0000a4300}, {0xac05a0, 0xc00011ebc0})
	/home/peza/DevProjects/go-git/plumbing/object/tag.go:58 +0x7b
github.com/go-git/go-git/v5/plumbing/object.DecodeObject({0x7f693642e860, 0xc0000a4300}, {0xac05a0, 0xc00011ebc0?})
	/home/peza/DevProjects/go-git/plumbing/object/object.go:71 +0xdb
github.com/go-git/go-git/v5/plumbing/object.GetObject({0x7f693642e860, 0xc0000a4300}, {0xbf, 0xba, 0x38, 0x96, 0x52, 0x2a, 0x9e, 0xf, ...})
	/home/peza/DevProjects/go-git/plumbing/object/object.go:57 +0x5d
github.com/go-git/go-git/v5.(*Remote).addReachableTags(0xc000382690, {0xc00011eec0, 0x7, 0x0?}, {0xac05f0, 0xc000381da0}, 0xc0003ba540)
	/home/peza/DevProjects/go-git/remote.go:263 +0x29c
github.com/go-git/go-git/v5.(*Remote).newReferenceUpdateRequest(0x0?, 0xc000487948, {0xc00011eec0, 0x7, 0x8}, {0xac05f0, 0xc000381da0}, 0xc0003a8460)
	/home/peza/DevProjects/go-git/remote.go:342 +0x310
github.com/go-git/go-git/v5.(*Remote).PushContext(0xc000382690, {0xabd748, 0xc00017e3f0}, 0xc000487948)
	/home/peza/DevProjects/go-git/remote.go:168 +0x5a5
github.com/go-git/go-git/v5.(*Repository).PushContext(0xc00011c240?, {0xabd748, 0xc00017e3f0}, 0xc000487948)
	/home/peza/DevProjects/go-git/repository.go:1226 +0x6a
github.com/myhops/ggit/command.(*TagRemoteConfig).pushTags(0xc000000300, {0xabd748, 0xc00017e3f0}, 0xfffffffffffffffc?, {0x9e4d2d, 0x6}, {0xabad18?, 0xc0001898e0?})
	/home/peza/DevProjects/ggit/command/tagremote.go:174 +0x438
github.com/myhops/ggit/command.(*TagRemoteConfig).ExecuteContext(0xc000000300, {0xabd748, 0xc00017e3f0})
	/home/peza/DevProjects/ggit/command/tagremote.go:209 +0x217
github.com/myhops/ggit/command.tagRemoteAction(0xc00017e150)
	/home/peza/DevProjects/ggit/command/tagremotecommand.go:62 +0x3a
github.com/urfave/cli/v3.(*Command).Run(0xc0000d4fc0, {0xabd710?, 0xe812a0}, {0xc000024120, 0x11, 0x12})
	/home/peza/go/pkg/mod/github.com/urfave/cli/v3@v3.0.0-alpha4/command.go:494 +0x1017
main.main()
	/home/peza/DevProjects/ggit/cmd/ggit/main.go:13 +0x3f
exit status 2
aymanbagabas added a commit to aymanbagabas/go-git that referenced this issue Nov 28, 2023
An empty tagname is an invalid tag.

Fixes: go-git#929
aymanbagabas added a commit to aymanbagabas/go-git that referenced this issue Nov 28, 2023
An empty tagname is an invalid tag.

Fixes: go-git#929
aymanbagabas added a commit to aymanbagabas/go-git that referenced this issue Nov 28, 2023
Check reference names format before creating branches/tags/remotes.

This should probably be in a lower level somewhere in `plumbing`.
Validating the names under `plumbing.NewReference*` is not possible
since these functions don't return errors.

Fixes: go-git#929
aymanbagabas added a commit to aymanbagabas/go-git that referenced this issue Nov 28, 2023
Check reference names format before creating branches/tags/remotes.

This should probably be in a lower level somewhere in `plumbing`.
Validating the names under `plumbing.NewReference*` is not possible
since these functions don't return errors.

Fixes: go-git#929
aymanbagabas added a commit to aymanbagabas/go-git that referenced this issue Nov 28, 2023
Check reference names format before creating branches/tags/remotes.

This should probably be in a lower level somewhere in `plumbing`.
Validating the names under `plumbing.NewReference*` is not possible
since these functions don't return errors.

Fixes: go-git#929
aymanbagabas added a commit to aymanbagabas/go-git that referenced this issue Nov 30, 2023
Check reference names format before creating branches/tags/remotes.

This should probably be in a lower level somewhere in `plumbing`.
Validating the names under `plumbing.NewReference*` is not possible
since these functions don't return errors.

Fixes: go-git#929
@pjbgf pjbgf closed this as completed in #950 Dec 1, 2023
pjbgf added a commit that referenced this issue Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant