forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup protected branches when deleting users & teams (go-gitea#19158)
* Clean up protected_branches when deleting user fixes go-gitea#19094 * Clean up protected_branches when deleting teams * fix issue Co-authored-by: Lauris BH <[email protected]>
- Loading branch information
Showing
3 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package util | ||
|
||
// RemoveIDFromList removes the given ID from the slice, if found. | ||
// It does not preserve order, and assumes the ID is unique. | ||
func RemoveIDFromList(list []int64, id int64) ([]int64, bool) { | ||
n := len(list) - 1 | ||
for i, item := range list { | ||
if item == id { | ||
list[i] = list[n] | ||
return list[:n], true | ||
} | ||
} | ||
return list, false | ||
} |