gotsunami/gitlab-copy

gitlab-copy crashes if an issue is not assigned to a milestone

Closed this issue · 6 comments

Well it might not be considered as good style to not assign an issue to a milestone, but gitlab-copy should not crash with a nil pointer dereference when copying an issue that is not assigned to a milestone.

Workaround: assing all issues to a milestone

Otherwise, nice tool - keep on going! :)

matm commented

Weird. I made several tests in the past with issues without milestones. Maybe a regression... Thanks for pointing this out!

Hm - I used the current master and build it on a windows machine with the git-bash and go 1.8.3 windows/amd64

matm commented

Yep. Would you mind pasting a stack trace? Thanks

Sorry for the late reply, I had some free days :)

C:\Users\Username\Documents\gitlab-copy\dist\gitlab-copy>gitlab-copy gitlab.yml
DUMMY MODE: won't apply anything (stats only)
--
source: User1/project1 at http://192.168.64.115/api/v3
target: User1/project2 at http://192.168.64.115/api/v3
--
source: finding issues ... panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x71022d]

goroutine 1 [running]:
main.(*projectStats).computeStats.func1(0xc042034600, 0xc04200ecc0, 0xc04208fa50, 0x40fb7f, 0x20)
        C:/Users/Username/go/src/github.com/gotsunami/gitlab-copy/cmd/gitlab-copy/stats.go:70 +0x1dd
main.(*projectStats).pagination(0xc04200c480, 0xc042034600, 0xc042002d60, 0xc80000, 0x0)
        C:/Users/Username/go/src/github.com/gotsunami/gitlab-copy/cmd/gitlab-copy/stats.go:37 +0x83
main.(*projectStats).computeStats(0xc04200c480, 0xc042034600, 0xc04200b050, 0x0)
        C:/Users/Username/go/src/github.com/gotsunami/gitlab-copy/cmd/gitlab-copy/stats.go:81 +0xbf
main.main()
        C:/Users/Username/go/src/github.com/gotsunami/gitlab-copy/cmd/gitlab-copy/main.go:103 +0x6ba

Project 1 has 1 issue without milestone and 1 issue with milestone, project 2 has no issues and no milestones.

I had the same issue, wanting to copy all labels from a project to another. As the from project had around ~1000 issues, assigning milestones to all was no option. My workaround was to comment some lines in computeStats:

	if len(issues) > 0 {
		p.nbIssues += len(issues)
		for _, issue := range issues {
			switch issue.State {
			case "opened":
				p.nbOpened++
			case "closed":
				p.nbClosed++
			}
			// if issue.Milestone.Title != "" {
			// 	p.milestones[issue.Milestone.Title]++
			// }
		}
	} else {
		// Exit
		return true, nil
	}

This probably only works when using labelsOnly: true though.

This was fixed by commit 2b95aab
stats.go:70
if issue.Milestone!=nil && issue.Milestone.Title != "" {