Skip to content

Commit

Permalink
Remove unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Dec 10, 2021
1 parent b93b534 commit 7ac88ae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
5 changes: 0 additions & 5 deletions models/branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,6 @@ func GetProtectedBranches(repoID int64) ([]*ProtectedBranch, error) {
return protectedBranches, db.GetEngine(db.DefaultContext).Find(&protectedBranches, &ProtectedBranch{RepoID: repoID})
}

// GetBranchProtection get the branch protection of a branch
func GetBranchProtection(repoID int64, branchName string) (*ProtectedBranch, error) {
return GetProtectedBranchBy(repoID, branchName)
}

// IsProtectedBranch checks if branch is protected
func IsProtectedBranch(repoID int64, branchName string) (bool, error) {
protectedBranch := &ProtectedBranch{
Expand Down
6 changes: 3 additions & 3 deletions routers/api/v1/repo/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func GetBranch(ctx *context.APIContext) {
return
}

branchProtection, err := models.GetBranchProtection(ctx.Repo.Repository.ID, branchName)
branchProtection, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branchName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
Expand Down Expand Up @@ -210,7 +210,7 @@ func CreateBranch(ctx *context.APIContext) {
return
}

branchProtection, err := models.GetBranchProtection(ctx.Repo.Repository.ID, branch.Name)
branchProtection, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branch.Name)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
Expand Down Expand Up @@ -270,7 +270,7 @@ func ListBranches(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
return
}
branchProtection, err := models.GetBranchProtection(ctx.Repo.Repository.ID, branches[i].Name)
branchProtection, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branches[i].Name)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
Expand Down
2 changes: 1 addition & 1 deletion services/repository/files/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func CreateOrUpdateRepoFile(repo *repo_model.Repository, doer *user_model.User,

// VerifyBranchProtection verify the branch protection for modifying the given treePath on the given branch
func VerifyBranchProtection(repo *repo_model.Repository, doer *user_model.User, branchName string, treePath string) error {
protectedBranch, err := models.GetBranchProtection(repo.ID, branchName)
protectedBranch, err := models.GetProtectedBranchBy(repo.ID, branchName)
if err != nil {
return err
}
Expand Down

0 comments on commit 7ac88ae

Please sign in to comment.