Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-06-16 10:33:30 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-07-05 08:20:34 +0300
commit2a5cb7ec5259123cbbecb0577b9b4afacaf7546a (patch)
tree33c21abf857e8eac410416e74ec07c09757684f5 /app/models/protected_branch.rb
parentf51af496769f2fe181d4633f810b85103efd181e (diff)
Modify the frontend for wildcard protected branches.
1. Allow entering any branch name for a protected branch. - Either pick from a list of options, or enter it manually - You can enter wildcards. 2. Display branches matching a protected branch. - Add a `ProtectedBranches#show` page that displays the branches matching the given protected branch, or a message if there are no matches. - On the `index` page, display the last commit for an exact match, or the number of matching branches for a wildcard match. - Add an `iid` column to `protected_branches` - this is what we use for the `show` page URL. - On the off chance that this feature is unnecessary, this commit encapsulates it neatly, so it can be removed without affecting anything else. 3. Remove the "Last Commit" column from the list of protected branches. - There's no way to pull these for wildcard protected branches, so it's best left for the `show` page. - Rename the `@branches` instance variable to `@protected_branches` - Minor styling changes with the "Unprotect" button - floated right like the "Revoke" button for personal access tokens 4. Paginate the list of protected branches. 5. Move the instructions to the left side of the page.
Diffstat (limited to 'app/models/protected_branch.rb')
-rw-r--r--app/models/protected_branch.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb
index 3db1ab0e5f9..d3d5e1d98b2 100644
--- a/app/models/protected_branch.rb
+++ b/app/models/protected_branch.rb
@@ -19,6 +19,12 @@ class ProtectedBranch < ActiveRecord::Base
(protected_branches || all).select { |protected_branch| protected_branch.matches?(branch_name) }
end
+ # Returns all branches (among the given list of branches [`Gitlab::Git::Branch`])
+ # that match the current protected branch.
+ def matching(branches)
+ branches.select { |branch| self.matches?(branch.name) }
+ end
+
# Checks if the protected branch matches the given branch name.
def matches?(branch_name)
return false if self.name.blank?
@@ -26,6 +32,11 @@ class ProtectedBranch < ActiveRecord::Base
exact_match?(branch_name) || wildcard_match?(branch_name)
end
+ # Checks if this protected branch contains a wildcard
+ def wildcard?
+ self.name.include?('*')
+ end
+
protected
def exact_match?(branch_name)