Commit 0a94640e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'refactoring/backend'

parents e6c0673e de6fa5dd
...@@ -24,3 +24,4 @@ db/data.yml ...@@ -24,3 +24,4 @@ db/data.yml
.DS_Store .DS_Store
.chef .chef
vendor/bundle/* vendor/bundle/*
rails_best_practices_output.html
...@@ -8,7 +8,7 @@ branches: ...@@ -8,7 +8,7 @@ branches:
only: only:
- 'master' - 'master'
rvm: rvm:
- 1.9.3 - 1.9.2
services: services:
- mysql - mysql
- postgresql - postgresql
......
...@@ -123,6 +123,8 @@ group :development do ...@@ -123,6 +123,8 @@ group :development do
gem 'better_errors' gem 'better_errors'
gem 'binding_of_caller' gem 'binding_of_caller'
gem 'rails_best_practices'
# Docs generator # Docs generator
gem "sdoc" gem "sdoc"
end end
......
...@@ -132,6 +132,8 @@ GEM ...@@ -132,6 +132,8 @@ GEM
chosen-rails (0.9.8) chosen-rails (0.9.8)
railties (~> 3.0) railties (~> 3.0)
thor (~> 0.14) thor (~> 0.14)
code_analyzer (0.3.1)
sexp_processor
coderay (1.0.8) coderay (1.0.8)
coffee-rails (3.2.2) coffee-rails (3.2.2)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
...@@ -302,6 +304,7 @@ GEM ...@@ -302,6 +304,7 @@ GEM
pg (0.14.1) pg (0.14.1)
polyglot (0.3.3) polyglot (0.3.3)
posix-spawn (0.3.6) posix-spawn (0.3.6)
progressbar (0.12.0)
pry (0.9.10) pry (0.9.10)
coderay (~> 1.0.5) coderay (~> 1.0.5)
method_source (~> 0.8) method_source (~> 0.8)
...@@ -335,6 +338,14 @@ GEM ...@@ -335,6 +338,14 @@ GEM
rails-dev-tweaks (0.6.1) rails-dev-tweaks (0.6.1)
actionpack (~> 3.1) actionpack (~> 3.1)
railties (~> 3.1) railties (~> 3.1)
rails_best_practices (1.13.2)
activesupport
awesome_print
code_analyzer
colored
erubis
i18n
progressbar
railties (3.2.9) railties (3.2.9)
actionpack (= 3.2.9) actionpack (= 3.2.9)
activesupport (= 3.2.9) activesupport (= 3.2.9)
...@@ -393,6 +404,7 @@ GEM ...@@ -393,6 +404,7 @@ GEM
multi_json (~> 1.0) multi_json (~> 1.0)
rubyzip rubyzip
settingslogic (2.0.8) settingslogic (2.0.8)
sexp_processor (4.1.3)
shoulda-matchers (1.3.0) shoulda-matchers (1.3.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
simplecov (0.7.1) simplecov (0.7.1)
...@@ -512,6 +524,7 @@ DEPENDENCIES ...@@ -512,6 +524,7 @@ DEPENDENCIES
rack-mini-profiler rack-mini-profiler
rails (= 3.2.9) rails (= 3.2.9)
rails-dev-tweaks rails-dev-tweaks
rails_best_practices
raphael-rails (= 1.5.2) raphael-rails (= 1.5.2)
rb-fsevent rb-fsevent
rb-inotify rb-inotify
......
/** /**
* =================================== * ===================================
* Contain 3 main UI block elements: * Contain UI block elements:
* .main_box - for show pages * .ui-box - for any block & widgets
* .ui-box - for simple block & widgets
* =================================== * ===================================
*/ */
/** /**
* UI box element * UI Block
* contains top, middle, bottom blocks
* *
*/ */
.main_box { .ui-box {
@extend .borders; background: #F9F9F9;
@extend .prepend-top-20; margin-bottom: 25px;
@extend .append-bottom-20; border: 1px solid #CCC;
border-width: 1px;
@include solid-shade; @include solid-shade;
&.ui-box-show {
margin:20px 0;
background: #FFF;
}
img { max-width: 100%; } img { max-width: 100%; }
...@@ -27,9 +28,9 @@ ...@@ -27,9 +28,9 @@
} }
} }
.top_box_content, .ui-box-head,
.middle_box_content, .ui-box-body,
.bottom_box_content { .ui-box-bottom {
padding: 15px; padding: 15px;
word-wrap: break-word; word-wrap: break-word;
...@@ -39,19 +40,25 @@ ...@@ -39,19 +40,25 @@
border: none; border: none;
padding: 0; padding: 0;
} }
.clearfix {
margin: 0;
}
} }
.top_box_content { .ui-box-head {
.box-title { .box-title {
color: $style_color; color: $style_color;
font-size: 18px; font-size: 18px;
font-weight: normal; font-weight: normal;
line-height: 28px; line-height: 28px;
} }
h3 {
margin: 0;
}
} }
.middle_box_content { .ui-box-body {
@include border-radius(0);
border: none; border: none;
font-size: 12px; font-size: 12px;
background-color: #f5f5f5; background-color: #f5f5f5;
...@@ -59,24 +66,9 @@ ...@@ -59,24 +66,9 @@
border-top: 1px solid #eee; border-top: 1px solid #eee;
} }
.bottom_box_content { .ui-box-bottom {
border-top: 1px solid #eee; border-top: 1px solid #eee;
} }
}
/**
* Big UI Block for show page content
*
*/
.ui-box {
background: #F9F9F9;
margin-bottom: 25px;
border: 1px solid #eaeaea;
@include border-radius(4px);
border-color: #CCC;
@include solid-shade;
&.white { &.white {
background: #fff; background: #fff;
...@@ -86,47 +78,47 @@ ...@@ -86,47 +78,47 @@
margin: 0; margin: 0;
} }
h5, .title { .title {
padding: 0 10px;
@include border-radius(4px 4px 0 0);
@include bg-gray-gradient; @include bg-gray-gradient;
border-top: 1px solid #eaeaea; border-bottom: 1px solid #CCC;
border-bottom: 1px solid #bbb; color: #456;
font-size: 16px;
text-shadow: 0 1px 1px #fff;
padding: 0px 10px;
line-height: 36px;
font-size: 14px;
font-weight: normal;
> a { > a {
text-shadow: 0 1px 1px #fff; text-shadow: 0 1px 1px #fff;
} }
&.small {
line-height: 28px;
font-size: 14px;
line-height: 28px;
text-shadow: 0 1px 1px white;
}
form { form {
padding: 9px 0; margin-bottom: 0;
margin: 0px; margin-top: 3px;
} }
.nav-pills { .nav-pills {
li { > li {
padding: 3px 0; > a {
&.active a { background-color: $style_color; } padding: 13px;
a { margin: 0;
@include border-radius(7px); font-size: 13px;
}
&.active {
> a {
background: #D5D5D5;
color: $style_color;
@include border-radius(0);
border-radius: 0;
border-left: 1px solid #CCC;
border-right: 1px solid #CCC;
}
} }
} }
} }
} }
.bottom {
@include bg-gray-gradient;
@include border-radius(0 0 4px 4px);
border-bottom: none;
border-top: 1px solid #bbb;
}
&.padded { &.padded {
h5, .title { h5, .title {
margin: -20px; margin: -20px;
...@@ -143,6 +135,7 @@ ...@@ -143,6 +135,7 @@
color: #777; color: #777;
} }
} }
.row_title { .row_title {
font-weight: bold; font-weight: bold;
color: #444; color: #444;
...@@ -151,8 +144,4 @@ ...@@ -151,8 +144,4 @@
text-decoration: underline; text-decoration: underline;
} }
} }
.ui-box-body {
padding: 10px;
}
} }
...@@ -23,14 +23,12 @@ ...@@ -23,14 +23,12 @@
border-bottom: 1px solid #ADF; border-bottom: 1px solid #ADF;
} }
&:first-child {
@include border-radius(4px 4px 0 0);
border-top: none;
}
&:last-child { &:last-child {
@include border-radius(0 0 4px 4px); border-bottom: none;
border: none;
&.bottom {
background: #f5f5f5;
}
} }
.author { color: #999; } .author { color: #999; }
......
...@@ -25,7 +25,7 @@ table { ...@@ -25,7 +25,7 @@ table {
} }
th, td { th, td {
padding: 8px; padding: 10px;
line-height: 18px; line-height: 18px;
text-align: left; text-align: left;
} }
......
.commit-box {
@extend .main_box;
.commit-head {
@extend .top_box_content;
.commit-title {
line-height: 26px;
margin: 0;
}
.commit-description {
font-size: 14px;
border: none;
background-color: white;
padding-top: 10px;
}
.browse-button {
@extend .btn;
@extend .btn-small;
float: right;
}
}
.commit-info {
@extend .middle_box_content;
@extend .clearfix;
.sha-block {
text-align: right;
&:first-child {
padding-bottom: 6px;
}
a {
border-bottom: 1px solid #aaa;
margin-left: 9px;
}
}
&.merge-commit .sha-block {
clear: right;
}
.committer {
padding-left: 32px;
}
.author a,
.committer a {
font-size: 14px;
line-height: 22px;
text-shadow: 0 1px 1px #fff;
color: #777;
&:hover {
color: #999;
}
}
.avatar {
margin-right: 10px;
}
}
}
/** /**
* *
* COMMIT SHOw * COMMIT SHOw
* *
*/ */
.commit-committer-link,
.commit-author-link {
font-size: 13px;
color: #555;
&:hover {
color: #999;
}
}
.diff_file { .diff_file {
border: 1px solid #CCC; border: 1px solid #CCC;
margin-bottom: 1em; margin-bottom: 1em;
...@@ -255,13 +198,6 @@ ...@@ -255,13 +198,6 @@
min-width: 65px; min-width: 65px;
font-family: $monospace; font-family: $monospace;
} }
.commit-author-name {
color: #777;
&:hover {
color: #999;
}
}
} }
.diff_file_header a, .diff_file_header a,
......
.issue_form_box {
@extend .main_box;
.issue_title {
@extend .top_box_content;
.clearfix {
margin-bottom: 0px;
input {
@extend .span8;
}
}
}
.issue_middle_block {
@extend .middle_box_content;
height: 30px;
.issue_assignee {
@extend .span6;
float: left;
}
.issue_milestone {
@extend .span4;
float: left;
}
}
.issue_description {
@extend .bottom_box_content;
}
}
.issues_table { .issues_table {
.issue { .issue {
padding: 7px 10px; padding: 7px 10px;
...@@ -89,31 +61,25 @@ input.check_all_issues { ...@@ -89,31 +61,25 @@ input.check_all_issues {
#issues-table-holder { #issues-table-holder {
.issues_filters { .issues_filters {
form {
padding: 0;
margin: 0;
margin-top:7px
}
} }
.issues_bulk_update { .issues_bulk_update {
margin: 0; margin: 0;
form { form {
padding: 0; float:left;
margin: 0;
margin-top:7px
} }
.update_selected_issues { .update_selected_issues {
position: relative; position: relative;
top:-2px; top:5px;
margin-left: 4px; margin-left: 4px;
float: left; float: left;
} }
.update_issues_text { .update_issues_text {
padding: 3px; padding: 3px;
line-height: 18px; line-height: 28px;
float: left; float: left;
color: #479;
} }
} }
} }
......
/**
* MR form
*
*/
.mr_branch_box {
@extend .ui-box;
margin-bottom: 20px;
.body {
background: #f1f1f1;
}
}
/** /**
* MR -> show: Automerge widget * MR -> show: Automerge widget
...@@ -121,19 +107,3 @@ li.merge_request { ...@@ -121,19 +107,3 @@ li.merge_request {
.mr_direction_tip { .mr_direction_tip {
margin-top:40px margin-top:40px
} }
.merge_requests_form_box {
@extend .main_box;
.merge_requests_middle_box {
@extend .middle_box_content;
height: 30px;
.merge_requests_assignee {
@extend .span6;
float: left;
}
.merge_requests_milestone {
@extend .span4;
float: left;
}
}
}
...@@ -8,16 +8,12 @@ ...@@ -8,16 +8,12 @@
.groups_box, .groups_box,
.projects_box { .projects_box {
> h5 { > .title {
color: $style_color; padding: 2px 15px;
font-size: 16px;
text-shadow: 0 1px 1px #fff;
padding: 2px 10px;
line-height: 32px;
font-size: 14px;
} }
.nav-projects-tabs li { padding: 0; } .nav-projects-tabs li { padding: 0; }
.well-list { .well-list {
li { padding: 15px; }
.arrow { .arrow {
float: right; float: right;
padding: 10px; padding: 10px;
...@@ -109,7 +105,7 @@ ul.nav.nav-projects-tabs { ...@@ -109,7 +105,7 @@ ul.nav.nav-projects-tabs {
li { li {
a { a {
padding: 4px 20px; padding: 6px 25px;
margin-top: 2px; margin-top: 2px;
border-color: #DDD; border-color: #DDD;
background-color: #EEE; background-color: #EEE;
......
...@@ -9,7 +9,7 @@ class CommitLoadContext < BaseContext ...@@ -9,7 +9,7 @@ class CommitLoadContext < BaseContext
status: :ok status: :ok
} }
commit = project.commit(params[:id]) commit = project.repository.commit(params[:id])
if commit if commit
commit = CommitDecorator.decorate(commit) commit = CommitDecorator.decorate(commit)
......
...@@ -9,7 +9,7 @@ module Notes ...@@ -9,7 +9,7 @@ module Notes
@notes = case target_type @notes = case target_type
when "commit" when "commit"
project.commit_notes(project.commit(target_id)).fresh.limit(20) project.commit_notes(project.repository.commit(target_id)).fresh.limit(20)
when "issue" when "issue"
project.issues.find(target_id).notes.inc_author.fresh.limit(20) project.issues.find(target_id).notes.inc_author.fresh.limit(20)
when "merge_request" when "merge_request"
...@@ -18,7 +18,7 @@ module Notes ...@@ -18,7 +18,7 @@ module Notes
project.snippets.find(target_id).notes.fresh project.snippets.find(target_id).notes.fresh
when "wall" when "wall"
# this is the only case, where the order is DESC # this is the only case, where the order is DESC
project.common_notes.order("created_at DESC, id DESC").limit(50) project.notes.common.inc_author_project.order("created_at DESC, id DESC").limit(50)
end end
@notes = if after_id @notes = if after_id
......
class TestHookContext < BaseContext class TestHookContext < BaseContext
def execute def execute
hook = project.hooks.find(params[:id]) hook = project.hooks.find(params[:id])
commits = project.commits(project.default_branch, nil, 3) commits = project.repository.commits(project.default_branch, nil, 3)
data = project.post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{project.default_branch}", current_user) data = project.post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{project.default_branch}", current_user)
hook.execute(data) hook.execute(data)
end end
......
...@@ -10,6 +10,7 @@ class Admin::ProjectsController < AdminController ...@@ -10,6 +10,7 @@ class Admin::ProjectsController < AdminController
end end
def show def show
@repository = @project.repository
@users = User.active @users = User.active
@users = @users.not_in_project(@project) if @project.users.present? @users = @users.not_in_project(@project) if @project.users.present?
@users = @users.all @users = @users.all
...@@ -19,7 +20,7 @@ class Admin::ProjectsController < AdminController ...@@ -19,7 +20,7 @@ class Admin::ProjectsController < AdminController
end end
def team_update def team_update
@project.add_users_ids_to_team(params[:user_ids], params[:project_access]) @project.team.add_users_ids(params[:user_ids], params[:project_access])
redirect_to [:admin, @project], notice: 'Project was successfully updated.' redirect_to [:admin, @project], notice: 'Project was successfully updated.'
end end
...@@ -36,7 +37,7 @@ class Admin::ProjectsController < AdminController ...@@ -36,7 +37,7 @@ class Admin::ProjectsController < AdminController
def destroy def destroy
# Delete team first in order to prevent multiple gitolite calls # Delete team first in order to prevent multiple gitolite calls
@project.truncate_team @project.team.truncate
@project.destroy @project.destroy
......
...@@ -19,9 +19,9 @@ class Admin::UsersController < AdminController ...@@ -19,9 +19,9 @@ class Admin::UsersController < AdminController
def team_update def team_update
@admin_user = User.find(params[:id]) @admin_user = User.find(params[:id])
UsersProject.user_bulk_import( UsersProject.add_users_into_projects(
@admin_user,
params[:project_ids], params[:project_ids],
[@admin_user.id],
params[:project_access] params[:project_access]
) )
......
...@@ -76,6 +76,12 @@ class ApplicationController < ActionController::Base ...@@ -76,6 +76,12 @@ class ApplicationController < ActionController::Base
end end
end end
def repository
@repository ||= project.repository
rescue Grit::NoSuchPathError
nil
end
def add_abilities def add_abilities
abilities << Ability abilities << Ability
end end
......
...@@ -9,10 +9,10 @@ class CommitsController < ProjectResourceController ...@@ -9,10 +9,10 @@ class CommitsController < ProjectResourceController
before_filter :require_non_empty_project before_filter :require_non_empty_project
def show def show
@repo = @project.repo @repo = @project.repository
@limit, @offset = (params[:limit] || 40), (params[:offset] || 0) @limit, @offset = (params[:limit] || 40), (params[:offset] || 0)
@commits = @project.commits(@ref, @path, @limit, @offset) @commits = @repo.commits(@ref, @path, @limit, @offset)
@commits = CommitDecorator.decorate(@commits) @commits = CommitDecorator.decorate(@commits)
respond_to do |format| respond_to do |format|
......
...@@ -83,12 +83,12 @@ class MergeRequestsController < ProjectResourceController ...@@ -83,12 +83,12 @@ class MergeRequestsController < ProjectResourceController
end end
def branch_from def branch_from
@commit = project.commit(params[:ref]) @commit = @repository.commit(params[:ref])
@commit = CommitDecorator.decorate(@commit) @commit = CommitDecorator.decorate(@commit)
end end
def branch_to def branch_to
@commit = project.commit(params[:ref]) @commit = @repository.commit(params[:ref])
@commit = CommitDecorator.decorate(@commit) @commit = CommitDecorator.decorate(@commit)
end end
......
class ProjectResourceController < ApplicationController class ProjectResourceController < ApplicationController
before_filter :project before_filter :project
before_filter :repository
end end
...@@ -2,6 +2,7 @@ require Rails.root.join('lib', 'gitlab', 'graph', 'json_builder') ...@@ -2,6 +2,7 @@ require Rails.root.join('lib', 'gitlab', 'graph', 'json_builder')
class ProjectsController < ProjectResourceController class ProjectsController < ProjectResourceController
skip_before_filter :project, only: [:new, :create] skip_before_filter :project, only: [:new, :create]
skip_before_filter :repository, only: [:new, :create]
# Authorize # Authorize
before_filter :authorize_read_project!, except: [:index, :new, :create] before_filter :authorize_read_project!, except: [:index, :new, :create]
...@@ -58,7 +59,7 @@ class ProjectsController < ProjectResourceController ...@@ -58,7 +59,7 @@ class ProjectsController < ProjectResourceController
respond_to do |format| respond_to do |format|
format.html do format.html do
unless @project.empty_repo? if @project.repository && !@project.repository.empty?
@last_push = current_user.recent_push(@project.id) @last_push = current_user.recent_push(@project.id)
render :show render :show
else else
......
...@@ -31,7 +31,7 @@ class RefsController < ProjectResourceController ...@@ -31,7 +31,7 @@ class RefsController < ProjectResourceController
contents = @tree.contents contents = @tree.contents
@logs = contents.map do |content| @logs = contents.map do |content|
file = params[:path] ? File.join(params[:path], content.name) : content.name file = params[:path] ? File.join(params[:path], content.name) : content.name
last_commit = @project.commits(@commit.id, file, 1).last last_commit = @repo.commits(@commit.id, file, 1).last
last_commit = CommitDecorator.decorate(last_commit) last_commit = CommitDecorator.decorate(last_commit)
{ {
file_name: content.name, file_name: content.name,
...@@ -45,10 +45,10 @@ class RefsController < ProjectResourceController ...@@ -45,10 +45,10 @@ class RefsController < ProjectResourceController
def define_tree_vars def define_tree_vars
params[:path] = nil if params[:path].blank? params[:path] = nil if params[:path].blank?
@repo = project.repo @repo = project.repository
@commit = project.commit(@ref) @commit = @repo.commit(@ref)
@commit = CommitDecorator.decorate(@commit) @commit = CommitDecorator.decorate(@commit)
@tree = Tree.new(@commit.tree, project, @ref, params[:path]) @tree = Tree.new(@commit.tree, @ref, params[:path])
@tree = TreeDecorator.new(@tree) @tree = TreeDecorator.new(@tree)
@hex_path = Digest::SHA1.hexdigest(params[:path] || "") @hex_path = Digest::SHA1.hexdigest(params[:path] || "")
......
...@@ -5,19 +5,19 @@ class RepositoriesController < ProjectResourceController ...@@ -5,19 +5,19 @@ class RepositoriesController < ProjectResourceController
before_filter :require_non_empty_project before_filter :require_non_empty_project
def show def show
@activities = @project.commits_with_refs(20) @activities = @repository.commits_with_refs(20)
end end
def branches def branches
@branches = @project.branches @branches = @repository.branches
end end
def tags def tags
@tags = @project.tags @tags = @repository.tags
end end
def stats def stats
@stats = Gitlab::GitStats.new(@project.repo, @project.root_ref) @stats = Gitlab::GitStats.new(@repository.raw, @repository.root_ref)
@graph = @stats.graph @graph = @stats.graph
end end
...@@ -27,7 +27,7 @@ class RepositoriesController < ProjectResourceController ...@@ -27,7 +27,7 @@ class RepositoriesController < ProjectResourceController
end end
file_path = @project.archive_repo(params[:ref]) file_path = @repository.archive_repo(params[:ref])
if file_path if file_path
# Send file to user # Send file to user
......
...@@ -26,7 +26,7 @@ class ServicesController < ProjectResourceController ...@@ -26,7 +26,7 @@ class ServicesController < ProjectResourceController
end end
def test def test
commits = project.commits(project.default_branch, nil, 3) commits = project.repository.commits(project.default_branch, nil, 3)
data = project.post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{project.default_branch}", current_user) data = project.post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{project.default_branch}", current_user)
@service = project.gitlab_ci_service @service = project.gitlab_ci_service
......
...@@ -16,10 +16,9 @@ class TeamMembersController < ProjectResourceController ...@@ -16,10 +16,9 @@ class TeamMembersController < ProjectResourceController
end end
def create def create
@project.add_users_ids_to_team( users = User.where(id: params[:user_ids])
params[:user_ids],
params[:project_access] @project.team << [users, params[:project_access]]
)
if params[:redirect_to] if params[:redirect_to]
redirect_to params[:redirect_to] redirect_to params[:redirect_to]
...@@ -50,7 +49,7 @@ class TeamMembersController < ProjectResourceController ...@@ -50,7 +49,7 @@ class TeamMembersController < ProjectResourceController
def apply_import def apply_import
giver = Project.find(params[:source_project_id]) giver = Project.find(params[:source_project_id])
status = UsersProject.import_team(giver, project) status = @project.team.import(giver)
notice = status ? "Succesfully imported" : "Import failed" notice = status ? "Succesfully imported" : "Import failed"
redirect_to project_team_members_path(project), notice: notice redirect_to project_team_members_path(project), notice: notice
......
...@@ -22,7 +22,7 @@ class TreeController < ProjectResourceController ...@@ -22,7 +22,7 @@ class TreeController < ProjectResourceController
end end
def edit def edit
@last_commit = @project.last_commit_for(@ref, @path).sha @last_commit = @project.repository.last_commit_for(@ref, @path).sha
end end
def update def update
......
...@@ -6,16 +6,14 @@ class TreeDecorator < ApplicationDecorator ...@@ -6,16 +6,14 @@ class TreeDecorator < ApplicationDecorator
part_path = "" part_path = ""
parts = path.split("\/") parts = path.split("\/")
#parts = parts[0...-1] if is_blob? yield('..', nil) if parts.count > max_links
yield(h.link_to("..", "#")) if parts.count > max_links
parts.each do |part| parts.each do |part|
part_path = File.join(part_path, part) unless part_path.empty? part_path = File.join(part_path, part) unless part_path.empty?
part_path = part if part_path.empty? part_path = part if part_path.empty?
next unless parts.last(2).include?(part) if parts.count > max_links next unless parts.last(2).include?(part) if parts.count > max_links
yield(h.link_to(h.truncate(part, length: 40), h.project_tree_path(project, h.tree_join(ref, part_path)))) yield(part, h.tree_join(ref, part_path))
end end
end end
end end
...@@ -26,7 +24,7 @@ class TreeDecorator < ApplicationDecorator ...@@ -26,7 +24,7 @@ class TreeDecorator < ApplicationDecorator
def up_dir_path def up_dir_path
file = File.join(path, "..") file = File.join(path, "..")
h.project_tree_path(project, h.tree_join(ref, file)) h.tree_join(ref, file)
end end
def readme def readme
......
...@@ -53,7 +53,7 @@ module ApplicationHelper ...@@ -53,7 +53,7 @@ module ApplicationHelper
def last_commit(project) def last_commit(project)
if project.repo_exists? if project.repo_exists?
time_ago_in_words(project.commit.committed_date) + " ago" time_ago_in_words(project.repository.commit.committed_date) + " ago"
else else
"Never" "Never"
end end
...@@ -62,9 +62,11 @@ module ApplicationHelper ...@@ -62,9 +62,11 @@ module ApplicationHelper
end end
def grouped_options_refs(destination = :tree) def grouped_options_refs(destination = :tree)
repository = @project.repository
options = [ options = [
["Branch", @project.branch_names ], ["Branch", repository.branch_names ],
[ "Tag", @project.tag_names ] [ "Tag", repository.tag_names ]
] ]
# If reference is commit id - # If reference is commit id -
...@@ -100,15 +102,15 @@ module ApplicationHelper ...@@ -100,15 +102,15 @@ module ApplicationHelper
] ]
project_nav = [] project_nav = []
if @project && !@project.new_record? if @project && @project.repository && @project.repository.root_ref
project_nav = [ project_nav = [
{ label: "#{@project.name} Issues", url: project_issues_path(@project) }, { label: "#{@project.name} Issues", url: project_issues_path(@project) },
{ label: "#{@project.name} Commits", url: project_commits_path(@project, @ref || @project.root_ref) }, { label: "#{@project.name} Commits", url: project_commits_path(@project, @ref || @project.repository.root_ref) },
{ label: "#{@project.name} Merge Requests", url: project_merge_requests_path(@project) }, { label: "#{@project.name} Merge Requests", url: project_merge_requests_path(@project) },
{ label: "#{@project.name} Milestones", url: project_milestones_path(@project) }, { label: "#{@project.name} Milestones", url: project_milestones_path(@project) },
{ label: "#{@project.name} Snippets", url: project_snippets_path(@project) }, { label: "#{@project.name} Snippets", url: project_snippets_path(@project) },
{ label: "#{@project.name} Team", url: project_team_index_path(@project) }, { label: "#{@project.name} Team", url: project_team_index_path(@project) },
{ label: "#{@project.name} Tree", url: project_tree_path(@project, @ref || @project.root_ref) }, { label: "#{@project.name} Tree", url: project_tree_path(@project, @ref || @project.repository.root_ref) },
{ label: "#{@project.name} Wall", url: wall_project_path(@project) }, { label: "#{@project.name} Wall", url: wall_project_path(@project) },
{ label: "#{@project.name} Wiki", url: project_wikis_path(@project) }, { label: "#{@project.name} Wiki", url: project_wikis_path(@project) },
] ]
...@@ -140,6 +142,7 @@ module ApplicationHelper ...@@ -140,6 +142,7 @@ module ApplicationHelper
event.last_push_to_non_root? && event.last_push_to_non_root? &&
!event.rm_ref? && !event.rm_ref? &&
event.project && event.project &&
event.project.repository &&
event.project.merge_requests_enabled event.project.merge_requests_enabled
end end
......
...@@ -20,20 +20,6 @@ module EventsHelper ...@@ -20,20 +20,6 @@ module EventsHelper
[event.action_name, target].join(" ") [event.action_name, target].join(" ")
end end
def event_image event
event_image_path = if event.push?
"event_push.png"
elsif event.merged?
"event_mr_merged.png"
end
return nil unless event_image_path
content_tag :div, class: 'event_icon' do
image_tag event_image_path
end
end
def event_filter_link key, tooltip def event_filter_link key, tooltip
key = key.to_s key = key.to_s
......
...@@ -4,7 +4,7 @@ module MergeRequestsHelper ...@@ -4,7 +4,7 @@ module MergeRequestsHelper
event.project, event.project,
merge_request: { merge_request: {
source_branch: event.branch_name, source_branch: event.branch_name,
target_branch: event.project.root_ref, target_branch: event.project.repository.root_ref,
title: event.branch_name.titleize title: event.branch_name.titleize
} }
) )
......
...@@ -15,17 +15,19 @@ class Ability ...@@ -15,17 +15,19 @@ class Ability
def project_abilities(user, project) def project_abilities(user, project)
rules = [] rules = []
team = project.team
# Rules based on role in project # Rules based on role in project
if project.master_access_for?(user) if team.masters.include?(user)
rules << project_master_rules rules << project_master_rules
elsif project.dev_access_for?(user) elsif team.developers.include?(user)
rules << project_dev_rules rules << project_dev_rules
elsif project.report_access_for?(user) elsif team.reporters.include?(user)
rules << project_report_rules rules << project_report_rules
elsif project.guest_access_for?(user) elsif team.guests.include?(user)
rules << project_guest_rules rules << project_guest_rules
end end
......
...@@ -11,7 +11,7 @@ class Commit ...@@ -11,7 +11,7 @@ class Commit
attr_accessor :commit, :head, :refs attr_accessor :commit, :head, :refs
delegate :message, :authored_date, :committed_date, :parents, :sha, delegate :message, :authored_date, :committed_date, :parents, :sha,
:date, :committer, :author, :diffs, :tree, :id, :date, :committer, :author, :diffs, :tree, :id, :stats,
:to_patch, to: :commit :to_patch, to: :commit
class << self class << self
...@@ -83,8 +83,8 @@ class Commit ...@@ -83,8 +83,8 @@ class Commit
return result unless from && to return result unless from && to
first = project.commit(to.try(:strip)) first = project.repository.commit(to.try(:strip))
last = project.commit(from.try(:strip)) last = project.repository.commit(from.try(:strip))
if first && last if first && last
result[:same] = (first.id == last.id) result[:same] = (first.id == last.id)
...@@ -98,6 +98,8 @@ class Commit ...@@ -98,6 +98,8 @@ class Commit
end end
def initialize(raw_commit, head = nil) def initialize(raw_commit, head = nil)
raise "Nil as raw commit passed" unless raw_commit
@commit = raw_commit @commit = raw_commit
@head = head @head = head
end end
...@@ -136,7 +138,11 @@ class Commit ...@@ -136,7 +138,11 @@ class Commit
end end
def prev_commit def prev_commit
parents.try :first @prev_commit ||= if parents.present?
Commit.new(parents.first)
else
nil
end
end end
def prev_commit_id def prev_commit_id
......
...@@ -110,26 +110,6 @@ class Event < ActiveRecord::Base ...@@ -110,26 +110,6 @@ class Event < ActiveRecord::Base
target_type == "MergeRequest" target_type == "MergeRequest"
end end
def new_issue?
target_type == "Issue" &&
action == Created
end
def new_merge_request?
target_type == "MergeRequest" &&
action == Created
end
def changed_merge_request?
target_type == "MergeRequest" &&
[Closed, Reopened].include?(action)
end
def changed_issue?
target_type == "Issue" &&
[Closed, Reopened].include?(action)
end
def joined? def joined?
action == Joined action == Joined
end end
...@@ -224,7 +204,7 @@ class Event < ActiveRecord::Base ...@@ -224,7 +204,7 @@ class Event < ActiveRecord::Base
# Max 20 commits from push DESC # Max 20 commits from push DESC
def commits def commits
@commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse @commits ||= data[:commits].map { |commit| repository.commit(commit[:id]) }.reverse
end end
def commits_count def commits_count
...@@ -245,14 +225,18 @@ class Event < ActiveRecord::Base ...@@ -245,14 +225,18 @@ class Event < ActiveRecord::Base
end end
end end
def repository
project.repository
end
def parent_commit def parent_commit
project.commit(commit_from) repository.commit(commit_from)
rescue => ex rescue => ex
nil nil
end end
def last_commit def last_commit
project.commit(commit_to) repository.commit(commit_to)
rescue => ex rescue => ex
nil nil
end end
......
...@@ -29,10 +29,6 @@ class GitlabCiService < Service ...@@ -29,10 +29,6 @@ class GitlabCiService < Service
hook.save hook.save
end end
def commit_badge_path sha
project_url + "/status?sha=#{sha}"
end
def commit_status_path sha def commit_status_path sha
project_url + "/builds/#{sha}/status.json?token=#{token}" project_url + "/builds/#{sha}/status.json?token=#{token}"
end end
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
# #
# id :integer not null, primary key # id :integer not null, primary key
# note :text # note :text
# noteable_id :string(255)
# noteable_type :string(255) # noteable_type :string(255)
# author_id :integer # author_id :integer
# created_at :datetime not null # created_at :datetime not null
...@@ -12,6 +11,8 @@ ...@@ -12,6 +11,8 @@
# project_id :integer # project_id :integer
# attachment :string(255) # attachment :string(255)
# line_code :string(255) # line_code :string(255)
# commit_id :string(255)
# noteable_id :integer
# #
require 'carrierwave/orm/activerecord' require 'carrierwave/orm/activerecord'
...@@ -42,7 +43,7 @@ class Note < ActiveRecord::Base ...@@ -42,7 +43,7 @@ class Note < ActiveRecord::Base
# Scopes # Scopes
scope :for_commits, ->{ where(noteable_type: "Commit") } scope :for_commits, ->{ where(noteable_type: "Commit") }
scope :common, ->{ where(noteable_id: nil, commit_id: nil) } scope :common, ->{ where(noteable_type: ["", nil]) }
scope :today, ->{ where("created_at >= :date", date: Date.today) } scope :today, ->{ where("created_at >= :date", date: Date.today) }
scope :last_week, ->{ where("created_at >= :date", date: (Date.today - 7.days)) } scope :last_week, ->{ where("created_at >= :date", date: (Date.today - 7.days)) }
scope :since, ->(day) { where("created_at >= :date", date: (day)) } scope :since, ->(day) { where("created_at >= :date", date: (day)) }
...@@ -70,7 +71,7 @@ class Note < ActiveRecord::Base ...@@ -70,7 +71,7 @@ class Note < ActiveRecord::Base
# override to return commits, which are not active record # override to return commits, which are not active record
def noteable def noteable
if for_commit? if for_commit?
project.commit(commit_id) project.repository.commit(commit_id)
else else
super super
end end
......
This diff is collapsed.
...@@ -26,6 +26,6 @@ class ProtectedBranch < ActiveRecord::Base ...@@ -26,6 +26,6 @@ class ProtectedBranch < ActiveRecord::Base
end end
def commit def commit
project.commit(self.name) project.repository.commit(self.name)
end end
end end
class Repository
# Repository directory name with namespace direcotry
# Examples:
# gitlab/gitolite
# diaspora
#
attr_accessor :path_with_namespace
# Grit repo object
attr_accessor :repo
# Default branch in the repository
attr_accessor :root_ref
def initialize(path_with_namespace, root_ref = 'master')
@root_ref = root_ref || "master"
@path_with_namespace = path_with_namespace
# Init grit repo object
repo
end
def raw
repo
end
def path_to_repo
@path_to_repo ||= File.join(Gitlab.config.gitolite.repos_path, "#{path_with_namespace}.git")
end
def repo
@repo ||= Grit::Repo.new(path_to_repo)
end
def commit(commit_id = nil)
Commit.find_or_first(repo, commit_id, root_ref)
end
def fresh_commits(n = 10)
Commit.fresh_commits(repo, n)
end
def commits_with_refs(n = 20)
Commit.commits_with_refs(repo, n)
end
def commits_since(date)
Commit.commits_since(repo, date)
end
def commits(ref, path = nil, limit = nil, offset = nil)
Commit.commits(repo, ref, path, limit, offset)
end
def last_commit_for(ref, path = nil)
commits(ref, path, 1).first
end
def commits_between(from, to)
Commit.commits_between(repo, from, to)
end
def has_post_receive_file?
!!hook_file
end
def valid_post_receive_file?
valid_hook_file == hook_file
end
def valid_hook_file
@valid_hook_file ||= File.read(Rails.root.join('lib', 'hooks', 'post-receive'))
end
def hook_file
@hook_file ||= begin
hook_path = File.join(path_to_repo, 'hooks', 'post-receive')
File.read(hook_path) if File.exists?(hook_path)
end
end
# Returns an Array of branch names
def branch_names
repo.branches.collect(&:name).sort
end
# Returns an Array of Branches
def branches
repo.branches.sort_by(&:name)
end
# Returns an Array of tag names
def tag_names
repo.tags.collect(&:name).sort.reverse
end
# Returns an Array of Tags
def tags
repo.tags.sort_by(&:name).reverse
end
# Returns an Array of branch and tag names
def ref_names
[branch_names + tag_names].flatten
end
def heads
@heads ||= repo.heads
end
def tree(fcommit, path = nil)
fcommit = commit if fcommit == :head
tree = fcommit.tree
path ? (tree / path) : tree
end
def has_commits?
!!commit
rescue Grit::NoSuchPathError
false
end
def empty?
!has_commits?
end
# Discovers the default branch based on the repository's available branches
#
# - If no branches are present, returns nil
# - If one branch is present, returns its name
# - If two or more branches are present, returns the one that has a name
# matching root_ref (default_branch or 'master' if default_branch is nil)
def discover_default_branch
if branch_names.length == 0
nil
elsif branch_names.length == 1
branch_names.first
else
branch_names.select { |v| v == root_ref }.first
end
end
# Archive Project to .tar.gz
#
# Already packed repo archives stored at
# app_root/tmp/repositories/project_name/project_name-commit-id.tag.gz
#
def archive_repo(ref)
ref = ref || self.root_ref
commit = self.commit(ref)
return nil unless commit
# Build file path
file_name = self.path + "-" + commit.id.to_s + ".tar.gz"
storage_path = Rails.root.join("tmp", "repositories", self.path_with_namespace)
file_path = File.join(storage_path, file_name)
# Put files into a directory before archiving
prefix = self.path + "/"
# Create file if not exists
unless File.exists?(file_path)
FileUtils.mkdir_p storage_path
file = self.repo.archive_to_file(ref, prefix, file_path)
end
file_path
end
end
class Team
attr_accessor :project
def initialize(project)
@project = project
end
# Shortcut to add users
#
# Use:
# @team << [@user, :master]
# @team << [@users, :master]
#
def << args
users = args.first
if users.respond_to?(:each)
add_users(users, args.second)
else
add_user(users, args.second)
end
end
def add_user(user, access)
add_users_ids([user.id], access)
end
def add_users(users, access)
add_users_ids(users.map(&:id), access)
end
def add_users_ids(user_ids, access)
UsersProject.add_users_into_projects(
[project.id],
user_ids,
access
)
end
# Remove all users from project team
def truncate
UsersProject.truncate_team(project)
end
def members
project.users_projects
end
def guests
members.guests.map(&:user)
end
def reporters
members.reporters.map(&:user)
end
def developers
members.developers.map(&:user)
end
def masters
members.masters.map(&:user)
end
def repository_readers
repository_members[UsersProject::REPORTER]
end
def repository_writers
repository_members[UsersProject::DEVELOPER]
end
def repository_masters
repository_members[UsersProject::MASTER]
end
def repository_members
keys = Hash.new {|h,k| h[k] = [] }
UsersProject.select("keys.identifier, project_access").
joins(user: :keys).where(project_id: project.id).
each {|row| keys[row.project_access] << [row.identifier] }
keys[UsersProject::REPORTER] += project.deploy_keys.pluck(:identifier)
keys
end
def import(source_project)
target_project = project
source_team = source_project.users_projects.all
target_team = target_project.users_projects.all
target_user_ids = target_team.map(&:user_id)
source_team.reject! do |tm|
# Skip if user already present in team
target_user_ids.include?(tm.user_id)
end
source_team.map! do |tm|
new_tm = tm.dup
new_tm.id = nil
new_tm.project_id = target_project.id
new_tm.skip_git = true
new_tm
end
UsersProject.transaction do
source_team.each do |tm|
tm.save
end
target_project.update_repository
end
true
rescue
false
end
end
class Tree class Tree
include Linguist::BlobHelper include Linguist::BlobHelper
attr_accessor :path, :tree, :project, :ref
attr_accessor :path, :tree, :ref
delegate :contents, :basename, :name, :data, :mime_type, delegate :contents, :basename, :name, :data, :mime_type,
:mode, :size, :text?, :colorize, to: :tree :mode, :size, :text?, :colorize, to: :tree
def initialize(raw_tree, project, ref = nil, path = nil) def initialize(raw_tree, ref = nil, path = nil)
@project, @ref, @path = project, ref, path @ref, @path = ref, path
@tree = if path.present? @tree = if path.present?
raw_tree / path raw_tree / path
else else
......
...@@ -188,7 +188,7 @@ class User < ActiveRecord::Base ...@@ -188,7 +188,7 @@ class User < ActiveRecord::Base
# Team membership in personal projects # Team membership in personal projects
def tm_in_personal_projects def tm_in_personal_projects
personal_projects.users_projects.where(user_id: self.id) UsersProject.where(project_id: personal_projects.map(&:id), user_id: self.id)
end end
# Returns a string for use as a Gitolite user identifier # Returns a string for use as a Gitolite user identifier
......
...@@ -42,7 +42,34 @@ class UsersProject < ActiveRecord::Base ...@@ -42,7 +42,34 @@ class UsersProject < ActiveRecord::Base
scope :in_project, ->(project) { where(project_id: project.id) } scope :in_project, ->(project) { where(project_id: project.id) }
class << self class << self
def add_users_into_projects(project_ids, user_ids, project_access)
# Add users to project teams with passed access option
#
# access can be an integer representing a access code
# or symbol like :master representing role
#
# Ex.
# add_users_into_projects(
# project_ids,
# user_ids,
# UsersProject::MASTER
# )
#
# add_users_into_projects(
# project_ids,
# user_ids,
# :master
# )
#
def add_users_into_projects(project_ids, user_ids, access)
project_access = if roles_hash.has_key?(access)
roles_hash[access]
elsif roles_hash.values.include?(access.to_i)
access
else
raise "Non valid access"
end
UsersProject.transaction do UsersProject.transaction do
project_ids.each do |project_id| project_ids.each do |project_id|
user_ids.each do |user_id| user_ids.each do |user_id|
...@@ -79,36 +106,6 @@ class UsersProject < ActiveRecord::Base ...@@ -79,36 +106,6 @@ class UsersProject < ActiveRecord::Base
truncate_teams [project.id] truncate_teams [project.id]
end end
def import_team(source_project, target_project)
source_team = source_project.users_projects.all
target_team = target_project.users_projects.all
target_user_ids = target_team.map(&:user_id)
source_team.reject! do |tm|
# Skip if user already present in team
target_user_ids.include?(tm.user_id)
end
source_team.map! do |tm|
new_tm = tm.dup
new_tm.id = nil
new_tm.project_id = target_project.id
new_tm.skip_git = true
new_tm
end
UsersProject.transaction do
source_team.each do |tm|
tm.save
end
target_project.update_repository
end
true
rescue
false
end
def bulk_delete(project, user_ids) def bulk_delete(project, user_ids)
UsersProject.transaction do UsersProject.transaction do
UsersProject.where(user_id: user_ids, project_id: project.id).each do |users_project| UsersProject.where(user_id: user_ids, project_id: project.id).each do |users_project|
...@@ -131,14 +128,13 @@ class UsersProject < ActiveRecord::Base ...@@ -131,14 +128,13 @@ class UsersProject < ActiveRecord::Base
end end
end end
# TODO: depreceate in future in favor of add_users_into_projects def roles_hash
def bulk_import(project, user_ids, project_access) {
add_users_into_projects([project.id], user_ids, project_access) guest: GUEST,
end reporter: REPORTER,
developer: DEVELOPER,
# TODO: depreceate in future in favor of add_users_into_projects master: MASTER
def user_bulk_import(user, project_ids, project_access) }
add_users_into_projects(project_ids, [user.id], project_access)
end end
def access_roles def access_roles
......
# encoding: utf-8 # encoding: utf-8
class AttachmentUploader < CarrierWave::Uploader::Base class AttachmentUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage :file storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end end
# Provide a default URL as a default if there hasn't been a file uploaded: def image?
# def default_url %w(png jpg jpeg).include?(file.extension)
# "/images/fallback/" + [version_name, "default.png"].compact.join('_') end
# end
# Process files as they are uploaded:
# process scale: [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process scale: [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
# def extension_white_list
# %w(jpg jpeg gif png)
# end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end end
.admin_dash.row .admin_dash.row
.span3 .span3
.ui-box .ui-box
%h5 Projects %h5.title Projects
.data.padded .data.padded
= link_to admin_projects_path do = link_to admin_projects_path do
%h1= Project.count %h1= Project.count
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
= link_to 'New Project', new_project_path, class: "btn small" = link_to 'New Project', new_project_path, class: "btn small"
.span3 .span3
.ui-box .ui-box
%h5 Groups %h5.title Groups
.data.padded .data.padded
= link_to admin_groups_path do = link_to admin_groups_path do
%h1= Group.count %h1= Group.count
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
= link_to 'New Group', new_admin_group_path, class: "btn small" = link_to 'New Group', new_admin_group_path, class: "btn small"
.span3 .span3
.ui-box .ui-box
%h5 Users %h5.title Users
.data.padded .data.padded
= link_to admin_users_path do = link_to admin_users_path do
%h1= User.count %h1= User.count
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
= link_to 'New User', new_admin_user_path, class: "btn small" = link_to 'New User', new_admin_user_path, class: "btn small"
.span3 .span3
.ui-box .ui-box
%h5 %h5.title
Resque Workers Resque Workers
.data.padded .data.padded
- if @resque_accessible - if @resque_accessible
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
- if project.repo_exists? - if project.repo_exists?
.clearfix .clearfix
= f.label :default_branch, "Default Branch" = f.label :default_branch, "Default Branch"
.input= f.select(:default_branch, project.heads.map(&:name), {}, style: "width:210px;") .input= f.select(:default_branch, repository.heads.map(&:name), {}, style: "width:210px;")
%fieldset.adv_settings %fieldset.adv_settings
%legend Features: %legend Features:
......
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
%i.icon-edit %i.icon-edit
Edit Edit
- if @project.has_commits? - if @repository && @repository.has_commits?
- if !@project.has_post_receive_file? - if !@repository.has_post_receive_file?
%br %br
.alert.alert-error .alert.alert-error
%span %span
%strong Project has commits but missing post-receive file. %strong Project has commits but missing post-receive file.
%br %br
If you exported project manually - make a link of post-receive hook file from gitolite to project repository If you exported project manually - make a link of post-receive hook file from gitolite to project repository
- elsif !@project.valid_post_receive_file? - elsif !@repository.valid_post_receive_file?
%br %br
.alert.alert-error .alert.alert-error
%span %span
...@@ -65,42 +65,43 @@ ...@@ -65,42 +65,43 @@
Created at: Created at:
%td %td
= @project.created_at.stamp("March 1, 1999") = @project.created_at.stamp("March 1, 1999")
%tr
%td
%b
Smart HTTP:
%td
= link_to @project.http_url_to_repo
%tr
%td
%b
SSH:
%td
= link_to @project.ssh_url_to_repo
%table.zebra-striped - if @repository
%thead %table.zebra-striped
%thead
%tr
%th Repository
%th
%tr %tr
%th Repository %td
%th %b
%tr FS Path:
%td %td
%b %code= @repository.path_to_repo
FS Path: %tr
%td %td
%code= @project.path_to_repo %b
%tr Last commit at:
%td %td
%b = last_commit(@project)
Smart HTTP: %tr
%td %td
= link_to @project.http_url_to_repo %b
%tr Post Receive File:
%td %td
%b = check_box_tag :post_receive_file, 1, @repository.has_post_receive_file?, disabled: true
SSH:
%td
= link_to @project.ssh_url_to_repo
%tr
%td
%b
Last commit at:
%td
= last_commit(@project)
%tr
%td
%b
Post Receive File:
%td
= check_box_tag :post_receive_file, 1, @project.has_post_receive_file?, disabled: true
%br %br
%h5 %h5
......
= render "commits/commit_box" = render "commits/commit_box"
%p.right.cgray
This commit has
%span.cgreen #{@commit.stats.additions} additions
and
%span.cred #{@commit.stats.deletions} deletions
= render "commits/diffs", diffs: @commit.diffs = render "commits/diffs", diffs: @commit.diffs
= render "notes/notes_with_form", tid: @commit.id, tt: "commit" = render "notes/notes_with_form", tid: @commit.id, tt: "commit"
= render "notes/per_line_form" = render "notes/per_line_form"
:javascript :javascript
$(function(){ $(function(){
PerLineNotes.init(); PerLineNotes.init();
...@@ -19,7 +25,7 @@ ...@@ -19,7 +25,7 @@
, h = event.currentTarget.naturalHeight; , h = event.currentTarget.naturalHeight;
$('.image.diff_added .image-info', this).append(' | <b>W:</b> ' + w + 'px | <b>H:</b> ' + h + 'px'); $('.image.diff_added .image-info', this).append(' | <b>W:</b> ' + w + 'px | <b>H:</b> ' + h + 'px');
}, this)); }, this));
}); });
}); });
.commit-box{class: @commit.parents_count > 1 ? "merge-commit" : ""} .ui-box.ui-box-show
.commit-head .ui-box-head
.right .right
- if @notes_count > 0 - if @notes_count > 0
%span.btn.disabled.grouped %span.btn.disabled.grouped
%i.icon-comment %i.icon-comment
= @notes_count = @notes_count
.left.btn-group .left.btn-group
%a.btn.small.grouped.dropdown-toggle{ data: {toggle: :dropdown} } %a.btn.grouped.dropdown-toggle{ data: {toggle: :dropdown} }
%i.icon-download-alt %i.icon-download-alt
Download as Download as
%span.caret %span.caret
%ul.dropdown-menu %ul.dropdown-menu
%li= link_to "Email Patches", project_commit_path(@project, @commit, format: :patch) %li= link_to "Email Patches", project_commit_path(@project, @commit, format: :patch)
%li= link_to "Plain Diff", project_commit_path(@project, @commit, format: :diff) %li= link_to "Plain Diff", project_commit_path(@project, @commit, format: :diff)
= link_to project_tree_path(@project, @commit), class: "browse-button primary grouped" do = link_to project_tree_path(@project, @commit), class: "btn primary grouped" do
%strong Browse Code » %span Browse Code »
%h3.commit-title.page_title %h3.commit-title.page_title
= gfm escape_once(@commit.title) = gfm escape_once(@commit.title)
- if @commit.description.present? - if @commit.description.present?
%pre.commit-description %pre.commit-description
= gfm escape_once(@commit.description) = gfm escape_once(@commit.description)
.commit-info .ui-box-body
.row .row
.span5 .span5
.author .author
%strong= @commit.author_link avatar: true, size: 40 = @commit.author_link avatar: true, size: 32
authored authored
%time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")} %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")}
#{time_ago_in_words(@commit.authored_date)} ago #{time_ago_in_words(@commit.authored_date)} ago
- if @commit.different_committer? - if @commit.different_committer?
.committer .committer
&rarr; &rarr;
%strong= @commit.committer_link = @commit.committer_link
committed committed
%time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")}
#{time_ago_in_words(@commit.committed_date)} ago #{time_ago_in_words(@commit.committed_date)} ago
.span6.right .span6.pull-right
.sha-block .pull-right
%span.cgray commit .sha-block
%code.label_commit= @commit.id %span.cgray commit
.sha-block %span.label_commit= @commit.id
%span.cgray= pluralize(@commit.parents.count, "parent") .clearfix
- @commit.parents.each do |parent| .pull-right
= link_to parent.id[0...10], project_commit_path(@project, parent) .sha-block
%span.cgray= pluralize(@commit.parents.count, "parent")
- @commit.parents.each do |parent|
= link_to parent.id[0...10], project_commit_path(@project, parent)
- @commits.group_by { |c| c.committed_date.to_date }.each do |day, commits| - @commits.group_by { |c| c.committed_date.to_date }.each do |day, commits|
%div.ui-box %div.ui-box
%h5.small %h5.title
%i.icon-calendar %i.icon-calendar
= day.stamp("28 Aug, 2010") = day.stamp("28 Aug, 2010")
%ul.well-list= render commits %ul.well-list= render commits
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
%li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'}
= nav_link(controller: [:commit, :commits]) do = nav_link(controller: [:commit, :commits]) do
= link_to 'Commits', project_commits_path(@project, @project.root_ref) = link_to 'Commits', project_commits_path(@project, @repository.root_ref)
= nav_link(controller: :compare) do = nav_link(controller: :compare) do
= link_to 'Compare', project_compare_index_path(@project) = link_to 'Compare', project_compare_index_path(@project)
= nav_link(html_options: {class: branches_tab_class}) do = nav_link(html_options: {class: branches_tab_class}) do
= link_to project_repository_path(@project) do = link_to project_repository_path(@project) do
Branches Branches
%span.badge= @project.branches.length %span.badge= @repository.branches.length
= nav_link(controller: :repositories, action: :tags) do = nav_link(controller: :repositories, action: :tags) do
= link_to tags_project_repository_path(@project) do = link_to tags_project_repository_path(@project) do
Tags Tags
%span.badge= @project.tags.length %span.badge= @repository.tags.length
= nav_link(controller: :repositories, action: :stats) do = nav_link(controller: :repositories, action: :stats) do
= link_to stats_project_repository_path(@project) do = link_to stats_project_repository_path(@project) do
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
:javascript :javascript
$(function() { $(function() {
var availableTags = #{@project.ref_names.to_json}; var availableTags = #{@project.repository.ref_names.to_json};
$("#from, #to").autocomplete({ $("#from, #to").autocomplete({
source: availableTags, source: availableTags,
......
.groups_box .groups_box
%h5 %h5.title
Groups Groups
%small %small
(#{groups.count}) (#{groups.count})
......
.projects_box .projects_box
%h5 %h5.title
Projects Projects
%small %small
(#{projects.total_count}) (#{projects.total_count})
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
- @issues.group_by(&:project).each do |group| - @issues.group_by(&:project).each do |group|
%div.ui-box %div.ui-box
- @project = group[0] - @project = group[0]
%h5= link_to_project @project %h5.title
= link_to_project @project
%ul.well-list.issues_table %ul.well-list.issues_table
- group[1].each do |issue| - group[1].each do |issue|
= render(partial: 'issues/show', locals: {issue: issue}) = render(partial: 'issues/show', locals: {issue: issue})
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
- @merge_requests.group_by(&:project).each do |group| - @merge_requests.group_by(&:project).each do |group|
.ui-box .ui-box
- @project = group[0] - @project = group[0]
%h5= link_to_project @project %h5.title
= link_to_project @project
%ul.well-list %ul.well-list
- group[1].each do |merge_request| - group[1].each do |merge_request|
= render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request})
......
.projects_box .projects_box
%h5 %h5.title
Projects Projects
%small %small
(#{projects.count}) (#{projects.count})
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
- @issues.group_by(&:project).each do |group| - @issues.group_by(&:project).each do |group|
%div.ui-box %div.ui-box
- @project = group[0] - @project = group[0]
%h5= @project.name %h5.title
= @project.name
%ul.well-list.issues_table %ul.well-list.issues_table
- group[1].each do |issue| - group[1].each do |issue|
= render(partial: 'issues/show', locals: {issue: issue}) = render(partial: 'issues/show', locals: {issue: issue})
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
- @merge_requests.group_by(&:project).each do |group| - @merge_requests.group_by(&:project).each do |group|
%ul.well-list.ui-box %ul.well-list.ui-box
- @project = group[0] - @project = group[0]
%h5= @project.name %h5.title
= @project.name
- group[1].each do |merge_request| - group[1].each do |merge_request|
= render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request})
%hr %hr
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
- if can?(current_user, :manage_group, @group) - if can?(current_user, :manage_group, @group)
= render (@project ? "new_member" : "new_group_member") = render (@project ? "new_member" : "new_group_member")
.ui-box .ui-box
%h5 %h5.title
Team Team
%small %small
(#{@users.size}) (#{@users.size})
......
...@@ -6,26 +6,27 @@ ...@@ -6,26 +6,27 @@
- @issue.errors.full_messages.each do |msg| - @issue.errors.full_messages.each do |msg|
%span= msg %span= msg
%br %br
.issue_form_box .ui-box.ui-box-show
.issue_title .ui-box-head
.clearfix .clearfix
= f.label :title do = f.label :title do
%strong= "Subject *" %strong= "Subject *"
.input .input
= f.text_field :title, maxlength: 255, class: "xxlarge js-gfm-input", autofocus: true, required: true = f.text_field :title, maxlength: 255, class: "xxlarge js-gfm-input", autofocus: true, required: true
.issue_middle_block .ui-box-body
.issue_assignee .clearfix
= f.label :assignee_id do .issue_assignee.pull-left
%i.icon-user = f.label :assignee_id do
Assign to %i.icon-user
.input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'}) Assign to
.issue_milestone .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'})
= f.label :milestone_id do .issue_milestone.pull-left
%i.icon-time = f.label :milestone_id do
Milestone %i.icon-time
.input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) Milestone
.input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'})
.issue_description .ui-box-bottom
.clearfix .clearfix
= f.label :label_list do = f.label :label_list do
%i.icon-tag %i.icon-tag
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
= select_tag('update[milestone_id]', options_from_collection_for_select(issues_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone") = select_tag('update[milestone_id]', options_from_collection_for_select(issues_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone")
= hidden_field_tag 'update[issues_ids]', [] = hidden_field_tag 'update[issues_ids]', []
= hidden_field_tag :f, params[:f] = hidden_field_tag :f, params[:f]
= button_tag "Save", class: "btn update_selected_issues" = button_tag "Save", class: "btn update_selected_issues btn-small save-btn"
.issues_filters .issues_filters
.left .left
%ul.nav.nav-pills.left %ul.nav.nav-pills.left
......
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
&larr; To issues list &larr; To issues list
.main_box .ui-box.ui-box-show
.top_box_content .ui-box-head
%h4.box-title %h4.box-title
- if @issue.closed - if @issue.closed
.error.status_info Closed .error.status_info Closed
= gfm escape_once(@issue.title) = gfm escape_once(@issue.title)
.middle_box_content .ui-box-body
%cite.cgray %cite.cgray
Created by #{link_to_member(@project, @issue.author)} Created by #{link_to_member(@project, @issue.author)}
- if @issue.assignee - if @issue.assignee
...@@ -44,13 +44,13 @@ ...@@ -44,13 +44,13 @@
.right .right
- @issue.labels.each do |label| - @issue.labels.each do |label|
%span.label.label-issue %span
%i.icon-tag %i.icon-tag
= label.name = label.name
&nbsp; &nbsp;
- if @issue.description.present? - if @issue.description.present?
.bottom_box_content .ui-box-bottom
= preserve do = preserve do
= markdown @issue.description = markdown @issue.description
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
- if @project.repo_exists? - if @project.repo_exists?
- if can? current_user, :download_code, @project - if can? current_user, :download_code, @project
= nav_link(controller: %w(tree blob blame)) do = nav_link(controller: %w(tree blob blame)) do
= link_to 'Files', project_tree_path(@project, @ref || @project.root_ref) = link_to 'Files', project_tree_path(@project, @ref || @repository.root_ref)
= nav_link(controller: %w(commit commits compare repositories protected_branches)) do = nav_link(controller: %w(commit commits compare repositories protected_branches)) do
= link_to "Commits", project_commits_path(@project, @ref || @project.root_ref) = link_to "Commits", project_commits_path(@project, @ref || @repository.root_ref)
= nav_link(path: 'projects#graph') do = nav_link(path: 'projects#graph') do
= link_to "Network", graph_project_path(@project) = link_to "Network", graph_project_path(@project)
......
...@@ -5,45 +5,47 @@ ...@@ -5,45 +5,47 @@
- @merge_request.errors.full_messages.each do |msg| - @merge_request.errors.full_messages.each do |msg|
%li= msg %li= msg
%h4.cdark 1. Select Branches %fieldset
%br %legend 1. Select Branches
.row .row
.span5 .span5
.mr_branch_box .mr_branch_box
%h5 From (Head Branch) %h5 From (Head Branch)
.body .body
.padded= f.select(:source_branch, @project.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span4'}) .padded= f.select(:source_branch, @repository.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span4'})
.mr_source_commit .mr_source_commit
.span2 .span2
%center= image_tag "merge.png", class: 'mr_direction_tip' %center= image_tag "merge.png", class: 'mr_direction_tip'
.span5 .span5
.mr_branch_box .mr_branch_box
%h5 To (Base Branch) %h5 To (Base Branch)
.body .body
.padded= f.select(:target_branch, @project.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span4'}) .padded= f.select(:target_branch, @repository.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span4'})
.mr_target_commit .mr_target_commit
%h4.cdark 2. Fill info %fieldset
%legend 2. Fill info
.clearfix .ui-box.ui-box-show
.merge_requests_form_box .ui-box-head
.top_box_content .clearfix
= f.label :title do = f.label :title do
%strong= "Title *" %strong= "Title *"
.input= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5, required: true .input= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5, required: true
.merge_requests_middle_box .ui-box-body
.merge_requests_assignee .clearfix
= f.label :assignee_id do .left
%i.icon-user = f.label :assignee_id do
Assign to %i.icon-user
.input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) Assign to
.merge_requests_milestone .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'})
= f.label :milestone_id do .left
%i.icon-time = f.label :milestone_id do
Milestone %i.icon-time
.input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) Milestone
.input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'})
.control-group .control-group
......
- if @commits.present? - if @commits.present?
.ui-box .ui-box
%h5 %h5.title
%i.icon-list %i.icon-list
Commits (#{@commits.count}) Commits (#{@commits.count})
.merge-request-commits .merge-request-commits
......
.main_box .ui-box.ui-box-show
.top_box_content .ui-box-head
%h4.box-title %h4.box-title
- if @merge_request.merged - if @merge_request.merged
.error.status_info .error.status_info
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
.error.status_info Closed .error.status_info Closed
= gfm escape_once(@merge_request.title) = gfm escape_once(@merge_request.title)
.middle_box_content .ui-box-body
%div %div
%cite.cgray %cite.cgray
Created at #{@merge_request.created_at.stamp("Aug 21, 2011")} by #{link_to_member(@project, @merge_request.author)} Created at #{@merge_request.created_at.stamp("Aug 21, 2011")} by #{link_to_member(@project, @merge_request.author)}
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
- if @merge_request.closed - if @merge_request.closed
.bottom_box_content .ui-box-bottom
- if @merge_request.merged? - if @merge_request.merged?
%span %span
Merged by #{link_to_member(@project, @merge_request.merge_event.author)} Merged by #{link_to_member(@project, @merge_request.merge_event.author)}
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
%span All issues for this milestone are closed. You may close milestone now. %span All issues for this milestone are closed. You may close milestone now.
= link_to 'Close Milestone', project_milestone_path(@project, @milestone, milestone: {closed: true }), method: :put, class: "btn small danger" = link_to 'Close Milestone', project_milestone_path(@project, @milestone, milestone: {closed: true }), method: :put, class: "btn small danger"
.main_box .ui-box.ui-box-show
.top_box_content .ui-box-head
%h4.box-title %h4.box-title
- if @milestone.closed - if @milestone.closed
.error.status_info Closed .error.status_info Closed
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
= gfm escape_once(@milestone.title) = gfm escape_once(@milestone.title)
.middle_box_content .ui-box-body
%h5 %h5
Progress: Progress:
%small %small
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
= preserve do = preserve do
= markdown(note.note) = markdown(note.note)
- if note.attachment.url - if note.attachment.url
- if note.attachment.image?
= image_tag note.attachment.url, class: 'thumbnail span4'
.right .right
%div.file %div.file
= link_to note.attachment_identifier, note.attachment.url, target: "_blank" = link_to note.attachment_identifier, note.attachment.url, target: "_blank"
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
= f.label :path do = f.label :path do
Repository Repository
.controls .controls
= text_field_tag :ppath, @project.path_to_repo, class: "xxlarge", readonly: true = text_field_tag :ppath, @repository.path_to_repo, class: "xxlarge", readonly: true
- unless @project.heads.empty? - unless @repository.heads.empty?
.clearfix .clearfix
= f.label :default_branch, "Default Branch" = f.label :default_branch, "Default Branch"
.input= f.select(:default_branch, @project.heads.map(&:name), {}, style: "width:210px;") .input= f.select(:default_branch, @repository.heads.map(&:name), {}, style: "width:210px;")
%fieldset.features %fieldset.features
%legend Features: %legend Features:
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
%td %td
= link_to project_commits_path(@project, branch.name) do = link_to project_commits_path(@project, branch.name) do
%strong= branch.name %strong= branch.name
- if branch.name == @project.root_ref - if @project.root_ref?(branch.name)
%span.label default %span.label default
%td %td
- if branch.commit - if branch.commit
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
- else - else
%i.icon-unlock %i.icon-unlock
%strong= truncate(branch.name, length: 60) %strong= truncate(branch.name, length: 60)
- if branch.name == @project.root_ref - if branch.name == @repository.root_ref
%span.label default %span.label default
%td %td
= link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
= link_to project_commits_path(@project, commit.head.name) do = link_to project_commits_path(@project, commit.head.name) do
%strong %strong
= commit.head.name = commit.head.name
- if commit.head.name == @project.root_ref - if @project.root_ref?(commit.head.name)
%span.label default %span.label default
%td %td
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
%b Total commits: %b Total commits:
%span= @stats.commits_count %span= @stats.commits_count
%p %p
%b Total files in #{@project.root_ref}: %b Total files in #{@repository.root_ref}:
%span= @stats.files_count %span= @stats.files_count
%p %p
%b Authors: %b Authors:
......
...@@ -30,4 +30,10 @@ ...@@ -30,4 +30,10 @@
Download Download
- else - else
%h3 No tags %h3.nothing_here_message
Repository has no tags yet.
%br
%small
Use git tag command to add a new one:
%br
%span.monospace git tag -a v1.4 -m 'version 1.4'
- grouper_project_members(@project).each do |access, members| - grouper_project_members(@project).each do |access, members|
.ui-box .ui-box
%h5 %h5.title
= Project.access_options.key(access).pluralize = Project.access_options.key(access).pluralize
%small= members.size %small= members.size
%ul.well-list %ul.well-list
......
...@@ -3,9 +3,13 @@ ...@@ -3,9 +3,13 @@
%span.arrow %span.arrow
= link_to project_tree_path(@project, @ref) do = link_to project_tree_path(@project, @ref) do
= @project.name = @project.name
- tree.breadcrumbs(6) do |link| - tree.breadcrumbs(6) do |title, path|
\/ \/
%li= link %li
- if path
= link_to truncate(title, length: 40), project_tree_path(@project, path)
- else
= link_to title, '#'
.clear .clear
%div.tree_progress %div.tree_progress
...@@ -26,7 +30,7 @@ ...@@ -26,7 +30,7 @@
%tr.tree-item %tr.tree-item
%td.tree-item-file-name %td.tree-item-file-name
= image_tag "file_empty.png", size: '16x16' = image_tag "file_empty.png", size: '16x16'
= link_to "..", tree.up_dir_path = link_to "..", project_tree_path(@project, tree.up_dir_path)
%td %td
%td %td
%td %td
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
- @wiki.errors.full_messages.each do |msg| - @wiki.errors.full_messages.each do |msg|
%li= msg %li= msg
.main_box .ui-box.ui-box-show
.top_box_content .ui-box-head
= f.label :title = f.label :title
.input= f.text_field :title, class: 'span8' .input= f.text_field :title, class: 'span8'
= f.hidden_field :slug = f.hidden_field :slug
.middle_box_content .ui-box-body
.input .input
%span.cgray %span.cgray
Wiki content is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. Wiki content is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
%code [Link Title](page-slug) %code [Link Title](page-slug)
\. \.
.bottom_box_content .ui-box-bottom
= f.label :content = f.label :content
.input= f.text_area :content, class: 'span8 js-gfm-input' .input= f.text_area :content, class: 'span8 js-gfm-input'
.actions .actions
......
...@@ -11,7 +11,7 @@ class PostReceive ...@@ -11,7 +11,7 @@ class PostReceive
# Ignore push from non-gitlab users # Ignore push from non-gitlab users
user = if identifier.eql? Gitlab.config.gitolite.admin_key user = if identifier.eql? Gitlab.config.gitolite.admin_key
email = project.commit(newrev).author.email rescue nil email = project.repository.commit(newrev).author.email rescue nil
User.find_by_email(email) if email User.find_by_email(email) if email
elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier) elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier)
User.find_by_email(identifier) User.find_by_email(identifier)
......
...@@ -16,7 +16,7 @@ class AdminGroups < Spinach::FeatureSteps ...@@ -16,7 +16,7 @@ class AdminGroups < Spinach::FeatureSteps
@project = create(:project, group: @group) @project = create(:project, group: @group)
@event = create(:closed_issue_event, project: @project) @event = create(:closed_issue_event, project: @project)
@project.add_access current_user, :admin @project.team << [current_user, :master]
end end
And 'Create gitlab user "John"' do And 'Create gitlab user "John"' do
......
...@@ -61,7 +61,7 @@ class Dashboard < Spinach::FeatureSteps ...@@ -61,7 +61,7 @@ class Dashboard < Spinach::FeatureSteps
And 'I own project "Shop"' do And 'I own project "Shop"' do
@project = create :project, name: 'Shop' @project = create :project, name: 'Shop'
@project.add_access(@user, :admin) @project.team << [@user, :master]
end end
And 'I have group with projects' do And 'I have group with projects' do
...@@ -69,7 +69,7 @@ class Dashboard < Spinach::FeatureSteps ...@@ -69,7 +69,7 @@ class Dashboard < Spinach::FeatureSteps
@project = create(:project, group: @group) @project = create(:project, group: @group)
@event = create(:closed_issue_event, project: @project) @event = create(:closed_issue_event, project: @project)
@project.add_access current_user, :admin @project.team << [current_user, :master]
end end
And 'project "Shop" has push event' do And 'project "Shop" has push event' do
......
...@@ -13,7 +13,7 @@ class DashboardIssues < Spinach::FeatureSteps ...@@ -13,7 +13,7 @@ class DashboardIssues < Spinach::FeatureSteps
And 'I have assigned issues' do And 'I have assigned issues' do
project = create :project project = create :project
project.add_access(@user, :read, :write) project.team << [@user, :master]
2.times { create :issue, author: @user, assignee: @user, project: project } 2.times { create :issue, author: @user, assignee: @user, project: project }
end end
......
...@@ -14,8 +14,8 @@ class DashboardMergeRequests < Spinach::FeatureSteps ...@@ -14,8 +14,8 @@ class DashboardMergeRequests < Spinach::FeatureSteps
project1 = create :project project1 = create :project
project2 = create :project project2 = create :project
project1.add_access(@user, :read, :write) project1.team << [@user, :master]
project2.add_access(@user, :read, :write) project2.team << [@user, :master]
merge_request1 = create :merge_request, author: @user, project: project1 merge_request1 = create :merge_request, author: @user, project: project1
merge_request2 = create :merge_request, author: @user, project: project2 merge_request2 = create :merge_request, author: @user, project: project2
......
class DashboardSearch < Spinach::FeatureSteps class DashboardSearch < Spinach::FeatureSteps
include SharedAuthentication include SharedAuthentication
include SharedPaths include SharedPaths
include SharedProject
Given 'I search for "Sho"' do Given 'I search for "Sho"' do
fill_in "dashboard_search", with: "Sho" fill_in "dashboard_search", with: "Sho"
...@@ -11,11 +12,6 @@ class DashboardSearch < Spinach::FeatureSteps ...@@ -11,11 +12,6 @@ class DashboardSearch < Spinach::FeatureSteps
page.should have_link "Shop" page.should have_link "Shop"
end end
And 'I own project "Shop"' do
@project = create(:project, :name => "Shop")
@project.add_access(@user, :admin)
end
Given 'I search for "Contibuting"' do Given 'I search for "Contibuting"' do
fill_in "dashboard_search", with: "Contibuting" fill_in "dashboard_search", with: "Contibuting"
click_button "Search" click_button "Search"
......
...@@ -13,7 +13,7 @@ class Groups < Spinach::FeatureSteps ...@@ -13,7 +13,7 @@ class Groups < Spinach::FeatureSteps
@project = create(:project, group: @group) @project = create(:project, group: @group)
@event = create(:closed_issue_event, project: @project) @event = create(:closed_issue_event, project: @project)
@project.add_access current_user, :admin @project.team << [current_user, :master]
end end
And 'I should see projects activity feed' do And 'I should see projects activity feed' do
......
...@@ -3,13 +3,13 @@ class CreateProject < Spinach::FeatureSteps ...@@ -3,13 +3,13 @@ class CreateProject < Spinach::FeatureSteps
include SharedPaths include SharedPaths
And 'fill project form with valid data' do And 'fill project form with valid data' do
fill_in 'project_name', :with => 'NewProject' fill_in 'project_name', with: 'Empty'
click_button "Create project" click_button "Create project"
end end
Then 'I should see project page' do Then 'I should see project page' do
current_path.should == project_path(Project.last) current_path.should == project_path(Project.last)
page.should have_content "NewProject" page.should have_content "Empty"
end end
And 'I should see empty project instuctions' do And 'I should see empty project instuctions' do
......
...@@ -4,7 +4,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps ...@@ -4,7 +4,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
include SharedPaths include SharedPaths
Then 'I see project commits' do Then 'I see project commits' do
commit = @project.commit commit = @project.repository.commit
page.should have_content(@project.name) page.should have_content(@project.name)
page.should have_content(commit.message) page.should have_content(commit.message)
page.should have_content(commit.id.to_s[0..5]) page.should have_content(commit.id.to_s[0..5])
...@@ -15,7 +15,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps ...@@ -15,7 +15,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
end end
Then 'I see commits atom feed' do Then 'I see commits atom feed' do
commit = CommitDecorator.decorate(@project.commit) commit = CommitDecorator.decorate(@project.repository.commit)
page.response_headers['Content-Type'].should have_content("application/atom+xml") page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "Recent commits to #{@project.name}") page.body.should have_selector("title", :text => "Recent commits to #{@project.name}")
page.body.should have_selector("author email", :text => commit.author_email) page.body.should have_selector("author email", :text => commit.author_email)
...@@ -48,7 +48,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps ...@@ -48,7 +48,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
page.should have_selector('ul.breadcrumb span.divider', count: 3) page.should have_selector('ul.breadcrumb span.divider', count: 3)
page.should have_selector('ul.breadcrumb a', count: 4) page.should have_selector('ul.breadcrumb a', count: 4)
find('ul.breadcrumb li:first a')['href'].should match(/#{@project.path}\/commits\/master\z/) find('ul.breadcrumb li:first a')['href'].should match(/#{@project.path_with_namespace}\/commits\/master\z/)
find('ul.breadcrumb li:last a')['href'].should match(%r{master/app/models/project\.rb\z}) find('ul.breadcrumb li:last a')['href'].should match(%r{master/app/models/project\.rb\z})
end end
......
...@@ -84,18 +84,18 @@ class ProjectTeamManagement < Spinach::FeatureSteps ...@@ -84,18 +84,18 @@ class ProjectTeamManagement < Spinach::FeatureSteps
And '"Sam" is "Shop" developer' do And '"Sam" is "Shop" developer' do
user = User.find_by_name("Sam") user = User.find_by_name("Sam")
project = Project.find_by_name("Shop") project = Project.find_by_name("Shop")
project.add_access(user, :write) project.team << [user, :developer]
end end
Given 'I own project "Website"' do Given 'I own project "Website"' do
@project = create(:project, :name => "Website") @project = create(:project, :name => "Website")
@project.add_access(@user, :admin) @project.team << [@user, :master]
end end
And '"Mike" is "Website" reporter' do And '"Mike" is "Website" reporter' do
user = User.find_by_name("Mike") user = User.find_by_name("Mike")
project = Project.find_by_name("Website") project = Project.find_by_name("Website")
project.add_access(user, :read) project.team << [user, :reporter]
end end
And 'I click link "Import team from another project"' do And 'I click link "Import team from another project"' do
......
...@@ -114,15 +114,15 @@ module SharedPaths ...@@ -114,15 +114,15 @@ module SharedPaths
end end
Given "I visit my project's files page" do Given "I visit my project's files page" do
visit project_tree_path(@project, @project.root_ref) visit project_tree_path(@project, root_ref)
end end
Given "I visit my project's commits page" do Given "I visit my project's commits page" do
visit project_commits_path(@project, @project.root_ref, {limit: 5}) visit project_commits_path(@project, root_ref, {limit: 5})
end end
Given "I visit my project's commits page for a specific path" do Given "I visit my project's commits page for a specific path" do
visit project_commits_path(@project, @project.root_ref + "/app/models/project.rb", {limit: 5}) visit project_commits_path(@project, root_ref + "/app/models/project.rb", {limit: 5})
end end
Given 'I visit my project\'s commits stats page' do Given 'I visit my project\'s commits stats page' do
...@@ -174,7 +174,7 @@ module SharedPaths ...@@ -174,7 +174,7 @@ module SharedPaths
end end
Given 'I visit project commits page' do Given 'I visit project commits page' do
visit project_commits_path(@project, @project.root_ref, {limit: 5}) visit project_commits_path(@project, root_ref, {limit: 5})
end end
Given 'I visit project commits page for stable branch' do Given 'I visit project commits page for stable branch' do
...@@ -182,7 +182,7 @@ module SharedPaths ...@@ -182,7 +182,7 @@ module SharedPaths
end end
Given 'I visit project source page' do Given 'I visit project source page' do
visit project_tree_path(@project, @project.root_ref) visit project_tree_path(@project, root_ref)
end end
Given 'I visit blob file from repo' do Given 'I visit blob file from repo' do
...@@ -240,4 +240,8 @@ module SharedPaths ...@@ -240,4 +240,8 @@ module SharedPaths
Given 'I visit project wiki page' do Given 'I visit project wiki page' do
visit project_wiki_path(@project, :index) visit project_wiki_path(@project, :index)
end end
def root_ref
@project.repository.root_ref
end
end end
...@@ -4,13 +4,13 @@ module SharedProject ...@@ -4,13 +4,13 @@ module SharedProject
# Create a project without caring about what it's called # Create a project without caring about what it's called
And "I own a project" do And "I own a project" do
@project = create(:project) @project = create(:project)
@project.add_access(@user, :admin) @project.team << [@user, :master]
end end
# Create a specific project called "Shop" # Create a specific project called "Shop"
And 'I own project "Shop"' do And 'I own project "Shop"' do
@project = create(:project, :name => "Shop") @project = create(:project, name: "Shop")
@project.add_access(@user, :admin) @project.team << [@user, :master]
end end
def current_project def current_project
......
...@@ -13,7 +13,7 @@ module Gitlab ...@@ -13,7 +13,7 @@ module Gitlab
# Example Request: # Example Request:
# GET /projects/:id/notes # GET /projects/:id/notes
get ":id/notes" do get ":id/notes" do
@notes = user_project.common_notes @notes = user_project.notes.common
present paginate(@notes), with: Entities::Note present paginate(@notes), with: Entities::Note
end end
...@@ -25,7 +25,7 @@ module Gitlab ...@@ -25,7 +25,7 @@ module Gitlab
# Example Request: # Example Request:
# GET /projects/:id/notes/:note_id # GET /projects/:id/notes/:note_id
get ":id/notes/:note_id" do get ":id/notes/:note_id" do
@note = user_project.common_notes.find(params[:note_id]) @note = user_project.notes.common.find(params[:note_id])
present @note, with: Entities::Note present @note, with: Entities::Note
end end
......
...@@ -257,7 +257,7 @@ module Gitlab ...@@ -257,7 +257,7 @@ module Gitlab
per_page = params[:per_page] || 20 per_page = params[:per_page] || 20
ref = params[:ref_name] || user_project.try(:default_branch) || 'master' ref = params[:ref_name] || user_project.try(:default_branch) || 'master'
commits = user_project.commits(ref, nil, per_page, page * per_page) commits = user_project.repository.commits(ref, nil, per_page, page * per_page)
present CommitDecorator.decorate(commits), with: Entities::RepoCommit present CommitDecorator.decorate(commits), with: Entities::RepoCommit
end end
...@@ -375,10 +375,10 @@ module Gitlab ...@@ -375,10 +375,10 @@ module Gitlab
ref = params[:sha] ref = params[:sha]
commit = user_project.commit ref commit = user_project.repository.commit ref
not_found! "Commit" unless commit not_found! "Commit" unless commit
tree = Tree.new commit.tree, user_project, ref, params[:filepath] tree = Tree.new commit.tree, ref, params[:filepath]
not_found! "File" unless tree.try(:tree) not_found! "File" unless tree.try(:tree)
content_type tree.mime_type content_type tree.mime_type
......
...@@ -68,7 +68,7 @@ module ExtractsPath ...@@ -68,7 +68,7 @@ module ExtractsPath
id = input id = input
id += '/' unless id.ends_with?('/') id += '/' unless id.ends_with?('/')
valid_refs = @project.ref_names valid_refs = @project.repository.ref_names
valid_refs.select! { |v| id.start_with?("#{v}/") } valid_refs.select! { |v| id.start_with?("#{v}/") }
if valid_refs.length != 1 if valid_refs.length != 1
...@@ -114,9 +114,9 @@ module ExtractsPath ...@@ -114,9 +114,9 @@ module ExtractsPath
@id = File.join(@ref, @path) @id = File.join(@ref, @path)
@commit = CommitDecorator.decorate(@project.commit(@ref)) @commit = CommitDecorator.decorate(@project.repository.commit(@ref))
@tree = Tree.new(@commit.tree, @project, @ref, @path) @tree = Tree.new(@commit.tree, @ref, @path)
@tree = TreeDecorator.new(@tree) @tree = TreeDecorator.new(@tree)
raise InvalidPathError if @tree.invalid? raise InvalidPathError if @tree.invalid?
......
...@@ -82,7 +82,7 @@ module Gitlab ...@@ -82,7 +82,7 @@ module Gitlab
end end
def destroy_project(project) def destroy_project(project)
FileUtils.rm_rf(project.path_to_repo) FileUtils.rm_rf(project.repository.path_to_repo)
conf.rm_repo(project.path_with_namespace) conf.rm_repo(project.path_with_namespace)
end end
...@@ -138,9 +138,9 @@ module Gitlab ...@@ -138,9 +138,9 @@ module Gitlab
::Gitolite::Config::Repo.new(repo_name) ::Gitolite::Config::Repo.new(repo_name)
end end
name_readers = project.repository_readers name_readers = project.team.repository_readers
name_writers = project.repository_writers name_writers = project.team.repository_writers
name_masters = project.repository_masters name_masters = project.team.repository_masters
pr_br = project.protected_branches.map(&:name).join("$ ") pr_br = project.protected_branches.map(&:name).join("$ ")
......
...@@ -170,7 +170,7 @@ module Gitlab ...@@ -170,7 +170,7 @@ module Gitlab
end end
def reference_commit(identifier) def reference_commit(identifier)
if @project.valid_repo? && commit = @project.commit(identifier) if @project.valid_repo? && commit = @project.repository.commit(identifier)
link_to(identifier, project_commit_path(@project, commit), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}")) link_to(identifier, project_commit_path(@project, commit), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}"))
end end
end end
......
...@@ -31,7 +31,7 @@ module Gitlab ...@@ -31,7 +31,7 @@ module Gitlab
merge_repo.git.push({raise: true, timeout: true}, :origin, merge_request.target_branch) merge_repo.git.push({raise: true, timeout: true}, :origin, merge_request.target_branch)
# remove source branch # remove source branch
if merge_request.should_remove_source_branch && !project.root_ref?(merge_request.source_branch) if merge_request.should_remove_source_branch && !project.repository.root_ref?(merge_request.source_branch)
# will raise CommandFailed when push fails # will raise CommandFailed when push fails
merge_repo.git.push({raise: true, timeout: true}, :origin, ":#{merge_request.source_branch}") merge_repo.git.push({raise: true, timeout: true}, :origin, ":#{merge_request.source_branch}")
end end
......
...@@ -38,7 +38,7 @@ module StaticModel ...@@ -38,7 +38,7 @@ module StaticModel
end end
def ==(other) def ==(other)
if other.is_a? StaticModel if other.is_a? ::StaticModel
id == other.id id == other.id
else else
super super
......
...@@ -3,12 +3,12 @@ require 'spec_helper' ...@@ -3,12 +3,12 @@ require 'spec_helper'
describe CommitController do describe CommitController do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:commit) { project.last_commit_for("master") } let(:commit) { project.repository.last_commit_for("master") }
before do before do
sign_in(user) sign_in(user)
project.add_access(user, :read, :admin) project.team << [user, :master]
end end
describe "#show" do describe "#show" do
......
...@@ -7,7 +7,7 @@ describe CommitsController do ...@@ -7,7 +7,7 @@ describe CommitsController do
before do before do
sign_in(user) sign_in(user)
project.add_access(user, :read, :admin) project.team << [user, :master]
end end
describe "GET show" do describe "GET show" do
......
...@@ -7,7 +7,7 @@ describe MergeRequestsController do ...@@ -7,7 +7,7 @@ describe MergeRequestsController do
before do before do
sign_in(user) sign_in(user)
project.add_access(user, :read, :admin) project.team << [user, :master]
MergeRequestsController.any_instance.stub(validates_merge_request: true) MergeRequestsController.any_instance.stub(validates_merge_request: true)
end end
......
...@@ -7,7 +7,7 @@ describe TreeController do ...@@ -7,7 +7,7 @@ describe TreeController do
before do before do
sign_in(user) sign_in(user)
project.add_access(user, :read, :admin) project.team << [user, :master]
project.stub(:branches).and_return(['master', 'foo/bar/baz']) project.stub(:branches).and_return(['master', 'foo/bar/baz'])
project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) project.stub(:tags).and_return(['v1.0.0', 'v2.0.0'])
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment