diff options
50 files changed, 228 insertions, 168 deletions
diff --git a/.gitignore b/.gitignore index d47e3bd499e..7e621d260fc 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ config/database.yml config/initializers/omniauth.rb config/unicorn.rb config/resque.yml +config/aws.yml db/data.yml .idea .DS_Store diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 5aaea50cf21..d789f54a4e6 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -49,6 +49,10 @@ $ -> # Bottom tooltip $('.has_bottom_tooltip').tooltip(placement: 'bottom') + # Form submitter + $('.trigger-submit').on 'change', -> + $(@).parents('form').submit() + # Flash if (flash = $("#flash-container")).length > 0 flash.click -> $(@).slideUp("slow") diff --git a/app/assets/stylesheets/gitlab_bootstrap/mixins.scss b/app/assets/stylesheets/gitlab_bootstrap/mixins.scss index 9b1e2f2c728..c8cc9a70678 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/mixins.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/mixins.scss @@ -63,7 +63,7 @@ color: $style_color; text-shadow: 0 1px 1px #FFF; font-family: 'Yanone', sans-serif; - font-size: 26px; - line-height: 42px; + font-size: 24px; + line-height: 36px; font-weight: normal; } diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss index 8b93287ed1e..a389a9baa84 100644 --- a/app/assets/stylesheets/sections/commits.scss +++ b/app/assets/stylesheets/sections/commits.scss @@ -29,7 +29,7 @@ a{ color: $style_color; } - + > span { font-family: $monospace_font; font-size: 14px; @@ -124,7 +124,7 @@ .wrap{ display: inline-block; } - + .frame { display: inline-block; background-color: #fff; @@ -149,7 +149,7 @@ .view.swipe{ position: relative; - + .swipe-frame{ display: block; margin: auto; @@ -228,7 +228,7 @@ bottom: 0px; left: 50%; margin-left: -150px; - + .drag-track{ display: block; position: absolute; @@ -237,7 +237,7 @@ width: 276px; background: url('onion_skin_sprites.gif') -4px -20px repeat-x; } - + .dragger { display: block; position: absolute; @@ -248,7 +248,7 @@ background: url('onion_skin_sprites.gif') 0px -34px repeat-x; cursor: pointer; } - + .transparent { display: block; position: absolute; @@ -258,7 +258,7 @@ width: 10px; background: url('onion_skin_sprites.gif') -2px 0px no-repeat; } - + .opaque { display: block; position: absolute; @@ -275,19 +275,19 @@ padding: 10px; text-align: center; - + background-image: -webkit-gradient(linear, 0 0, 0 30, color-stop(0.066, #eee), to(#dfdfdf)); background-image: -webkit-linear-gradient(#eee 6.6%, #dfdfdf); background-image: -moz-linear-gradient(#eee 6.6%, #dfdfdf); background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf); - + ul, li{ list-style: none; margin: 0; padding: 0; display: inline-block; } - + li{ color: grey; border-left: 1px solid #c1c1c1; @@ -322,12 +322,12 @@ } .commit-author, .commit-committer{ display: block; - color: #999; - font-weight: normal; + color: #999; + font-weight: normal; font-style: italic; } .commit-author strong, .commit-committer strong{ - font-weight: bold; + font-weight: bold; font-style: normal; } @@ -337,7 +337,6 @@ */ .commit { .browse_code_link_holder { - @extend .span2; float: right; } diff --git a/app/assets/stylesheets/sections/header.scss b/app/assets/stylesheets/sections/header.scss index 5fe18131828..05c077a867a 100644 --- a/app/assets/stylesheets/sections/header.scss +++ b/app/assets/stylesheets/sections/header.scss @@ -5,15 +5,16 @@ header { &.navbar-gitlab { .navbar-inner { - height: 45px; - padding: 5px; + height: 40px; + padding: 3px; background: #F1F1F1; + filter: none; .nav > li > a { color: $style_color; text-shadow: 0 1px 0 #fff; - font-size: 18px; - padding: 12px; + font-size: 16px; + padding: 10px; } /** NAV block with links and profile **/ @@ -25,7 +26,6 @@ header { } z-index: 10; - /*height: 60px;*/ /** * @@ -34,7 +34,7 @@ header { */ .app_logo { float: left; - margin-right: 15px; + margin-right: 9px; position: relative; top: -5px; padding-top: 5px; @@ -42,10 +42,10 @@ header { a { float: left; padding: 0px; - margin: 0 10px; + margin: 0 6px; h1 { - background: url('logo_dark.png') no-repeat 0px 2px; + background: url('logo_dark.png') no-repeat center 1px; float: left; height: 40px; width: 40px; @@ -79,7 +79,6 @@ header { .search { margin-right: 45px; margin-left: 10px; - margin-top: 2px; .search-input { @extend .span2; @@ -105,7 +104,7 @@ header { .account-box { position: absolute; right: 0; - top: 6px; + top: 4px; z-index: 10000; width: 128px; font-size: 11px; @@ -228,6 +227,7 @@ header { .search-input { background-color: #D2D5DA; background-color: rgba(255, 255, 255, 0.5); + border: 1px solid #AAA; &:focus { background-color: white; @@ -240,13 +240,16 @@ header { .app_logo { a { h1 { - background: url('logo_white.png') no-repeat center center; + background: url('logo_white.png') no-repeat center 1px; color: #fff; text-shadow: 0 1px 1px #111; } } } .project_name { + a { + color: #FFF; + } color: #fff; text-shadow: 0 1px 1px #111; } @@ -261,11 +264,11 @@ header { .separator { float: left; - height: 60px; + height: 46px; width: 1px; background: white; border-left: 1px solid #DDD; - margin-top: -10px; + margin-top: -3px; margin-left: 10px; margin-right: 10px; } diff --git a/app/assets/stylesheets/themes/ui_mars.scss b/app/assets/stylesheets/themes/ui_mars.scss index 0a78c5c09f5..a2b8c21ea11 100644 --- a/app/assets/stylesheets/themes/ui_mars.scss +++ b/app/assets/stylesheets/themes/ui_mars.scss @@ -8,66 +8,27 @@ * */ .ui_mars { - /* * Application Header * */ header { - + @extend .header-dark; &.navbar-gitlab { .navbar-inner { - background: #474D57 url('bg-header.png') repeat-x bottom; - border-bottom: 1px solid #444; - - .nav > li > a { - color: #eee; - text-shadow: 0 1px 0 #444; + background: #474D57; + border-bottom: 1px solid #373D47; + .app_logo { + &:hover { + background-color: #373D47; + } } } } - .search { - float: right; - margin-right: 45px; - .search-input { - border: 1px solid rgba(0, 0, 0, 0.7); - background-color: #D2D5DA; - background-color: rgba(255, 255, 255, 0.5); - - &:focus { - background-color: white; - } - } - } - .search-input::-webkit-input-placeholder { - color: #666; - } - .app_logo { - a { - h1 { - background: url('logo_white.png') no-repeat center center; - color: #eee; - text-shadow: 0 1px 1px #111; - } - } - &:hover { - background-color: #41464e; - } - } - .project_name { - color: #eee; - text-shadow: 0 1px 1px #111; + .separator { + background: #31363E; + border-left: 1px solid #666; } } - - .separator { - background: #31363E; - border-left: 1px solid #666; - } - - /* - * End of Application Header - * - */ } diff --git a/app/contexts/projects/create_context.rb b/app/contexts/projects/create_context.rb index 629c5294754..fe8dde8c954 100644 --- a/app/contexts/projects/create_context.rb +++ b/app/contexts/projects/create_context.rb @@ -38,6 +38,8 @@ module Projects if @project.valid? && @project.import_url.present? shell = Gitlab::Shell.new if shell.import_repository(@project.path_with_namespace, @project.import_url) + # We should create satellite for imported repo + @project.satellite.create unless @project.satellite.exists? true else @project.errors.add(:import_url, 'cannot clone repo') diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb new file mode 100644 index 00000000000..3cd2e77322c --- /dev/null +++ b/app/controllers/files_controller.rb @@ -0,0 +1,13 @@ +class FilesController < ApplicationController + def download + note = Note.find(params[:id]) + + if can?(current_user, :read_project, note.project) + uploader = note.attachment + send_file uploader.file.path, disposition: 'attachment' + else + not_found! + end + end +end + diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 1d1efb16f04..051a6664519 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -51,7 +51,9 @@ class ProfilesController < ApplicationController end def update_username - @user.update_attributes(username: params[:user][:username]) + if @user.can_change_username? + @user.update_attributes(username: params[:user][:username]) + end respond_to do |format| format.js diff --git a/app/controllers/teams/members_controller.rb b/app/controllers/teams/members_controller.rb index db218b8ca5e..ead62e13afa 100644 --- a/app/controllers/teams/members_controller.rb +++ b/app/controllers/teams/members_controller.rb @@ -27,7 +27,13 @@ class Teams::MembersController < Teams::ApplicationController end def update - options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]} + member_params = params[:team_member] + + options = { + default_projects_access: member_params[:permission], + group_admin: member_params[:group_admin] + } + if user_team.update_membership(team_member, options) redirect_to team_members_path(user_team), notice: "Membership for #{team_member.name} was successfully updated in Team of users." else @@ -45,5 +51,4 @@ class Teams::MembersController < Teams::ApplicationController def team_member @member ||= user_team.members.find_by_username(params[:id]) end - end diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index ef66b77e232..4861892d36e 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -9,13 +9,11 @@ class TeamsController < ApplicationController layout 'user_team', except: [:new, :create] def show - user_team projects @events = Event.in_projects(user_team.project_ids).limit(20).offset(params[:offset] || 0) end def edit - user_team end def update @@ -41,6 +39,9 @@ class TeamsController < ApplicationController @team.path = @team.name.dup.parameterize if @team.name if @team.save + # Add current user as Master to the team + @team.add_members([current_user.id], UsersProject::MASTER, true) + redirect_to team_path(@team) else render action: :new diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 196105f0119..d02130c5eb1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -73,8 +73,8 @@ module ApplicationHelper def search_autocomplete_source projects = current_user.authorized_projects.map { |p| { label: "project: #{p.name_with_namespace}", url: project_path(p) } } - groups = current_user.authorized_groups.map { |group| { label: "group: #{group.name}", url: group_path(group) } } - teams = current_user.authorized_teams.map { |team| { label: "team: #{team.name}", url: team_path(team) } } + groups = current_user.authorized_groups.map { |group| { label: "group: #{simple_sanitize(group.name)}", url: group_path(group) } } + teams = current_user.authorized_teams.map { |team| { label: "team: #{simple_sanitize(team.name)}", url: team_path(team) } } default_nav = [ { label: "My Profile", url: profile_path }, @@ -159,8 +159,13 @@ module ApplicationHelper alt: "Sign in with #{provider.to_s.titleize}") end + def simple_sanitize str + sanitize(str, tags: %w(a span)) + end + def image_url(source) root_url + path_to_image(source) end + alias_method :url_to_image, :image_url end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 05303e86ae8..8225014a2a3 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -56,7 +56,7 @@ module ProjectsHelper def project_title project if project.group content_tag :span do - link_to(project.group.name, group_path(project.group)) + " / " + project.name + link_to(simple_sanitize(project.group.name), group_path(project.group)) + " / " + project.name end else project.name diff --git a/app/models/ability.rb b/app/models/ability.rb index 6d087a959a9..6fda2e52c7c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -123,7 +123,7 @@ class Ability def user_team_abilities user, team rules = [] - # Only group owner and administrators can manage group + # Only group owner and administrators can manage team if team.owner == user || team.admin?(user) || user.admin? rules << [ :manage_user_team ] end diff --git a/app/models/key.rb b/app/models/key.rb index 895e8d6cb9c..edb0bcd61fd 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -35,7 +35,7 @@ class Key < ActiveRecord::Base def fingerprintable_key return true unless key # Don't test if there is no key. - # `ssh-keygen -lf /dev/stdin <<< "#{key}"` errors with: redirection unexpected + file = Tempfile.new('key_file') begin file.puts key @@ -45,7 +45,7 @@ class Key < ActiveRecord::Base file.close file.unlink # deletes the temp file end - errors.add(:key, "can't be fingerprinted") if fingerprint_output.match("failed") + errors.add(:key, "can't be fingerprinted") if $?.exitstatus != 0 end def set_identifier diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 4e157839369..385fa291b48 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -17,11 +17,15 @@ class Namespace < ActiveRecord::Base has_many :projects, dependent: :destroy belongs_to :owner, class_name: "User" - validates :name, presence: true, uniqueness: true + validates :owner, presence: true + validates :name, presence: true, uniqueness: true, + length: { within: 0..255 }, + format: { with: Gitlab::Regex.name_regex, + message: "only letters, digits, spaces & '_' '-' '.' allowed." } + validates :path, uniqueness: true, presence: true, length: { within: 1..255 }, format: { with: Gitlab::Regex.path_regex, message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } - validates :owner, presence: true delegate :name, to: :owner, allow_nil: true, prefix: true diff --git a/app/models/repository.rb b/app/models/repository.rb index 8bcafbacda1..a5ca5533e08 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -132,9 +132,9 @@ class Repository return nil unless commit # Build file path - file_name = self.path_with_namespace + "-" + commit.id.to_s + ".tar.gz" + file_name = self.path_with_namespace.gsub("/","_") + "-" + commit.id.to_s + ".tar.gz" storage_path = Rails.root.join("tmp", "repositories") - file_path = File.join(storage_path, file_name) + file_path = File.join(storage_path, self.path_with_namespace, file_name) # Put files into a directory before archiving prefix = self.path_with_namespace + "/" diff --git a/app/models/user.rb b/app/models/user.rb index 10af9b8c165..a42671ea1c7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -234,8 +234,12 @@ class User < ActiveRecord::Base keys.count == 0 end + def can_change_username? + Gitlab.config.gitlab.username_changing_enabled + end + def can_create_project? - projects_limit > personal_projects.count + projects_limit > owned_projects.count end def can_create_group? diff --git a/app/models/user_team.rb b/app/models/user_team.rb index dc8cf9eeb22..2f3091c2353 100644 --- a/app/models/user_team.rb +++ b/app/models/user_team.rb @@ -21,8 +21,11 @@ class UserTeam < ActiveRecord::Base has_many :projects, through: :user_team_project_relationships has_many :members, through: :user_team_user_relationships, source: :user - validates :name, presence: true, uniqueness: true validates :owner, presence: true + validates :name, presence: true, uniqueness: true, + length: { within: 0..255 }, + format: { with: Gitlab::Regex.name_regex, + message: "only letters, digits, spaces & '_' '-' '.' allowed." } validates :path, uniqueness: true, presence: true, length: { within: 1..255 }, format: { with: Gitlab::Regex.path_regex, message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } diff --git a/app/uploaders/attachment_uploader.rb b/app/uploaders/attachment_uploader.rb index 3dbf2860bd4..200700b8810 100644 --- a/app/uploaders/attachment_uploader.rb +++ b/app/uploaders/attachment_uploader.rb @@ -19,4 +19,12 @@ class AttachmentUploader < CarrierWave::Uploader::Base rescue false end + + def secure_url + if self.class.storage == CarrierWave::Storage::File + "/files/#{model.class.to_s.underscore}/#{model.id}/#{file.filename}" + else + url + end + end end diff --git a/app/views/admin/groups/index.html.haml b/app/views/admin/groups/index.html.haml index 25ce66575bf..6d5a293ef7f 100644 --- a/app/views/admin/groups/index.html.haml +++ b/app/views/admin/groups/index.html.haml @@ -28,7 +28,7 @@ %td= group.path %td= group.projects.count %td - = link_to group.owner_name, admin_user_path(group.owner_id) + = link_to group.owner_name, admin_user_path(group.owner) %td.bgred = link_to 'Rename', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn btn-small" = link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove" diff --git a/app/views/admin/teams/index.html.haml b/app/views/admin/teams/index.html.haml index 1f2f4763f76..bb0487d43e9 100644 --- a/app/views/admin/teams/index.html.haml +++ b/app/views/admin/teams/index.html.haml @@ -30,7 +30,7 @@ %td= team.projects.count %td= team.members.count %td - = link_to team.owner.name, admin_user_path(team.owner_id) + = link_to team.owner.name, admin_user_path(team.owner) %td.bgred = link_to 'Rename', edit_admin_team_path(team), id: "edit_#{dom_id(team)}", class: "btn btn-small" = link_to 'Destroy', admin_team_path(team), confirm: "REMOVE #{team.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove" diff --git a/app/views/commits/_commit.html.haml b/app/views/commits/_commit.html.haml index eb0312d01e1..66307927db6 100644 --- a/app/views/commits/_commit.html.haml +++ b/app/views/commits/_commit.html.haml @@ -6,7 +6,7 @@ = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" = commit.author_link avatar: true, size: 24 - = link_to_gfm truncate(commit.title, length: 50), project_commit_path(@project, commit.id), class: "row_title" + = link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "row_title" %span.committed_ago = time_ago_in_words(commit.committed_date) diff --git a/app/views/events/event/_note.html.haml b/app/views/events/event/_note.html.haml index 20c3b927067..19665ce0aea 100644 --- a/app/views/events/event/_note.html.haml +++ b/app/views/events/event/_note.html.haml @@ -26,7 +26,7 @@ = markdown truncate(event.target.note, length: 70) - note = event.target - if note.attachment.url - = link_to note.attachment.url, target: "_blank", class: 'note-file-attach' do + = link_to note.attachment.secure_url, target: "_blank", class: 'note-file-attach' do - if note.attachment.image? = image_tag note.attachment.url, class: 'note-image-attach' - else diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index 1a4411c8f30..879a19fdfb4 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -1,8 +1,8 @@ %h3.page_title GITLAB .pull-right - %span= Gitlab::Version - %small= Gitlab::Revision + %span= Gitlab::VERSION + %small= Gitlab::REVISION %hr %p.lead Self Hosted Git Management diff --git a/app/views/notes/_note.html.haml b/app/views/notes/_note.html.haml index 4d3007a0ed1..b355e2a0bd4 100644 --- a/app/views/notes/_note.html.haml +++ b/app/views/notes/_note.html.haml @@ -31,7 +31,7 @@ - if note.attachment.image? = image_tag note.attachment.url, class: 'note-image-attach' .attachment.pull-right - = link_to note.attachment.url, target: "_blank" do + = link_to note.attachment.secure_url, target: "_blank" do %i.icon-paper-clip = note.attachment_identifier .clear diff --git a/app/views/profiles/account.html.haml b/app/views/profiles/account.html.haml index 5465d1f96e9..5b6c298df4a 100644 --- a/app/views/profiles/account.html.haml +++ b/app/views/profiles/account.html.haml @@ -53,29 +53,30 @@ -%fieldset.update-username - %legend - Username - %small.cred.pull-right - Changing your username can have unintended side effects! - = form_for @user, url: update_username_profile_path, method: :put, remote: true do |f| - .padded - = f.label :username - .input - = f.text_field :username, required: true - - %span.loading-gif.hide= image_tag "ajax_loader.gif" - %span.update-success.cgreen.hide - %i.icon-ok - Saved - %span.update-failed.cred.hide - %i.icon-remove - Failed - %ul.cred - %li It will change web url for personal projects. - %li It will change the git path to repositories for personal projects. - .input - = f.submit 'Save username', class: "btn btn-save" +- if current_user.can_change_username? + %fieldset.update-username + %legend + Username + %small.cred.pull-right + Changing your username can have unintended side effects! + = form_for @user, url: update_username_profile_path, method: :put, remote: true do |f| + .padded + = f.label :username + .input + = f.text_field :username, required: true + + %span.loading-gif.hide= image_tag "ajax_loader.gif" + %span.update-success.cgreen.hide + %i.icon-ok + Saved + %span.update-failed.cred.hide + %i.icon-remove + Failed + %ul.cred + %li It will change web url for personal projects. + %li It will change the git path to repositories for personal projects. + .input + = f.submit 'Save username', class: "btn btn-save" - if Gitlab.config.gitlab.signup_enabled %fieldset.remove-account @@ -83,4 +84,4 @@ Remove account %small.cred.pull-right Before removing the account you must remove all projects! - = link_to 'Delete account', user_registration_path, confirm: "REMOVE #{current_user.name}? Are you sure?", method: :delete, class: "btn btn-remove delete-key btn-small pull-right"
\ No newline at end of file + = link_to 'Delete account', user_registration_path, confirm: "REMOVE #{current_user.name}? Are you sure?", method: :delete, class: "btn btn-remove delete-key btn-small pull-right" diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 3cf6330cc3c..9cab3ba5252 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -77,7 +77,7 @@ %legend Personal projects: %small.pull-right - %span= current_user.personal_projects.count + %span= current_user.owned_projects.count of %span= current_user.projects_limit .padded diff --git a/app/views/projects/_new_form.html.haml b/app/views/projects/_new_form.html.haml index ba3ccc421cd..b6503636890 100644 --- a/app/views/projects/_new_form.html.haml +++ b/app/views/projects/_new_form.html.haml @@ -28,7 +28,7 @@ .input = f.text_field :import_url, class: 'xlarge', placeholder: 'https://github.com/randx/six.git' .light - URL should be clonable + URL must be clonable %p.padded New projects are private by default. You choose who can see the project and commit to repository. diff --git a/app/views/projects/files.html.haml b/app/views/projects/files.html.haml index d108308318e..36948eff658 100644 --- a/app/views/projects/files.html.haml +++ b/app/views/projects/files.html.haml @@ -9,7 +9,7 @@ - @notes.each do |note| %tr %td - %a{href: note.attachment.url} + = link_to note.attachment.secure_url, target: "_blank" do = image_tag gravatar_icon(note.author_email), class: "avatar s24" = note.attachment_identifier %td diff --git a/app/views/teams/members/_show.html.haml b/app/views/teams/members/_show.html.haml index 6cddb8e4826..94d2fd50fe8 100644 --- a/app/views/teams/members/_show.html.haml +++ b/app/views/teams/members/_show.html.haml @@ -10,22 +10,21 @@ %br %small.cgray= user.email - .span6.pull-right + .span4 - if allow_admin - .left.span2 - = form_for(member, as: :team_member, url: team_member_path(@team, user)) do |f| - = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium project-access-select span2" - .left.span2 - %span - = check_box_tag :group_admin, true, @team.admin?(user) - Admin access - .pull-right - - if current_user == user - %span.btn.disabled This is you! - - if @team.owner == user - %span.btn.disabled.btn-success Owner - - elsif user.blocked - %span.btn.disabled.blocked Blocked - - elsif allow_admin - = link_to team_member_path(@team, user), confirm: remove_from_user_team_message(@team, user), method: :delete, class: "btn-tiny btn btn-remove" do - %i.icon-minus.icon-white + = form_for(member, as: :team_member, url: team_member_path(@team, user)) do |f| + = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium trigger-submit" + %br + = label_tag do + = f.check_box :group_admin, class: 'trigger-submit' + %span Admin access + .pull-right + - if current_user == user + %span.btn.disabled This is you! + - if @team.owner == user + %span.btn.disabled Owner + - elsif user.blocked + %span.btn.disabled.blocked Blocked + - elsif allow_admin + = link_to team_member_path(@team, user), confirm: remove_from_user_team_message(@team, user), method: :delete, class: "btn-tiny btn btn-remove" do + %i.icon-minus.icon-white diff --git a/app/views/teams/new.html.haml b/app/views/teams/new.html.haml index 38f61c11c0c..7089f791558 100644 --- a/app/views/teams/new.html.haml +++ b/app/views/teams/new.html.haml @@ -17,3 +17,17 @@ %li All created teams are public (users can view who enter into team and which project are assigned for this team) %li People within a team see only projects they have access to %li You will be able to assign existing projects for team + %hr + + - if current_user.can_create_group? + .clearfix + .input.light + Need a group for several dependent projects? + = link_to new_group_path, class: "btn btn-tiny" do + Create a group + - if current_user.can_create_project? + .clearfix + .input.light + Want to create a project? + = link_to new_project_path, class: "btn btn-tiny" do + Create a project diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 44154456430..62761c80cbb 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -35,6 +35,7 @@ production: &base ## Project settings default_projects_limit: 10 # signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled. + # username_changing_enabled: false # default: true - User can change her username/namespace ## Gravatar gravatar: diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index b3fba99ebf3..f7d18e67148 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -57,6 +57,7 @@ Settings.gitlab['support_email'] ||= Settings.gitlab.email_from Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url) Settings.gitlab['user'] ||= 'git' Settings.gitlab['signup_enabled'] ||= false +Settings.gitlab['username_changing_enabled'] = true if Settings.gitlab['username_changing_enabled'].nil? # # Gravatar diff --git a/config/initializers/2_app.rb b/config/initializers/2_app.rb index 748f15a11d9..27a0c0ffeb2 100644 --- a/config/initializers/2_app.rb +++ b/config/initializers/2_app.rb @@ -1,6 +1,6 @@ module Gitlab - Version = File.read(Rails.root.join("VERSION")) - Revision = `git log --pretty=format:'%h' -n 1` + VERSION = File.read(Rails.root.join("VERSION")).strip + REVISION = `git log --pretty=format:'%h' -n 1` def self.config Settings diff --git a/config/routes.rb b/config/routes.rb index 88667db130e..7537a11de96 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,6 +46,11 @@ Gitlab::Application.routes.draw do end # + # Attachments serving + # + get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename: /[a-zA-Z.0-9_\-\+]+/ } + + # # Admin Area # namespace :admin do diff --git a/features/steps/profile/profile_ssh_keys.rb b/features/steps/profile/profile_ssh_keys.rb index 8ae1fa91025..fbb92077f0a 100644 --- a/features/steps/profile/profile_ssh_keys.rb +++ b/features/steps/profile/profile_ssh_keys.rb @@ -43,6 +43,6 @@ class ProfileSshKeys < Spinach::FeatureSteps end And 'I have ssh key "ssh-rsa Work"' do - create(:key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work") + create(:key, :user => @user, :title => "ssh-rsa Work", :key => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+L3TbFegm3k8QjejSwemk4HhlRh+DuN679Pc5ckqE/MPhVtE/+kZQDYCTB284GiT2aIoGzmZ8ee9TkaoejAsBwlA+Wz2Q3vhz65X6sMgalRwpdJx8kSEUYV8ZPV3MZvPo8KdNg993o4jL6G36GDW4BPIyO6FPZhfsawdf6liVD0Xo5kibIK7B9VoE178cdLQtLpS2YolRwf5yy6XR6hbbBGQR+6xrGOdP16eGZDb1CE2bMvvJijjloFqPscGktWOqW+nfh5txwFfBzlfARDTBsS8WZtg3Yoj1kn33kPsWRlgHfNutFRAIynDuDdQzQq8tTtVwm+Yi75RfcPHW8y3P Work") end end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index c1873d87b55..2cd8aa6c265 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -20,7 +20,7 @@ module Gitlab class Project < Grape::Entity expose :id, :name, :description, :default_branch expose :owner, using: Entities::UserBasic - expose :private_flag, as: :private + expose :public, as: :private expose :path, :path_with_namespace expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :created_at expose :namespace diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 3e5e3a478ba..5d74a761c05 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -40,7 +40,9 @@ module Gitlab get "/check" do { - api_version: '3' + api_version: Gitlab::API.version, + gitlab_version: Gitlab::VERSION, + gitlab_rev: Gitlab::REVISION, } end end diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb index b7b92e86a87..9ea08ccbdbf 100644 --- a/lib/gitlab/backend/shell.rb +++ b/lib/gitlab/backend/shell.rb @@ -10,7 +10,7 @@ module Gitlab # add_repository("gitlab/gitlab-ci") # def add_repository(name) - system("/home/git/gitlab-shell/bin/gitlab-projects add-project #{name}.git") + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects add-project #{name}.git") end # Import repository @@ -21,7 +21,7 @@ module Gitlab # import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git") # def import_repository(name, url) - system("/home/git/gitlab-shell/bin/gitlab-projects import-project #{name}.git #{url}") + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects import-project #{name}.git #{url}") end # Remove repository from file system @@ -32,7 +32,7 @@ module Gitlab # remove_repository("gitlab/gitlab-ci") # def remove_repository(name) - system("/home/git/gitlab-shell/bin/gitlab-projects rm-project #{name}.git") + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects rm-project #{name}.git") end # Add new key to gitlab-shell @@ -41,7 +41,7 @@ module Gitlab # add_key("key-42", "sha-rsa ...") # def add_key(key_id, key_content) - system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"") + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"") end # Remove ssh key from gitlab shell @@ -50,11 +50,16 @@ module Gitlab # remove_key("key-342", "sha-rsa ...") # def remove_key(key_id, key_content) - system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"") + system("#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"") end def url_to_repo path Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" end + + def gitlab_shell_user_home + File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") + end + end end diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 483042205ea..5eeb7c80184 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -10,6 +10,10 @@ module Gitlab /\A[a-zA-Z][a-zA-Z0-9_\-\. ]*\z/ end + def name_regex + /\A[a-zA-Z0-9_\-\. ]*\z/ + end + def path_regex default_regex end diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake index c44016ef6e8..091de6ee6d5 100644 --- a/lib/tasks/gitlab/info.rake +++ b/lib/tasks/gitlab/info.rake @@ -40,8 +40,8 @@ namespace :gitlab do puts "" puts "GitLab information".yellow - puts "Version:\t#{Gitlab::Version}" - puts "Revision:\t#{Gitlab::Revision}" + puts "Version:\t#{Gitlab::VERSION}" + puts "Revision:\t#{Gitlab::REVISION}" puts "Directory:\t#{Rails.root}" puts "DB Adapter:\t#{database_adapter}" puts "URL:\t\t#{Gitlab.config.gitlab.url}" diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake index bc0742564d0..8d4950cf396 100644 --- a/lib/tasks/gitlab/setup.rake +++ b/lib/tasks/gitlab/setup.rake @@ -1,10 +1,10 @@ namespace :gitlab do desc "GITLAB | Setup production application" task :setup => :environment do - setup + setup_db end - def setup + def setup_db warn_user_is_not_gitlab puts "This will create the necessary database tables and seed the database." diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake index 0ab8df1d094..ec5451dd47c 100644 --- a/lib/tasks/gitlab/shell.rake +++ b/lib/tasks/gitlab/shell.rake @@ -25,12 +25,13 @@ namespace :gitlab do def setup warn_user_is_not_gitlab + gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys') puts "This will rebuild an authorized_keys file." - puts "You will lose any data stored in /home/git/.ssh/authorized_keys." + puts "You will lose any data stored in #{gitlab_shell_authorized_keys}." ask_to_continue puts "" - system("echo '# Managed by gitlab-shell' > /home/git/.ssh/authorized_keys") + system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}") Key.find_each(batch_size: 1000) do |key| if Gitlab::Shell.new.add_key(key.shell_id, key.key) diff --git a/lib/tasks/gitlab/task_helpers.rake b/lib/tasks/gitlab/task_helpers.rake index d494125f76c..cb4e34cc0d7 100644 --- a/lib/tasks/gitlab/task_helpers.rake +++ b/lib/tasks/gitlab/task_helpers.rake @@ -77,8 +77,7 @@ namespace :gitlab do end def gid_for(group_name) - group_line = File.read("/etc/group").lines.select{|l| l.start_with?("#{group_name}:")}.first - group_line.split(":")[2].to_i + Etc.getgrnam(group_name).gid end def warn_user_is_not_gitlab diff --git a/public/deploy.html b/public/deploy.html index d8c287809ea..d9c4bb5c583 100644 --- a/public/deploy.html +++ b/public/deploy.html @@ -5,7 +5,7 @@ <link href="/static.css" media="screen" rel="stylesheet" type="text/css" /> </head> <body> - <h1>Deploy in progress</h1> + <h1><center><img src="/gitlab_logo.png"/></center>Deploy in progress</h1> <h3>Please try again in few minutes or contact your administrator.</h3> </body> </html> diff --git a/public/gitlab_logo.png b/public/gitlab_logo.png Binary files differnew file mode 100644 index 00000000000..e3cda5978ab --- /dev/null +++ b/public/gitlab_logo.png diff --git a/spec/factories.rb b/spec/factories.rb index d2e9f48c47b..17dbc796d8f 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -148,6 +148,12 @@ FactoryGirl.define do "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa ++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" end end + + factory :invalid_key do + key do + "ssh-rsa this_is_invalid_key==" + end + end end factory :milestone do diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb index 5ee7354688a..8360477d8fe 100644 --- a/spec/factories_spec.rb +++ b/spec/factories_spec.rb @@ -1,6 +1,9 @@ require 'spec_helper' -INVALID_FACTORIES = [:key_with_a_space_in_the_middle] +INVALID_FACTORIES = [ + :key_with_a_space_in_the_middle, + :invalid_key, +] FactoryGirl.factories.map(&:name).each do |factory_name| next if INVALID_FACTORIES.include?(factory_name) diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 94b952cf932..a9ab2f05a34 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -73,8 +73,12 @@ describe Key do build(:key, user: user).should be_valid end - it "rejects the unfingerprintable key" do + it "rejects the unfingerprintable key (contains space in middle)" do build(:key_with_a_space_in_the_middle).should_not be_valid end + + it "rejects the unfingerprintable key (not a key)" do + build(:invalid_key).should_not be_valid + end end end |