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

Unable to delete a group that has not been approved #1068

Closed
JosteinLindhom opened this issue Apr 9, 2024 · 0 comments · Fixed by #1069
Closed

Unable to delete a group that has not been approved #1068

JosteinLindhom opened this issue Apr 9, 2024 · 0 comments · Fixed by #1069
Assignees
Labels

Comments

@JosteinLindhom
Copy link
Contributor

Before we can delete a group we need to check that it's repository is either empty or does not exist.

For groups that have been created but not approved, no repository has been created. In these cases IsEmptyRepo, which is a precondition for deleting a group, will fail.

func (s *QuickFeedService) isEmptyRepo(ctx context.Context, sc scm.SCM, request *qf.RepositoryRequest) error {
	course, err := s.db.GetCourse(request.GetCourseID(), false)
	if err != nil {
		return err
	}
	repos, err := s.db.GetRepositories(&qf.Repository{
		ScmOrganizationID: course.GetScmOrganizationID(),
		UserID:            request.GetUserID(),
		GroupID:           request.GetGroupID(),
	})
	if err != nil {
		return err
	}
	if len(repos) < 1 {
		return fmt.Errorf("no repositories found")
	}
	return isEmpty(ctx, sc, repos)
}

Returning nil if no record is found may resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant