summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG2
-rw-r--r--app/assets/stylesheets/generic/mobile.scss33
-rw-r--r--app/controllers/projects/uploads_controller.rb7
-rw-r--r--app/models/namespace.rb11
-rw-r--r--app/views/dashboard/_activities.html.haml21
-rw-r--r--app/views/groups/show.html.haml21
-rw-r--r--app/views/projects/show.html.haml24
-rw-r--r--db/migrate/20150421120000_remove_periods_at_ends_of_usernames.rb88
-rw-r--r--db/schema.rb2
-rw-r--r--lib/gitlab/regex.rb4
10 files changed, 172 insertions, 41 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 87189d97103..92ae6767ea2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@ v 7.11.0 (unreleased)
- Ignore invalid lines in .gitmodules
- Fix "Cannot move project" error message from popping up after a successful transfer (Stan Hu)
- Redirect to sign in page after signing out.
+ - Fix "Hello @username." references not working by no longer allowing usernames to end in period.
-
- Add "Reply quoting selected text" shortcut key (`r`)
- Fix bug causing `@whatever` inside an issue's first code block to be picked up as a user mention.
@@ -21,6 +22,7 @@ v 7.11.0 (unreleased)
- Improve UI for sidebar. Increase separation between navigation and content
- Improve new project command options (Ben Bodenmiller)
- Prevent sending empty messages to HipChat (Chulki Lee)
+ - Improve UI for mobile phones on dashboard and project pages
v 7.10.0 (unreleased)
- Ignore submodules that are defined in .gitmodules but are checked in as directories.
diff --git a/app/assets/stylesheets/generic/mobile.scss b/app/assets/stylesheets/generic/mobile.scss
index 71a1fc4493f..c9bbacd7348 100644
--- a/app/assets/stylesheets/generic/mobile.scss
+++ b/app/assets/stylesheets/generic/mobile.scss
@@ -4,6 +4,11 @@
margin-top: 20px;
}
+ .container-fluid {
+ padding-left: 5px;
+ padding-right: 5px;
+ }
+
.nav.nav-tabs > li > a {
padding: 10px;
font-size: 12px;
@@ -27,6 +32,34 @@
.project-home-links {
display: none;
}
+
+ .project-avatar {
+ display: none;
+ }
+
+ .project-home-panel {
+ padding-left: 0 !important;
+
+ .project-home-row {
+ .project-home-desc {
+ margin-right: 0 !important;
+ float: none !important;
+ }
+
+ .project-repo-buttons {
+ position: static;
+ margin-top: 15px;
+ width: 100%;
+ float: none;
+ text-align: left;
+ }
+ }
+ }
+
+ .navbar-inner .title {
+ margin-left: 6px !important;
+ max-width: 70% !important;
+ }
}
@media (max-width: $screen-sm-max) {
diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb
index 6153ca2dc1b..e2d0b0d9459 100644
--- a/app/controllers/projects/uploads_controller.rb
+++ b/app/controllers/projects/uploads_controller.rb
@@ -1,11 +1,8 @@
class Projects::UploadsController < Projects::ApplicationController
layout 'project'
- # We want to skip these filters for only the `show` action if `image?` is true,
- # but `skip_before_filter` doesn't work with both `only` and `if`, so we accomplish the same like this.
- skipped_filters = [:authenticate_user!, :reject_blocked!, :project, :repository]
- skip_before_action *skipped_filters, only: [:show]
- before_action *skipped_filters, only: [:show], unless: :image?
+ skip_before_action :authenticate_user!, :reject_blocked!, :project,
+ :repository, if: -> { action_name == 'show' && image? }
def create
link_to_file = ::Projects::UploadService.new(project, params[:file]).
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index e1de114375e..211dfa76b81 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -60,15 +60,24 @@ class Namespace < ActiveRecord::Base
def clean_path(path)
path = path.dup
+ # Get the email username by removing everything after an `@` sign.
path.gsub!(/@.*\z/, "")
+ # Usernames can't end in .git, so remove it.
path.gsub!(/\.git\z/, "")
+ # Remove dashes at the start of the username.
path.gsub!(/\A-+/, "")
+ # Remove periods at the end of the username.
path.gsub!(/\.+\z/, "")
+ # Remove everything that's not in the list of allowed characters.
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "")
+ # Users with the great usernames of "." or ".." would end up with a blank username.
+ # Work around that by setting their username to "blank", followed by a counter.
+ path = "blank" if path.blank?
+
counter = 0
base = path
- while Namespace.by_path(path).present?
+ while Namespace.find_by_path_or_name(path)
counter += 1
path = "#{base}#{counter}"
end
diff --git a/app/views/dashboard/_activities.html.haml b/app/views/dashboard/_activities.html.haml
index b4fe8fecf99..ba49013d834 100644
--- a/app/views/dashboard/_activities.html.haml
+++ b/app/views/dashboard/_activities.html.haml
@@ -1,13 +1,14 @@
-= render "events/event_last_push", event: @last_push
+.hidden-xs
+ = render "events/event_last_push", event: @last_push
-- if current_user
- %ul.nav.nav-pills.event_filter.pull-right
- %li.pull-right
- = link_to dashboard_path(:atom, { private_token: current_user.private_token }), class: 'rss-btn' do
- %i.fa.fa-rss
- Activity Feed
-
-= render 'shared/event_filter'
-%hr
+ - if current_user
+ %ul.nav.nav-pills.event_filter.pull-right
+ %li.pull-right
+ = link_to dashboard_path(:atom, { private_token: current_user.private_token }), class: 'rss-btn' do
+ %i.fa.fa-rss
+ Activity Feed
+
+ = render 'shared/event_filter'
+ %hr
.content_list
= spinner
diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml
index 70a18f064be..3db0dfa59b1 100644
--- a/app/views/groups/show.html.haml
+++ b/app/views/groups/show.html.haml
@@ -15,18 +15,19 @@
%hr
.row
%section.activities.col-md-8
- - if current_user
- = render "events/event_last_push", event: @last_push
-
+ .hidden-xs
- if current_user
- %ul.nav.nav-pills.event_filter.pull-right
- %li
- = link_to group_path(@group, { format: :atom, private_token: current_user.private_token }), title: "Feed", class: 'rss-btn' do
- %i.fa.fa-rss
- Activity Feed
+ = render "events/event_last_push", event: @last_push
+
+ - if current_user
+ %ul.nav.nav-pills.event_filter.pull-right
+ %li
+ = link_to group_path(@group, { format: :atom, private_token: current_user.private_token }), title: "Feed", class: 'rss-btn' do
+ %i.fa.fa-rss
+ Activity Feed
- = render 'shared/event_filter'
- %hr
+ = render 'shared/event_filter'
+ %hr
.content_list
= spinner
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index f85705ffdd2..1787caa243d 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -7,7 +7,6 @@
= render 'shared/no_password'
= render "home_panel"
-
%ul.nav.nav-tabs
%li.active
= link_to '#tab-activity', 'data-toggle' => 'tab' do
@@ -17,11 +16,11 @@
= link_to '#tab-readme', 'data-toggle' => 'tab' do
Readme
- if @repository.changelog
- %li
+ %li.hidden-xs
= link_to changelog_url(@project) do
Changelog
- if @repository.contribution_guide
- %li
+ %li.hidden-xs
= link_to contribution_guide_url(@project) do
Contribution guide
- if @repository.license
@@ -42,17 +41,18 @@
= link_to '#aside', class: 'show-aside' do
%i.fa.fa-angle-left
%section.col-md-9
- = render "events/event_last_push", event: @last_push
+ .hidden-xs
+ = render "events/event_last_push", event: @last_push
- - if current_user
- %ul.nav.nav-pills.event_filter.pull-right
- %li
- = link_to namespace_project_path(@project.namespace, @project, format: :atom, private_token: current_user.private_token), title: "Feed", class: 'rss-btn' do
- %i.fa.fa-rss
- Activity Feed
+ - if current_user
+ %ul.nav.nav-pills.event_filter.pull-right
+ %li
+ = link_to namespace_project_path(@project.namespace, @project, format: :atom, private_token: current_user.private_token), title: "Feed", class: 'rss-btn' do
+ %i.fa.fa-rss
+ Activity Feed
- = render 'shared/event_filter'
- %hr
+ = render 'shared/event_filter'
+ %hr
.content_list
= spinner
%aside.col-md-3.project-side
diff --git a/db/migrate/20150421120000_remove_periods_at_ends_of_usernames.rb b/db/migrate/20150421120000_remove_periods_at_ends_of_usernames.rb
new file mode 100644
index 00000000000..3057ea3c68c
--- /dev/null
+++ b/db/migrate/20150421120000_remove_periods_at_ends_of_usernames.rb
@@ -0,0 +1,88 @@
+class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
+ include Gitlab::ShellAdapter
+
+ class Namespace < ActiveRecord::Base
+ class << self
+ def find_by_path_or_name(path)
+ find_by("lower(path) = :path OR lower(name) = :path", path: path.downcase)
+ end
+
+ def clean_path(path)
+ path = path.dup
+ # Get the email username by removing everything after an `@` sign.
+ path.gsub!(/@.*\z/, "")
+ # Usernames can't end in .git, so remove it.
+ path.gsub!(/\.git\z/, "")
+ # Remove dashes at the start of the username.
+ path.gsub!(/\A-+/, "")
+ # Remove periods at the end of the username.
+ path.gsub!(/\.+\z/, "")
+ # Remove everything that's not in the list of allowed characters.
+ path.gsub!(/[^a-zA-Z0-9_\-\.]/, "")
+
+ # Users with the great usernames of "." or ".." would end up with a blank username.
+ # Work around that by setting their username to "blank", followed by a counter.
+ path = "blank" if path.blank?
+
+ counter = 0
+ base = path
+ while Namespace.find_by_path_or_name(path)
+ counter += 1
+ path = "#{base}#{counter}"
+ end
+
+ path
+ end
+ end
+ end
+
+ def up
+ changed_paths = {}
+
+ select_all("SELECT id, username FROM users WHERE username LIKE '%.'").each do |user|
+ username_was = user["username"]
+ username = Namespace.clean_path(username_was)
+ changed_paths[username_was] = username
+
+ username = quote_string(username)
+ execute "UPDATE users SET username = '#{username}' WHERE id = #{user["id"]}"
+ execute "UPDATE namespaces SET path = '#{username}', name = '#{username}' WHERE type IS NULL AND owner_id = #{user["id"]}"
+ end
+
+ select_all("SELECT id, path FROM namespaces WHERE type = 'Group' AND path LIKE '%.'").each do |group|
+ path_was = group["path"]
+ path = Namespace.clean_path(path_was)
+ changed_paths[path_was] = path
+
+ path = quote_string(path)
+ execute "UPDATE namespaces SET path = '#{path}' WHERE id = #{group["id"]}"
+ end
+
+ changed_paths.each do |path_was, path|
+ # Don't attempt to move if original path only contains periods.
+ next if path_was =~ /\A\.+\z/
+
+ if gitlab_shell.mv_namespace(path_was, path)
+ # If repositories moved successfully we need to remove old satellites
+ # and send update instructions to users.
+ # However we cannot allow rollback since we moved namespace dir
+ # So we basically we mute exceptions in next actions
+ begin
+ gitlab_shell.rm_satellites(path_was)
+ # We cannot send update instructions since models and mailers
+ # can't safely be used from migrations as they may be written for
+ # later versions of the database.
+ # send_update_instructions
+ rescue
+ # Returning false does not rollback after_* transaction but gives
+ # us information about failing some of tasks
+ false
+ end
+ else
+ # if we cannot move namespace directory we should rollback
+ # db changes in order to prevent out of sync between db and fs
+ raise Exception.new('namespace directory cannot be moved')
+ end
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2b7e27e3a31..6db7e386c86 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150417122318) do
+ActiveRecord::Schema.define(version: 20150421120000) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb
index 9aeed5e6939..0571574aa4f 100644
--- a/lib/gitlab/regex.rb
+++ b/lib/gitlab/regex.rb
@@ -2,7 +2,7 @@ module Gitlab
module Regex
extend self
- NAMESPACE_REGEX_STR = '(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*)'.freeze
+ NAMESPACE_REGEX_STR = '(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])'.freeze
def namespace_regex
@namespace_regex ||= /\A#{NAMESPACE_REGEX_STR}\z/.freeze
@@ -10,7 +10,7 @@ module Gitlab
def namespace_regex_message
"can contain only letters, digits, '_', '-' and '.'. " \
- "Cannot start with '-'." \
+ "Cannot start with '-' or end in '.'." \
end