aboutsummaryrefslogtreecommitdiffstats
path: root/models/git
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-09-22 01:43:29 +0200
committerGitHub <noreply@github.com>2023-09-21 23:43:29 +0000
commit28f9b313bab420be8f42e546015312904311adba (patch)
treef3f09c6cef7bf96c7f390ba8e858cf80b0445581 /models/git
parent7520cd678c3ef037db702296192d8664b6f02a54 (diff)
downloadgitea-28f9b313bab420be8f42e546015312904311adba.tar.gz
gitea-28f9b313bab420be8f42e546015312904311adba.zip
Updates to the API for archived repos (#27149)
Diffstat (limited to 'models/git')
-rw-r--r--models/git/protected_branch.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/models/git/protected_branch.go b/models/git/protected_branch.go
index 5ed1003749..5be35f4b11 100644
--- a/models/git/protected_branch.go
+++ b/models/git/protected_branch.go
@@ -315,6 +315,11 @@ type WhitelistOptions struct {
// This function also performs check if whitelist user and team's IDs have been changed
// to avoid unnecessary whitelist delete and regenerate.
func UpdateProtectBranch(ctx context.Context, repo *repo_model.Repository, protectBranch *ProtectedBranch, opts WhitelistOptions) (err error) {
+ err = repo.MustNotBeArchived()
+ if err != nil {
+ return err
+ }
+
if err = repo.LoadOwner(ctx); err != nil {
return fmt.Errorf("LoadOwner: %v", err)
}
@@ -445,9 +450,14 @@ func updateTeamWhitelist(ctx context.Context, repo *repo_model.Repository, curre
}
// DeleteProtectedBranch removes ProtectedBranch relation between the user and repository.
-func DeleteProtectedBranch(ctx context.Context, repoID, id int64) (err error) {
+func DeleteProtectedBranch(ctx context.Context, repo *repo_model.Repository, id int64) (err error) {
+ err = repo.MustNotBeArchived()
+ if err != nil {
+ return err
+ }
+
protectedBranch := &ProtectedBranch{
- RepoID: repoID,
+ RepoID: repo.ID,
ID: id,
}