summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/branches.go17
-rw-r--r--models/fixtures/user.yml5
2 files changed, 20 insertions, 2 deletions
diff --git a/models/branches.go b/models/branches.go
index 322d33daae..a71c0e9622 100644
--- a/models/branches.go
+++ b/models/branches.go
@@ -63,6 +63,23 @@ func (repo *Repository) GetProtectedBranches() ([]*ProtectedBranch, error) {
return protectedBranches, x.Find(&protectedBranches, &ProtectedBranch{RepoID: repo.ID})
}
+// IsProtectedBranch checks if branch is protected
+func (repo *Repository) IsProtectedBranch(branchName string) (bool, error) {
+ protectedBranch := &ProtectedBranch{
+ RepoID: repo.ID,
+ BranchName: branchName,
+ }
+
+ has, err := x.Get(protectedBranch)
+ if err != nil {
+ return true, err
+ } else if has {
+ return true, nil
+ }
+
+ return false, nil
+}
+
// AddProtectedBranch add protection to branch
func (repo *Repository) AddProtectedBranch(branchName string, canPush bool) error {
protectedBranch := &ProtectedBranch{
diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml
index 409747aa12..dd8554c58b 100644
--- a/models/fixtures/user.yml
+++ b/models/fixtures/user.yml
@@ -18,15 +18,16 @@
name: user2
full_name: User Two
email: user2@example.com
- passwd: password
+ passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password
type: 0 # individual
- salt: salt
+ salt: ZogKvWdyEx
is_admin: false
avatar: avatar2
avatar_email: user2@example.com
num_repos: 2
num_stars: 2
num_followers: 1
+ is_active: true
-
id: 3