summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-15 14:37:11 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-15 14:37:11 -0800
commitc5ba87a2fbd4eb0bcce5431683e26e8d345db5c4 (patch)
tree3337cbcf38a72eaa275be7e995c7ed7c83002ca4 /app
parent9c4015f3e8080f41daaac82cfe1465f6839ca427 (diff)
parentcd688a60111853f63413a87ad6632ad57368e886 (diff)
downloadgitlab-ce-c5ba87a2fbd4eb0bcce5431683e26e8d345db5c4.tar.gz
Merge pull request #8096 from cirosantilli/regex-to-string
Replace regex methods by string ones since faster and more readable
Diffstat (limited to 'app')
-rw-r--r--app/models/commit.rb8
-rw-r--r--app/models/project_services/campfire_service.rb4
-rw-r--r--app/models/project_services/hipchat_service.rb4
-rw-r--r--app/models/project_services/pushover_service.rb4
-rw-r--r--app/models/project_services/slack_message.rb4
-rw-r--r--app/models/user.rb2
-rw-r--r--app/services/git_push_service.rb8
-rw-r--r--app/services/notification_service.rb2
8 files changed, 18 insertions, 18 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 37dd371ec00..baccf286740 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -75,11 +75,11 @@ class Commit
return no_commit_message if title.blank?
- title_end = title.index(/\n/)
+ title_end = title.index("\n")
if (!title_end && title.length > 100) || (title_end && title_end > 100)
title[0..79] << "&hellip;".html_safe
else
- title.split(/\n/, 2).first
+ title.split("\n", 2).first
end
end
@@ -87,11 +87,11 @@ class Commit
#
# cut off, ellipses (`&hellp;`) are prepended to the commit message.
def description
- title_end = safe_message.index(/\n/)
+ title_end = safe_message.index("\n")
@description ||= if (!title_end && safe_message.length > 100) || (title_end && title_end > 100)
"&hellip;".html_safe << safe_message[80..-1]
else
- safe_message.split(/\n/, 2)[1].try(:chomp)
+ safe_message.split("\n", 2)[1].try(:chomp)
end
end
diff --git a/app/models/project_services/campfire_service.rb b/app/models/project_services/campfire_service.rb
index 0736ddab99b..3116c311052 100644
--- a/app/models/project_services/campfire_service.rb
+++ b/app/models/project_services/campfire_service.rb
@@ -60,9 +60,9 @@ class CampfireService < Service
message << "[#{project.name_with_namespace}] "
message << "#{push[:user_name]} "
- if before =~ /000000/
+ if before.include?('000000')
message << "pushed new branch #{ref} \n"
- elsif after =~ /000000/
+ elsif after.include?('000000')
message << "removed branch #{ref} \n"
else
message << "pushed #{push[:total_commits_count]} commits to #{ref}. "
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb
index 6ef4b210c56..aafc3efa970 100644
--- a/app/models/project_services/hipchat_service.rb
+++ b/app/models/project_services/hipchat_service.rb
@@ -58,12 +58,12 @@ class HipchatService < Service
message = ""
message << "#{push[:user_name]} "
- if before =~ /000000/
+ if before.include?('000000')
message << "pushed new branch <a href=\""\
"#{project.web_url}/commits/#{URI.escape(ref)}\">#{ref}</a>"\
" to <a href=\"#{project.web_url}\">"\
"#{project.name_with_namespace.gsub!(/\s/, "")}</a>\n"
- elsif after =~ /000000/
+ elsif after.include?('000000')
message << "removed branch #{ref} from <a href=\"#{project.web_url}\">#{project.name_with_namespace.gsub!(/\s/,'')}</a> \n"
else
message << "pushed to branch <a href=\""\
diff --git a/app/models/project_services/pushover_service.rb b/app/models/project_services/pushover_service.rb
index f247fde7762..a9b23f97ba0 100644
--- a/app/models/project_services/pushover_service.rb
+++ b/app/models/project_services/pushover_service.rb
@@ -80,9 +80,9 @@ class PushoverService < Service
before = push_data[:before]
after = push_data[:after]
- if before =~ /000000/
+ if before.include?('000000')
message = "#{push_data[:user_name]} pushed new branch \"#{ref}\"."
- elsif after =~ /000000/
+ elsif after.include?('000000')
message = "#{push_data[:user_name]} deleted branch \"#{ref}\"."
else
message = "#{push_data[:user_name]} push to branch \"#{ref}\"."
diff --git a/app/models/project_services/slack_message.rb b/app/models/project_services/slack_message.rb
index d0ddb1f162c..6c6446db45f 100644
--- a/app/models/project_services/slack_message.rb
+++ b/app/models/project_services/slack_message.rb
@@ -77,11 +77,11 @@ class SlackMessage
end
def new_branch?
- before =~ /000000/
+ before.include?('000000')
end
def removed_branch?
- after =~ /000000/
+ after.include?('000000')
end
def branch_url
diff --git a/app/models/user.rb b/app/models/user.rb
index 6e5ac9b39c8..743410c22e3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -488,7 +488,7 @@ class User < ActiveRecord::Base
end
def temp_oauth_email?
- email =~ /\Atemp-email-for-oauth/
+ email.start_with?('temp-email-for-oauth')
end
def public_profile?
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index a9ea7daabc8..872b886c575 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -111,23 +111,23 @@ class GitPushService
ref_parts = ref.split('/')
# Return if this is not a push to a branch (e.g. new commits)
- ref_parts[1] =~ /heads/ && oldrev != Gitlab::Git::BLANK_SHA
+ ref_parts[1].include?('heads') && oldrev != Gitlab::Git::BLANK_SHA
end
def push_to_new_branch?(ref, oldrev)
ref_parts = ref.split('/')
- ref_parts[1] =~ /heads/ && oldrev == Gitlab::Git::BLANK_SHA
+ ref_parts[1].include?('heads') && oldrev == Gitlab::Git::BLANK_SHA
end
def push_remove_branch?(ref, newrev)
ref_parts = ref.split('/')
- ref_parts[1] =~ /heads/ && newrev == Gitlab::Git::BLANK_SHA
+ ref_parts[1].include?('heads') && newrev == Gitlab::Git::BLANK_SHA
end
def push_to_branch?(ref)
- ref =~ /refs\/heads/
+ ref.include?('refs/heads')
end
def is_default_branch?(ref)
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index fb8f812dad8..5a89c5d2936 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -118,7 +118,7 @@ class NotificationService
return true unless note.noteable_type.present?
# ignore gitlab service messages
- return true if note.note =~ /\A_Status changed to closed_/
+ return true if note.note.start_with?('_Status changed to closed_')
return true if note.cross_reference? && note.system == true
opts = { noteable_type: note.noteable_type, project_id: note.project_id }