Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit 86d2feb

Browse files
authored
Merge pull request #2010 from heidiberry/allow-immediate-project-deletion
Breaking change: New options when calling DeleteProject
2 parents afb6163 + 113bdaf commit 86d2feb

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

projects.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,18 +1159,28 @@ func (s *ProjectsService) UnarchiveProject(pid interface{}, options ...RequestOp
11591159
return p, resp, nil
11601160
}
11611161

1162+
// DeleteProjectOptions represents options to delete a project.
1163+
//
1164+
// GitLab API docs:
1165+
// https://docs.gitlab.com/ee/api/projects.html#delete-project
1166+
type DeleteProjectOptions struct {
1167+
FullPath *string `url:"full_path" json:"full_path"`
1168+
PermanentlyRemove *bool `url:"permanently_remove" json:"permanently_remove"`
1169+
}
1170+
11621171
// DeleteProject removes a project including all associated resources
11631172
// (issues, merge requests etc.)
11641173
//
1165-
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#delete-project
1166-
func (s *ProjectsService) DeleteProject(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
1174+
// GitLab API docs:
1175+
// https://docs.gitlab.com/ee/api/projects.html#delete-project
1176+
func (s *ProjectsService) DeleteProject(pid interface{}, opt *DeleteProjectOptions, options ...RequestOptionFunc) (*Response, error) {
11671177
project, err := parseID(pid)
11681178
if err != nil {
11691179
return nil, err
11701180
}
11711181
u := fmt.Sprintf("projects/%s", PathEscape(project))
11721182

1173-
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
1183+
req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
11741184
if err != nil {
11751185
return nil, err
11761186
}

projects_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,24 @@ func TestListProjectForks(t *testing.T) {
647647
}
648648
}
649649

650+
func TestDeleteProject(t *testing.T) {
651+
mux, client := setup(t)
652+
653+
mux.HandleFunc("/api/v4/projects/1", func(w http.ResponseWriter, r *http.Request) {
654+
testMethod(t, r, http.MethodDelete)
655+
})
656+
657+
opt := &DeleteProjectOptions{
658+
FullPath: Ptr("group/project"),
659+
PermanentlyRemove: Ptr(true),
660+
}
661+
662+
_, err := client.Projects.DeleteProject(1, opt)
663+
if err != nil {
664+
t.Errorf("Projects.DeleteProject returned error: %v", err)
665+
}
666+
}
667+
650668
func TestShareProjectWithGroup(t *testing.T) {
651669
mux, client := setup(t)
652670

0 commit comments

Comments
 (0)