From 0f0c562de09e325c5689b3db8e646b68322f5515 Mon Sep 17 00:00:00 2001 From: Adam Leonard Date: Thu, 20 Oct 2011 09:48:09 -0400 Subject: [PATCH 01/27] Add check to ensure that a team member has atleast one Access Role selected --- app/models/users_project.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/users_project.rb b/app/models/users_project.rb index bdc10633a3..96e2d16aff 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -9,7 +9,8 @@ class UsersProject < ActiveRecord::Base validates_uniqueness_of :user_id, :scope => [:project_id] validates_presence_of :user_id validates_presence_of :project_id - + validate :user_has_a_role_selected + delegate :name, :email, :to => :user, :prefix => true def update_gitosis_project @@ -18,6 +19,10 @@ class UsersProject < ActiveRecord::Base end end + def user_has_a_role_selected + errors.add(:base, "Please choose at least one Role in the Access list") unless read || write || admin + end + end # == Schema Information # From da48ca58914264cd58cf5e3863e9256d61b00d6a Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 21 Oct 2011 00:52:49 +0300 Subject: [PATCH 02/27] Issue #135 - Repository stay after project remove --- README.rdoc | 2 ++ lib/gitosis.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 200977877b..5e47b26922 100644 --- a/README.rdoc +++ b/README.rdoc @@ -32,6 +32,8 @@ sqlite as default db # install this library first sudo easy_install pygments + + echo "gitlabhq ALL = (git) NOPASSWD: /bin/rm" | sudo tee -a /etc/sudoers sudo gem install bundler bundle diff --git a/lib/gitosis.rb b/lib/gitosis.rb index cab7da2d43..59b3f2a2c8 100644 --- a/lib/gitosis.rb +++ b/lib/gitosis.rb @@ -42,7 +42,7 @@ class Gitosis end def destroy_project(project) - FileUtils.rm_rf(project.path_to_repo) + `rm -Rf #{project.path_to_repo}` conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf')) From 6d0175e1f641415574a8fc48909af2cb3a357882 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 20:58:04 +0300 Subject: [PATCH 03/27] cleaning --- README.rdoc | 8 +++-- db/fixtures/development/001_admin.rb | 10 ++++++- db/fixtures/production/001_admin.rb | 9 ++++++ install.rb | 32 -------------------- update.rb | 44 ---------------------------- 5 files changed, 23 insertions(+), 80 deletions(-) delete mode 100644 install.rb delete mode 100644 update.rb diff --git a/README.rdoc b/README.rdoc index 200977877b..74ffe15aaf 100644 --- a/README.rdoc +++ b/README.rdoc @@ -34,18 +34,19 @@ sqlite as default db sudo easy_install pygments sudo gem install bundler + bundle - RAILS_ENV=production rake db:setup + bundle exec rake db:setup RAILS_ENV=production # create admin user # login....admin@local.host # pass.....5iveL!fe - RAILS_ENV=production rake db:seed_fu + bundle exec rake db:seed_fu RAILS_ENV=production Install gitosis, edit conf/gitosis.yml & start server - rails s + rails s -e production == Install Gitosis sudo aptitude install gitosis @@ -63,6 +64,7 @@ Install gitosis, edit conf/gitosis.yml & start server ssh-keygen -t rsa sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub + sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update diff --git a/db/fixtures/development/001_admin.rb b/db/fixtures/development/001_admin.rb index 9c5a6da09e..cfff6bf8bc 100644 --- a/db/fixtures/development/001_admin.rb +++ b/db/fixtures/development/001_admin.rb @@ -1,4 +1,3 @@ -# Admin account admin = User.create( :email => "admin@local.host", :name => "Administrator", @@ -9,3 +8,12 @@ admin = User.create( admin.projects_limit = 10000 admin.admin = true admin.save! + +if admin.valid? +puts %q[ +Administrator account created: + +login.........admin@local.host +password......5iveL!fe +] +end diff --git a/db/fixtures/production/001_admin.rb b/db/fixtures/production/001_admin.rb index 94d1abe87c..cfff6bf8bc 100644 --- a/db/fixtures/production/001_admin.rb +++ b/db/fixtures/production/001_admin.rb @@ -8,3 +8,12 @@ admin = User.create( admin.projects_limit = 10000 admin.admin = true admin.save! + +if admin.valid? +puts %q[ +Administrator account created: + +login.........admin@local.host +password......5iveL!fe +] +end diff --git a/install.rb b/install.rb deleted file mode 100644 index a118cb5d6f..0000000000 --- a/install.rb +++ /dev/null @@ -1,32 +0,0 @@ -root_path = File.expand_path(File.dirname(__FILE__)) -require File.join(root_path, "lib", "color") -include Color - -# -# ruby ./update.rb development # or test or production (default) -# -envs = ["production", "test", "development"] -env = if envs.include?(ARGV[0]) - ARGV[0] - else - "production" - end - -puts green " == Install for ENV=#{env} ..." - -# bundle install -`bundle install` - -# migrate db -`bundle exec rake db:create RAILS_ENV=#{env}` -`bundle exec rake db:schema:load RAILS_ENV=#{env}` -`bundle exec rake db:seed_fu RAILS_ENV=#{env}` - -puts green %q[ -Administrator account created: - -login.........admin@local.host -password......5iveL!fe -] - -puts green " == Done! Now you can start server" diff --git a/update.rb b/update.rb deleted file mode 100644 index b81a408888..0000000000 --- a/update.rb +++ /dev/null @@ -1,44 +0,0 @@ -root_path = File.expand_path(File.dirname(__FILE__)) -require File.join(root_path, "lib", "color") -include Color - -def version - File.read("VERSION") -end - -# -# ruby ./update.rb development # or test or production (default) -# -envs = ["production", "test", "development"] -env = if envs.include?(ARGV[0]) - ARGV[0] - else - "production" - end - -puts yellow "== RAILS ENV | #{env}" -current_version = version -puts yellow "Your version is #{current_version}" -puts yellow "Check for new version: $ git pull origin 1x" -`git pull origin 1x` # pull from origin - -# latest version -if version == current_version - puts yellow "You have a latest version" -else - puts green "Update to #{version}" - -`bundle install` - - # migrate db -if env == "development" -`bundle exec rake db:migrate RAILS_ENV=development` -`bundle exec rake db:migrate RAILS_ENV=test` -else -`bundle exec rake db:migrate RAILS_ENV=#{env}` -end - - puts green "== Done! Now you can start/restart server" -end - - From 32f4dc7cf917d152d703e338219d1c718b97a003 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 21:14:55 +0300 Subject: [PATCH 04/27] link to file for commit diff --- app/views/commits/_diff.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/commits/_diff.html.haml b/app/views/commits/_diff.html.haml index 73652aaf9f..c88e54307e 100644 --- a/app/views/commits/_diff.html.haml +++ b/app/views/commits/_diff.html.haml @@ -31,7 +31,8 @@ - if diff.deleted_file %strong{:id => "#{diff.b_path}"}= diff.a_path - else - %strong{:id => "#{diff.b_path}"}= diff.b_path + = link_to tree_file_project_path(@project, @commit.id, diff.b_path) do + %strong{:id => "#{diff.b_path}"}= diff.b_path %br/ .diff_file_content - if file.text? From e7570250afd88934d8435678b5c618d3ac202d17 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 21:40:36 +0300 Subject: [PATCH 05/27] fix #140, commit lil refactor --- app/models/project.rb | 8 +++++ app/views/commits/_diff.html.haml | 41 ++------------------------ app/views/commits/_diff_head.html.haml | 24 +++++++++++++++ app/views/commits/_text_file.html.haml | 15 ++++++++++ spec/models/project_spec.rb | 9 ++++++ 5 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 app/views/commits/_diff_head.html.haml create mode 100644 app/views/commits/_text_file.html.haml diff --git a/app/models/project.rb b/app/models/project.rb index d70b18e793..1dd04e1fcb 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -36,6 +36,8 @@ class Project < ActiveRecord::Base validate :check_limit + validate :repo_name + after_destroy :destroy_gitosis_project after_save :update_gitosis_project @@ -168,6 +170,12 @@ class Project < ActiveRecord::Base errors[:base] << ("Cant check your ability to create project") end + def repo_name + if path == "gitosis-admin" + errors.add(:path, "Project path like 'gitosis-admin' is not allowed") + end + end + def valid_repo? repo rescue diff --git a/app/views/commits/_diff.html.haml b/app/views/commits/_diff.html.haml index c88e54307e..2807e0903d 100644 --- a/app/views/commits/_diff.html.haml +++ b/app/views/commits/_diff.html.haml @@ -1,27 +1,5 @@ -.file_stats - - @commit.diffs.each do |diff| - - if diff.deleted_file - %span.removed_file - %a{:href => "##{diff.a_path}"} - = diff.a_path - = image_tag "blueprint_delete.png" - - elsif diff.renamed_file - %span.moved_file - %a{:href => "##{diff.b_path}"} - = diff.a_path - = "->" - = diff.b_path - = image_tag "blueprint_notice.png" - - elsif diff.new_file - %span.new_file - %a{:href => "##{diff.b_path}"} - = diff.b_path - = image_tag "blueprint_add.png" - - else - %span.edit_file - %a{:href => "##{diff.b_path}"} - = diff.b_path - = image_tag "blueprint_info.png" +.file_stats= render "commits/diff_head" + - @commit.diffs.each do |diff| - next if diff.diff.empty? - file = (@commit.tree / diff.b_path) @@ -36,20 +14,7 @@ %br/ .diff_file_content - if file.text? - - lines_arr = diff.diff.lines.to_a - - line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 - - line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 - - lines = lines_arr[3..-1].join - - lines.each_line do |line| - = diff_line(line, line_new, line_old) - - if line[0] == "+" - - line_new += 1 - - elsif - - line[0] == "-" - - line_old += 1 - - else - - line_new += 1 - - line_old += 1 + = render :partial => "commits/text_file", :locals => { :diff => diff } - elsif file.image? .diff_file_content_image %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} diff --git a/app/views/commits/_diff_head.html.haml b/app/views/commits/_diff_head.html.haml new file mode 100644 index 0000000000..922c35990a --- /dev/null +++ b/app/views/commits/_diff_head.html.haml @@ -0,0 +1,24 @@ +- @commit.diffs.each do |diff| + - if diff.deleted_file + %span.removed_file + %a{:href => "##{diff.a_path}"} + = diff.a_path + = image_tag "blueprint_delete.png" + - elsif diff.renamed_file + %span.moved_file + %a{:href => "##{diff.b_path}"} + = diff.a_path + = "->" + = diff.b_path + = image_tag "blueprint_notice.png" + - elsif diff.new_file + %span.new_file + %a{:href => "##{diff.b_path}"} + = diff.b_path + = image_tag "blueprint_add.png" + - else + %span.edit_file + %a{:href => "##{diff.b_path}"} + = diff.b_path + = image_tag "blueprint_info.png" + diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml new file mode 100644 index 0000000000..b20aa8afe4 --- /dev/null +++ b/app/views/commits/_text_file.html.haml @@ -0,0 +1,15 @@ +- lines_arr = diff.diff.lines.to_a +- line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 +- line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 +- lines = lines_arr[3..-1].join +- lines.each_line do |line| + = diff_line(line, line_new, line_old) + - if line[0] == "+" + - line_new += 1 + - elsif + - line[0] == "-" + - line_old += 1 + - else + - line_new += 1 + - line_old += 1 + diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 6ed8653d76..0c62743d8e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -4,11 +4,15 @@ describe Project do describe "Associations" do it { should have_many(:users) } it { should have_many(:users_projects) } + it { should have_many(:issues) } + it { should have_many(:notes) } + it { should have_many(:snippets) } end describe "Validation" do it { should validate_presence_of(:name) } it { should validate_presence_of(:path) } + it { should validate_presence_of(:code) } end describe "Respond to" do @@ -31,6 +35,11 @@ describe Project do it { should respond_to(:commit) } end + it "should not allow 'gitosis-admin' as repo name" do + should allow_value("blah").for(:path) + should_not allow_value("gitosis-admin").for(:path) + end + it "should return valid url to repo" do project = Project.new(:path => "somewhere") project.url_to_repo.should == "git@localhost:somewhere.git" From 421b11158d8420b3fe337b63d5686c24b5644c94 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 21:51:55 +0300 Subject: [PATCH 06/27] error fields highlight --- app/assets/stylesheets/projects.css.scss | 9 +++++++++ app/models/project.rb | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 517886722c..8caa2810e7 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -638,3 +638,12 @@ tbody tr:nth-child(2n) td, tbody tr.even td { display:none; } } + +.field_with_errors { + input[type="text"], + input[type="password"], + textarea + { + background: none repeat scroll 0 0 #FFBBBB + } +} diff --git a/app/models/project.rb b/app/models/project.rb index 1dd04e1fcb..5262e55245 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -35,7 +35,6 @@ class Project < ActiveRecord::Base :presence => true validate :check_limit - validate :repo_name after_destroy :destroy_gitosis_project @@ -172,7 +171,7 @@ class Project < ActiveRecord::Base def repo_name if path == "gitosis-admin" - errors.add(:path, "Project path like 'gitosis-admin' is not allowed") + errors.add(:path, " like 'gitosis-admin' is not allowed") end end From ecd462a606b1f9fc36a46daea95d09eddddd9e89 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 22:44:08 +0300 Subject: [PATCH 07/27] test cov --- app/controllers/team_members_controller.rb | 28 ++++++---------------- spec/requests/team_members_spec.rb | 26 ++++++++++++++++---- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index 5fb2710dad..84addf8d7b 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -8,35 +8,16 @@ class TeamMembersController < ApplicationController def show @team_member = project.users_projects.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.js - end end def new @team_member = project.users_projects.new - - respond_to do |format| - format.html # new.html.erb - format.js - end end def create @team_member = UsersProject.new(params[:team_member]) @team_member.project = project - - respond_to do |format| - if @team_member.save - format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } - format.js - else - format.html { render action: "new" } - format.js - end - end + @team_member.save end def update @@ -45,7 +26,12 @@ class TeamMembersController < ApplicationController respond_to do |format| format.js - format.html { redirect_to team_project_path(@project)} + format.html do + unless @team_member.valid? + flash[:alert] = "User should have at least one role" + end + redirect_to team_project_path(@project) + end end end diff --git a/spec/requests/team_members_spec.rb b/spec/requests/team_members_spec.rb index dd92febf70..ec0af3214a 100644 --- a/spec/requests/team_members_spec.rb +++ b/spec/requests/team_members_spec.rb @@ -29,19 +29,37 @@ describe "TeamMembers" do describe "fill in" do before do - check "team_member_read" click_link "Select user" click_link @user_1.name - #select @user_1.name, :from => "team_member_user_id" + + within "#team_member_new" do + check "team_member_read" + check "team_member_write" + end end - it { expect { click_button "Save" }.to change {UsersProject.count}.by(1) } + it { expect { click_button "Save";sleep(1) }.to change {UsersProject.count}.by(1) } it "should add new member to table" do click_button "Save" + @member = UsersProject.last - page.should_not have_content("Add new member") page.should have_content @user_1.name + + @member.read.should be_true + @member.write.should be_true + @member.admin.should be_false + end + + it "should not allow creation without access selected" do + within "#team_member_new" do + uncheck "team_member_read" + uncheck "team_member_write" + uncheck "team_member_admin" + end + + expect { click_button "Save" }.to_not change {UsersProject.count} + page.should have_content("Please choose at least one Role in the Access list") end end end From 6d6eefa0e201953818592962b723c3ee4e5d0c5a Mon Sep 17 00:00:00 2001 From: VSizov Date: Sat, 22 Oct 2011 13:50:02 +0300 Subject: [PATCH 08/27] fix remove repo --- lib/gitosis.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitosis.rb b/lib/gitosis.rb index 59b3f2a2c8..1dd87c0abe 100644 --- a/lib/gitosis.rb +++ b/lib/gitosis.rb @@ -42,7 +42,7 @@ class Gitosis end def destroy_project(project) - `rm -Rf #{project.path_to_repo}` + `sudo -u git rm -Rf #{project.path_to_repo}` conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf')) From c7ccfb9a9d639ab172beaa319db09b343c65168f Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Sat, 22 Oct 2011 14:07:09 +0300 Subject: [PATCH 09/27] low case --- lib/gitosis.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitosis.rb b/lib/gitosis.rb index 1dd87c0abe..92d32d8bf7 100644 --- a/lib/gitosis.rb +++ b/lib/gitosis.rb @@ -42,7 +42,7 @@ class Gitosis end def destroy_project(project) - `sudo -u git rm -Rf #{project.path_to_repo}` + `sudo -u git rm -rf #{project.path_to_repo}` conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf')) From c66c30c821a77309302560667692854b2caabb8d Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 20 Oct 2011 09:48:09 -0400 Subject: [PATCH 10/27] Add check to ensure that a team member has atleast one Access Role selected --- app/models/users_project.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/users_project.rb b/app/models/users_project.rb index bdc10633a3..96e2d16aff 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -9,7 +9,8 @@ class UsersProject < ActiveRecord::Base validates_uniqueness_of :user_id, :scope => [:project_id] validates_presence_of :user_id validates_presence_of :project_id - + validate :user_has_a_role_selected + delegate :name, :email, :to => :user, :prefix => true def update_gitosis_project @@ -18,6 +19,10 @@ class UsersProject < ActiveRecord::Base end end + def user_has_a_role_selected + errors.add(:base, "Please choose at least one Role in the Access list") unless read || write || admin + end + end # == Schema Information # From 977fe7307320ccd7613ea97823b68ab356ebbe60 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 09:58:28 +0300 Subject: [PATCH 11/27] prepare for 1.1 --- CHANGELOG | 2 ++ VERSION | 2 +- update.rb | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index aa8461661e..96acfba144 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ v 1.1.0 + - project dashboard + - wall redesigned - feature: code snippets - fixed horizontal scroll on file preview - fixed app crash if commit message has invalid chars diff --git a/VERSION b/VERSION index 6d7de6e6ab..9084fa2f71 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.2 +1.1.0 diff --git a/update.rb b/update.rb index dccb7df369..b81a408888 100644 --- a/update.rb +++ b/update.rb @@ -19,8 +19,8 @@ env = if envs.include?(ARGV[0]) puts yellow "== RAILS ENV | #{env}" current_version = version puts yellow "Your version is #{current_version}" -puts yellow "Check for new version: $ git pull origin" -`git pull origin` # pull from origin +puts yellow "Check for new version: $ git pull origin 1x" +`git pull origin 1x` # pull from origin # latest version if version == current_version From 24f04c0a6154c6d5890642fb8a8ec16b44146547 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 14:03:34 +0300 Subject: [PATCH 12/27] recent radio button --- app/controllers/projects_controller.rb | 32 ++++++++++++-------------- app/models/note.rb | 1 + app/models/project.rb | 28 ++++++++++++++++++++++ app/views/projects/show.html.haml | 7 ++++-- app/views/projects/wall.html.haml | 5 +++- spec/requests/projects_spec.rb | 2 +- 6 files changed, 54 insertions(+), 21 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index dc94bae2c7..5ccfe4bb34 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -60,24 +60,21 @@ class ProjectsController < ApplicationController end def show - if @project.repo_exists? - @date = case params[:view] - when "week" then Date.today - 7.days - else Date.today - end.at_beginning_of_day + return render "projects/empty" unless @project.repo_exists? + @date = case params[:view] + when "week" then Date.today - 7.days + when "day" then Date.today + else nil + end - @heads = @project.repo.heads - @commits = @heads.map do |h| - @project.repo.log(h.name, nil, :since => @date) - end.flatten.uniq { |c| c.id } - - @commits.sort! do |x, y| - y.committed_date <=> x.committed_date - end + if @date + @date = @date.at_beginning_of_day + @commits = @project.commits_since(@date) @messages = project.notes.since(@date).order("created_at DESC") - else - return render "projects/empty" + else + @commits = @project.fresh_commits + @messages = project.notes.fresh.limit(10) end end @@ -89,11 +86,12 @@ class ProjectsController < ApplicationController @date = case params[:view] when "week" then Date.today - 7.days when "all" then nil - else Date.today + when "day" then Date.today + else nil end @notes = @project.common_notes.order("created_at DESC") - @notes = @notes.since(@date.at_beginning_of_day) if @date + @notes = @date ? @notes.since(@date.at_beginning_of_day) : @notes.fresh.limit(10) @note = Note.new end diff --git a/app/models/note.rb b/app/models/note.rb index 71fd9dcd13..e3dabce479 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -24,6 +24,7 @@ class Note < ActiveRecord::Base scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days)) scope :since, lambda { |day| where("created_at >= :date", :date => (day)) } + scope :fresh, order("created_at DESC") mount_uploader :attachment, AttachmentUploader end diff --git a/app/models/project.rb b/app/models/project.rb index f51bd9b3ad..d70b18e793 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -126,6 +126,34 @@ class Project < ActiveRecord::Base end end + def heads + @heads ||= repo.heads + end + + def fresh_commits + commits = heads.map do |h| + repo.commits(h.name, 10) + end.flatten.uniq { |c| c.id } + + commits.sort! do |x, y| + y.committed_date <=> x.committed_date + end + + commits[0..10] + end + + def commits_since(date) + commits = heads.map do |h| + repo.log(h.name, nil, :since => date) + end.flatten.uniq { |c| c.id } + + commits.sort! do |x, y| + y.committed_date <=> x.committed_date + end + + commits + end + def tree(fcommit, path = nil) fcommit = commit if fcommit == :head tree = fcommit.tree diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index ff6078c15a..85019ecbe5 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -1,9 +1,12 @@ %div - %h2.left Recent history + %h2.left History .right = form_tag project_path(@project), :method => :get do .span-2 - = radio_button_tag :view, "day", (params[:view] || "day") == "day", :onclick => "this.form.submit()", :id => "day_view" + = radio_button_tag :view, "recent", (params[:view] || "recent") == "recent", :onclick => "this.form.submit()", :id => "recent_view" + = label_tag "recent_view","Recent" + .span-2 + = radio_button_tag :view, "day", params[:view] == "day", :onclick => "this.form.submit()", :id => "day_view" = label_tag "day_view","Today" .span-2 = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" diff --git a/app/views/projects/wall.html.haml b/app/views/projects/wall.html.haml index d3dcb3530a..ed22478c92 100644 --- a/app/views/projects/wall.html.haml +++ b/app/views/projects/wall.html.haml @@ -4,7 +4,10 @@ .right = form_tag wall_project_path(@project), :method => :get do .span-2 - = radio_button_tag :view, "day", (params[:view] || "day") == "day", :onclick => "this.form.submit()", :id => "day_view" + = radio_button_tag :view, "recent", (params[:view] || "recent") == "recent", :onclick => "this.form.submit()", :id => "recent_view" + = label_tag "recent_view","Recent" + .span-2 + = radio_button_tag :view, "day", params[:view] == "day", :onclick => "this.form.submit()", :id => "day_view" = label_tag "day_view","Today" .span-2 = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb index a1bac06240..945c1ea26f 100644 --- a/spec/requests/projects_spec.rb +++ b/spec/requests/projects_spec.rb @@ -73,7 +73,7 @@ describe "Projects" do end it "should beahave like dashboard" do - page.should have_content("Recent history") + page.should have_content("History") end end From d49645a01348e093b87586b3575e93233d497aea Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 14:25:42 +0300 Subject: [PATCH 13/27] fixed wall --all option --- app/controllers/projects_controller.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5ccfe4bb34..54d19af751 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -83,16 +83,15 @@ class ProjectsController < ApplicationController # def wall - @date = case params[:view] - when "week" then Date.today - 7.days - when "all" then nil - when "day" then Date.today - else nil - end - - @notes = @project.common_notes.order("created_at DESC") - @notes = @date ? @notes.since(@date.at_beginning_of_day) : @notes.fresh.limit(10) @note = Note.new + @notes = @project.common_notes.order("created_at DESC") + + @notes = case params[:view] + when "week" then @notes.since((Date.today - 7.days).at_beginning_of_day) + when "all" then @notes.all + when "day" then @notes.since(Date.today.at_beginning_of_day) + else @notes.fresh.limit(10) + end end # From b3279b9b5170a19a2aa504eae94a9a8be5908755 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 15:35:42 +0300 Subject: [PATCH 14/27] moved from albino -> pygments.rb --- Gemfile | 2 +- Gemfile.lock | 15 +++++++-------- app/models/snippet.rb | 3 +-- app/views/projects/_tree_file.html.haml | 1 + app/views/projects/empty.html.erb | 7 ++++--- config/initializers/grit_ext.rb | 2 +- lib/utils.rb | 8 ++++++-- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index 523793e7ca..77a00659ac 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem 'therubyracer' gem 'faker' gem 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git' gem "inifile" -gem "albino", :git => "git://github.com/gitlabhq/albino.git" +gem "pygments.rb", "0.2.3" gem "kaminari" gem "thin" gem "git" diff --git a/Gemfile.lock b/Gemfile.lock index 2aa894aa87..5ba3445975 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,13 +4,6 @@ GIT specs: annotate (2.4.1.beta1) -GIT - remote: git://github.com/gitlabhq/albino.git - revision: 118380924969f3a856659f86ea1f40c1ba7bfcb1 - specs: - albino (1.3.3) - posix-spawn (>= 0.3.6) - GIT remote: git://github.com/gitlabhq/grit.git revision: ff015074ef35bd94cba943f9c0f98e161ab5851c @@ -72,6 +65,7 @@ GEM ZenTest (= 4.5) awesome_print (0.4.0) bcrypt-ruby (3.0.1) + blankslate (2.1.2.4) builder (3.0.0) capybara (1.0.1) mime-types (>= 1.16) @@ -138,6 +132,8 @@ GEM orm_adapter (0.0.5) polyglot (0.3.2) posix-spawn (0.3.6) + pygments.rb (0.2.3) + rubypython (>= 0.5.1) rack (1.3.2) rack-cache (1.0.3) rack (>= 0.4) @@ -189,6 +185,9 @@ GEM ruby-debug-base19 (>= 0.11.19) ruby_core_source (0.1.5) archive-tar-minitar (>= 0.5.2) + rubypython (0.5.1) + blankslate (>= 2.1.2.3) + ffi (~> 1.0.7) rubyzip (0.9.4) sass (3.1.7) sass-rails (3.1.1) @@ -242,7 +241,6 @@ PLATFORMS DEPENDENCIES acts_as_list - albino! annotate! autotest autotest-rails @@ -260,6 +258,7 @@ DEPENDENCIES jquery-rails kaminari launchy + pygments.rb (= 0.2.3) rails (= 3.1.0) rails-footnotes (>= 3.7.5.rc4) rspec-rails diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 119b69a452..95d6a07d54 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -32,8 +32,7 @@ class Snippet < ActiveRecord::Base end def colorize - ft = handle_file_type(file_name) - Albino.colorize(content, ft, :html, 'utf-8', "linenos=True") + system_colorize(content, file_name) end end # == Schema Information diff --git a/app/views/projects/_tree_file.html.haml b/app/views/projects/_tree_file.html.haml index ae95d48317..41a2287aa8 100644 --- a/app/views/projects/_tree_file.html.haml +++ b/app/views/projects/_tree_file.html.haml @@ -1,3 +1,4 @@ +:css .view_file .view_file_header %strong diff --git a/app/views/projects/empty.html.erb b/app/views/projects/empty.html.erb index a891747155..4c60facde8 100644 --- a/app/views/projects/empty.html.erb +++ b/app/views/projects/empty.html.erb @@ -1,3 +1,4 @@ +<% bash_lexer = Pygments::Lexer[:bash] %>

Git global setup:

@@ -6,7 +7,7 @@ git config --global user.name "#{current_user.name}" git config --global user.email "#{current_user.email}" eos %> - <%= raw Albino.colorize(setup_str, :bash) %> + <%= raw bash_lexer.highlight(setup_str) %>

Next steps:

@@ -21,7 +22,7 @@ git remote add origin #{@project.url_to_repo} git push -u origin master eos %> - <%= raw Albino.colorize(repo_setup_str, :bash) %> + <%= raw bash_lexer.highlight(repo_setup_str) %>

Existing Git Repo?

@@ -31,7 +32,7 @@ git remote add origin #{@project.url_to_repo} git push -u origin master eos %> - <%= raw Albino.colorize(exist_repo_setup_str, :bash) %> + <%= raw bash_lexer.highlight(exist_repo_setup_str) %>

Remove this project?

diff --git a/config/initializers/grit_ext.rb b/config/initializers/grit_ext.rb index 8f1329a660..4bd7100353 100644 --- a/config/initializers/grit_ext.rb +++ b/config/initializers/grit_ext.rb @@ -1,5 +1,5 @@ require 'grit' -require 'albino' +require 'pygments' require "utils" Grit::Blob.class_eval do diff --git a/lib/utils.rb b/lib/utils.rb index 40bf26735c..e57121a3e2 100644 --- a/lib/utils.rb +++ b/lib/utils.rb @@ -18,8 +18,12 @@ module Utils module Colorize def colorize - ft = handle_file_type(name, mime_type) - Albino.colorize(data, ft, :html, 'utf-8', "linenos=True") + system_colorize(data, name) + end + + def system_colorize(data, file_name) + ft = handle_file_type(file_name) + Pygments.highlight(data, :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' }) end def handle_file_type(file_name, mime_type = nil) From 9fa4df16ec8f8317c83371c5768c30e276e49ae9 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 15:56:37 +0300 Subject: [PATCH 15/27] now you can view comrade profile info #134 --- app/views/projects/_top_menu.html.haml | 2 +- app/views/team_members/_show.html.haml | 6 ++-- app/views/team_members/show.html.haml | 28 +++++++++++++++++++ ...021101550_change_social_fields_in_users.rb | 10 +++++++ db/schema.rb | 8 +++--- spec/requests/team_members_spec.rb | 9 ++++++ spec/support/login.rb | 3 +- 7 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 app/views/team_members/show.html.haml create mode 100644 db/migrate/20111021101550_change_social_fields_in_users.rb diff --git a/app/views/projects/_top_menu.html.haml b/app/views/projects/_top_menu.html.haml index e281b93b28..59f2533ea7 100644 --- a/app/views/projects/_top_menu.html.haml +++ b/app/views/projects/_top_menu.html.haml @@ -5,7 +5,7 @@ %span= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil %span= link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil %span - = link_to team_project_path(@project), :class => current_page?(:controller => "projects", :action => "team", :id => @project) ? "current" : nil do + = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do Team - if @project.users_projects.count > 0 %span{ :class => "top_menu_count" }= @project.users_projects.count diff --git a/app/views/team_members/_show.html.haml b/app/views/team_members/_show.html.haml index 6d310768af..b9a68e6cfb 100644 --- a/app/views/team_members/_show.html.haml +++ b/app/views/team_members/_show.html.haml @@ -1,8 +1,10 @@ - user = member.user %tr{:id => dom_id(member)} %td - = image_tag gravatar_icon(user.email), :class => "left", :width => 40, :style => "padding:0 5px;" - = truncate user.name, :lenght => 16 + = link_to image_tag(gravatar_icon(user.email), :class => "left", :width => 40, :style => "padding:0 5px;"), project_team_member_path(@project, member) + + = link_to truncate(user.name, :lenght => 16), project_team_member_path(@project, member) + %td= truncate user.email, :lenght => 16 - if can? current_user, :admin_project, @project = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| diff --git a/app/views/team_members/show.html.haml b/app/views/team_members/show.html.haml new file mode 100644 index 0000000000..d07c54f8b6 --- /dev/null +++ b/app/views/team_members/show.html.haml @@ -0,0 +1,28 @@ +- user = @team_member.user +.span-2 + = image_tag gravatar_icon(user.email), :class => "left", :width => 60, :style => "padding-right:5px;" +%p + %b Name: + = user.name +%p + %b Email: + = user.email + +%br + +- unless user.skype.empty? + .div + %b Skype: + = user.skype + +- unless user.linkedin.empty? + .div + %b LinkedIn: + = user.linkedin + +- unless user.twitter.empty? + .div + %b Twitter: + = user.twitter + + diff --git a/db/migrate/20111021101550_change_social_fields_in_users.rb b/db/migrate/20111021101550_change_social_fields_in_users.rb new file mode 100644 index 0000000000..6f05c05da7 --- /dev/null +++ b/db/migrate/20111021101550_change_social_fields_in_users.rb @@ -0,0 +1,10 @@ +class ChangeSocialFieldsInUsers < ActiveRecord::Migration + def up + change_column(:users, :skype, :string, {:null => false, :default => ''}) + change_column(:users, :linkedin, :string, {:null => false, :default => ''}) + change_column(:users, :twitter, :string, {:null => false, :default => ''}) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 6408792f9a..cc805990a8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111019212429) do +ActiveRecord::Schema.define(:version => 20111021101550) do create_table "issues", :force => true do |t| t.string "title" @@ -82,9 +82,9 @@ ActiveRecord::Schema.define(:version => 20111019212429) do t.string "name" t.boolean "admin", :default => false, :null => false t.integer "projects_limit", :default => 10 - t.string "skype" - t.string "linkedin" - t.string "twitter" + t.string "skype", :default => "", :null => false + t.string "linkedin", :default => "", :null => false + t.string "twitter", :default => "", :null => false end add_index "users", ["email"], :name => "index_users_on_email", :unique => true diff --git a/spec/requests/team_members_spec.rb b/spec/requests/team_members_spec.rb index db7513ae95..dd92febf70 100644 --- a/spec/requests/team_members_spec.rb +++ b/spec/requests/team_members_spec.rb @@ -7,6 +7,15 @@ describe "TeamMembers" do @project.add_access(@user, :read, :admin) end + describe "View profile" do + it "should be available" do + visit(team_project_path(@project)) + find(:xpath, "//table[@id='team-table']//a[1]").click + page.should have_content @user.skype + page.should_not have_content 'Twitter' + end + end + describe "New Team member", :js => true do before do @user_1 = Factory :user diff --git a/spec/support/login.rb b/spec/support/login.rb index 09f64f9e3c..462647ab85 100644 --- a/spec/support/login.rb +++ b/spec/support/login.rb @@ -3,7 +3,8 @@ module LoginMacros @user = User.create(:email => "user#{User.count}@mail.com", :name => "John Smith", :password => "123456", - :password_confirmation => "123456") + :password_confirmation => "123456", + :skype => 'user_skype') if role == :admin @user.admin = true From 1c2660729003932183ec6c7973e4ee15192f99d7 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 16:36:33 +0300 Subject: [PATCH 16/27] corrected last migration --- .../20111021101550_change_social_fields_in_users.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/db/migrate/20111021101550_change_social_fields_in_users.rb b/db/migrate/20111021101550_change_social_fields_in_users.rb index 6f05c05da7..6e506c1cf9 100644 --- a/db/migrate/20111021101550_change_social_fields_in_users.rb +++ b/db/migrate/20111021101550_change_social_fields_in_users.rb @@ -1,8 +1,12 @@ class ChangeSocialFieldsInUsers < ActiveRecord::Migration def up - change_column(:users, :skype, :string, {:null => false, :default => ''}) - change_column(:users, :linkedin, :string, {:null => false, :default => ''}) - change_column(:users, :twitter, :string, {:null => false, :default => ''}) + remove_column :users, :skype + remove_column :users, :linkedin + remove_column :users, :twitter + + add_column :users, :skype, :string, {:null => false, :default => ''} + add_column :users, :linkedin, :string, {:null => false, :default => ''} + add_column :users, :twitter, :string, {:null => false, :default => ''} end def down From 35d24b3928a0905d23e8e33bbc9a89d33fa0a480 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 20:58:04 +0300 Subject: [PATCH 17/27] cleaning --- README.rdoc | 8 +++-- db/fixtures/development/001_admin.rb | 10 ++++++- db/fixtures/production/001_admin.rb | 9 ++++++ install.rb | 32 -------------------- update.rb | 44 ---------------------------- 5 files changed, 23 insertions(+), 80 deletions(-) delete mode 100644 install.rb delete mode 100644 update.rb diff --git a/README.rdoc b/README.rdoc index 5e47b26922..3e604a0f78 100644 --- a/README.rdoc +++ b/README.rdoc @@ -36,18 +36,19 @@ sqlite as default db echo "gitlabhq ALL = (git) NOPASSWD: /bin/rm" | sudo tee -a /etc/sudoers sudo gem install bundler + bundle - RAILS_ENV=production rake db:setup + bundle exec rake db:setup RAILS_ENV=production # create admin user # login....admin@local.host # pass.....5iveL!fe - RAILS_ENV=production rake db:seed_fu + bundle exec rake db:seed_fu RAILS_ENV=production Install gitosis, edit conf/gitosis.yml & start server - rails s + rails s -e production == Install Gitosis sudo aptitude install gitosis @@ -65,6 +66,7 @@ Install gitosis, edit conf/gitosis.yml & start server ssh-keygen -t rsa sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub + sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update diff --git a/db/fixtures/development/001_admin.rb b/db/fixtures/development/001_admin.rb index 9c5a6da09e..cfff6bf8bc 100644 --- a/db/fixtures/development/001_admin.rb +++ b/db/fixtures/development/001_admin.rb @@ -1,4 +1,3 @@ -# Admin account admin = User.create( :email => "admin@local.host", :name => "Administrator", @@ -9,3 +8,12 @@ admin = User.create( admin.projects_limit = 10000 admin.admin = true admin.save! + +if admin.valid? +puts %q[ +Administrator account created: + +login.........admin@local.host +password......5iveL!fe +] +end diff --git a/db/fixtures/production/001_admin.rb b/db/fixtures/production/001_admin.rb index 94d1abe87c..cfff6bf8bc 100644 --- a/db/fixtures/production/001_admin.rb +++ b/db/fixtures/production/001_admin.rb @@ -8,3 +8,12 @@ admin = User.create( admin.projects_limit = 10000 admin.admin = true admin.save! + +if admin.valid? +puts %q[ +Administrator account created: + +login.........admin@local.host +password......5iveL!fe +] +end diff --git a/install.rb b/install.rb deleted file mode 100644 index a118cb5d6f..0000000000 --- a/install.rb +++ /dev/null @@ -1,32 +0,0 @@ -root_path = File.expand_path(File.dirname(__FILE__)) -require File.join(root_path, "lib", "color") -include Color - -# -# ruby ./update.rb development # or test or production (default) -# -envs = ["production", "test", "development"] -env = if envs.include?(ARGV[0]) - ARGV[0] - else - "production" - end - -puts green " == Install for ENV=#{env} ..." - -# bundle install -`bundle install` - -# migrate db -`bundle exec rake db:create RAILS_ENV=#{env}` -`bundle exec rake db:schema:load RAILS_ENV=#{env}` -`bundle exec rake db:seed_fu RAILS_ENV=#{env}` - -puts green %q[ -Administrator account created: - -login.........admin@local.host -password......5iveL!fe -] - -puts green " == Done! Now you can start server" diff --git a/update.rb b/update.rb deleted file mode 100644 index b81a408888..0000000000 --- a/update.rb +++ /dev/null @@ -1,44 +0,0 @@ -root_path = File.expand_path(File.dirname(__FILE__)) -require File.join(root_path, "lib", "color") -include Color - -def version - File.read("VERSION") -end - -# -# ruby ./update.rb development # or test or production (default) -# -envs = ["production", "test", "development"] -env = if envs.include?(ARGV[0]) - ARGV[0] - else - "production" - end - -puts yellow "== RAILS ENV | #{env}" -current_version = version -puts yellow "Your version is #{current_version}" -puts yellow "Check for new version: $ git pull origin 1x" -`git pull origin 1x` # pull from origin - -# latest version -if version == current_version - puts yellow "You have a latest version" -else - puts green "Update to #{version}" - -`bundle install` - - # migrate db -if env == "development" -`bundle exec rake db:migrate RAILS_ENV=development` -`bundle exec rake db:migrate RAILS_ENV=test` -else -`bundle exec rake db:migrate RAILS_ENV=#{env}` -end - - puts green "== Done! Now you can start/restart server" -end - - From 29e11d1461a5689ff295adb035e38564701ad377 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 21:14:55 +0300 Subject: [PATCH 18/27] link to file for commit diff --- app/views/commits/_diff.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/commits/_diff.html.haml b/app/views/commits/_diff.html.haml index 73652aaf9f..c88e54307e 100644 --- a/app/views/commits/_diff.html.haml +++ b/app/views/commits/_diff.html.haml @@ -31,7 +31,8 @@ - if diff.deleted_file %strong{:id => "#{diff.b_path}"}= diff.a_path - else - %strong{:id => "#{diff.b_path}"}= diff.b_path + = link_to tree_file_project_path(@project, @commit.id, diff.b_path) do + %strong{:id => "#{diff.b_path}"}= diff.b_path %br/ .diff_file_content - if file.text? From 1a9531c9a42e380d922de98ad1658e85ac5fbde6 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 21:40:36 +0300 Subject: [PATCH 19/27] fix #140, commit lil refactor --- app/models/project.rb | 8 +++++ app/views/commits/_diff.html.haml | 41 ++------------------------ app/views/commits/_diff_head.html.haml | 24 +++++++++++++++ app/views/commits/_text_file.html.haml | 15 ++++++++++ spec/models/project_spec.rb | 9 ++++++ 5 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 app/views/commits/_diff_head.html.haml create mode 100644 app/views/commits/_text_file.html.haml diff --git a/app/models/project.rb b/app/models/project.rb index d70b18e793..1dd04e1fcb 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -36,6 +36,8 @@ class Project < ActiveRecord::Base validate :check_limit + validate :repo_name + after_destroy :destroy_gitosis_project after_save :update_gitosis_project @@ -168,6 +170,12 @@ class Project < ActiveRecord::Base errors[:base] << ("Cant check your ability to create project") end + def repo_name + if path == "gitosis-admin" + errors.add(:path, "Project path like 'gitosis-admin' is not allowed") + end + end + def valid_repo? repo rescue diff --git a/app/views/commits/_diff.html.haml b/app/views/commits/_diff.html.haml index c88e54307e..2807e0903d 100644 --- a/app/views/commits/_diff.html.haml +++ b/app/views/commits/_diff.html.haml @@ -1,27 +1,5 @@ -.file_stats - - @commit.diffs.each do |diff| - - if diff.deleted_file - %span.removed_file - %a{:href => "##{diff.a_path}"} - = diff.a_path - = image_tag "blueprint_delete.png" - - elsif diff.renamed_file - %span.moved_file - %a{:href => "##{diff.b_path}"} - = diff.a_path - = "->" - = diff.b_path - = image_tag "blueprint_notice.png" - - elsif diff.new_file - %span.new_file - %a{:href => "##{diff.b_path}"} - = diff.b_path - = image_tag "blueprint_add.png" - - else - %span.edit_file - %a{:href => "##{diff.b_path}"} - = diff.b_path - = image_tag "blueprint_info.png" +.file_stats= render "commits/diff_head" + - @commit.diffs.each do |diff| - next if diff.diff.empty? - file = (@commit.tree / diff.b_path) @@ -36,20 +14,7 @@ %br/ .diff_file_content - if file.text? - - lines_arr = diff.diff.lines.to_a - - line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 - - line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 - - lines = lines_arr[3..-1].join - - lines.each_line do |line| - = diff_line(line, line_new, line_old) - - if line[0] == "+" - - line_new += 1 - - elsif - - line[0] == "-" - - line_old += 1 - - else - - line_new += 1 - - line_old += 1 + = render :partial => "commits/text_file", :locals => { :diff => diff } - elsif file.image? .diff_file_content_image %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} diff --git a/app/views/commits/_diff_head.html.haml b/app/views/commits/_diff_head.html.haml new file mode 100644 index 0000000000..922c35990a --- /dev/null +++ b/app/views/commits/_diff_head.html.haml @@ -0,0 +1,24 @@ +- @commit.diffs.each do |diff| + - if diff.deleted_file + %span.removed_file + %a{:href => "##{diff.a_path}"} + = diff.a_path + = image_tag "blueprint_delete.png" + - elsif diff.renamed_file + %span.moved_file + %a{:href => "##{diff.b_path}"} + = diff.a_path + = "->" + = diff.b_path + = image_tag "blueprint_notice.png" + - elsif diff.new_file + %span.new_file + %a{:href => "##{diff.b_path}"} + = diff.b_path + = image_tag "blueprint_add.png" + - else + %span.edit_file + %a{:href => "##{diff.b_path}"} + = diff.b_path + = image_tag "blueprint_info.png" + diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml new file mode 100644 index 0000000000..b20aa8afe4 --- /dev/null +++ b/app/views/commits/_text_file.html.haml @@ -0,0 +1,15 @@ +- lines_arr = diff.diff.lines.to_a +- line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 +- line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 +- lines = lines_arr[3..-1].join +- lines.each_line do |line| + = diff_line(line, line_new, line_old) + - if line[0] == "+" + - line_new += 1 + - elsif + - line[0] == "-" + - line_old += 1 + - else + - line_new += 1 + - line_old += 1 + diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 6ed8653d76..0c62743d8e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -4,11 +4,15 @@ describe Project do describe "Associations" do it { should have_many(:users) } it { should have_many(:users_projects) } + it { should have_many(:issues) } + it { should have_many(:notes) } + it { should have_many(:snippets) } end describe "Validation" do it { should validate_presence_of(:name) } it { should validate_presence_of(:path) } + it { should validate_presence_of(:code) } end describe "Respond to" do @@ -31,6 +35,11 @@ describe Project do it { should respond_to(:commit) } end + it "should not allow 'gitosis-admin' as repo name" do + should allow_value("blah").for(:path) + should_not allow_value("gitosis-admin").for(:path) + end + it "should return valid url to repo" do project = Project.new(:path => "somewhere") project.url_to_repo.should == "git@localhost:somewhere.git" From 72d15cc7caf7e457a578d13b496b6b461487f1fc Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 21:51:55 +0300 Subject: [PATCH 20/27] error fields highlight --- app/assets/stylesheets/projects.css.scss | 9 +++++++++ app/models/project.rb | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 517886722c..8caa2810e7 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -638,3 +638,12 @@ tbody tr:nth-child(2n) td, tbody tr.even td { display:none; } } + +.field_with_errors { + input[type="text"], + input[type="password"], + textarea + { + background: none repeat scroll 0 0 #FFBBBB + } +} diff --git a/app/models/project.rb b/app/models/project.rb index 1dd04e1fcb..5262e55245 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -35,7 +35,6 @@ class Project < ActiveRecord::Base :presence => true validate :check_limit - validate :repo_name after_destroy :destroy_gitosis_project @@ -172,7 +171,7 @@ class Project < ActiveRecord::Base def repo_name if path == "gitosis-admin" - errors.add(:path, "Project path like 'gitosis-admin' is not allowed") + errors.add(:path, " like 'gitosis-admin' is not allowed") end end From 00290b9214e4dc4688e93c04489a7551da697ee6 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 22:44:08 +0300 Subject: [PATCH 21/27] test cov --- app/controllers/team_members_controller.rb | 28 ++++++---------------- spec/requests/team_members_spec.rb | 26 ++++++++++++++++---- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index 5fb2710dad..84addf8d7b 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -8,35 +8,16 @@ class TeamMembersController < ApplicationController def show @team_member = project.users_projects.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.js - end end def new @team_member = project.users_projects.new - - respond_to do |format| - format.html # new.html.erb - format.js - end end def create @team_member = UsersProject.new(params[:team_member]) @team_member.project = project - - respond_to do |format| - if @team_member.save - format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } - format.js - else - format.html { render action: "new" } - format.js - end - end + @team_member.save end def update @@ -45,7 +26,12 @@ class TeamMembersController < ApplicationController respond_to do |format| format.js - format.html { redirect_to team_project_path(@project)} + format.html do + unless @team_member.valid? + flash[:alert] = "User should have at least one role" + end + redirect_to team_project_path(@project) + end end end diff --git a/spec/requests/team_members_spec.rb b/spec/requests/team_members_spec.rb index dd92febf70..ec0af3214a 100644 --- a/spec/requests/team_members_spec.rb +++ b/spec/requests/team_members_spec.rb @@ -29,19 +29,37 @@ describe "TeamMembers" do describe "fill in" do before do - check "team_member_read" click_link "Select user" click_link @user_1.name - #select @user_1.name, :from => "team_member_user_id" + + within "#team_member_new" do + check "team_member_read" + check "team_member_write" + end end - it { expect { click_button "Save" }.to change {UsersProject.count}.by(1) } + it { expect { click_button "Save";sleep(1) }.to change {UsersProject.count}.by(1) } it "should add new member to table" do click_button "Save" + @member = UsersProject.last - page.should_not have_content("Add new member") page.should have_content @user_1.name + + @member.read.should be_true + @member.write.should be_true + @member.admin.should be_false + end + + it "should not allow creation without access selected" do + within "#team_member_new" do + uncheck "team_member_read" + uncheck "team_member_write" + uncheck "team_member_admin" + end + + expect { click_button "Save" }.to_not change {UsersProject.count} + page.should have_content("Please choose at least one Role in the Access list") end end end From edeb20e95bd26a08b10f211b33fb5bedce9b9957 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Sat, 22 Oct 2011 14:48:10 +0300 Subject: [PATCH 22/27] readme for v1.1.0 --- README.rdoc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.rdoc b/README.rdoc index 3e604a0f78..4016ebba5b 100644 --- a/README.rdoc +++ b/README.rdoc @@ -28,12 +28,18 @@ sqlite as default db git clone git://github.com/gitlabhq/gitlabhq.git + cd gitlabhq/ # install this library first sudo easy_install pygments - - echo "gitlabhq ALL = (git) NOPASSWD: /bin/rm" | sudo tee -a /etc/sudoers + + # give your user access to remove git repo + # Ex. + # If you are going to use user 'gitlabhq' for rails server + # gitlabhq ALL = (git) NOPASSWD: /bin/rm" | sudo tee -a /etc/sudoers + # + echo "USERNAME ALL = (git) NOPASSWD: /bin/rm" | sudo tee -a /etc/sudoers sudo gem install bundler @@ -87,3 +93,8 @@ Install gitosis, edit conf/gitosis.yml & start server echo "gem: --no-rdoc --no-ri" > ~/.gemrc + +== Contribute + +We develop project on our private server. +Want to help? Contact us on twitter or email to become a team member. From 61e6751ea676d23f5ef88de6d0bf9c273f785516 Mon Sep 17 00:00:00 2001 From: Sairam Kunala Date: Sun, 23 Oct 2011 12:47:57 +0530 Subject: [PATCH 23/27] bug fix: history in commit history not working as expected for tags and branches --- app/views/projects/_tree.html.haml | 8 ++++---- app/views/projects/_tree_file.html.haml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/projects/_tree.html.haml b/app/views/projects/_tree.html.haml index d190358640..11b04a3ba4 100644 --- a/app/views/projects/_tree.html.haml +++ b/app/views/projects/_tree.html.haml @@ -30,15 +30,15 @@ %th Last Update %th Last commit - = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right" + = link_to "history", project_commits_path(@project, :path => params[:path], :branch => params[:branch],:tag => params[:tag]), :class => "right" - if params[:path] - file = File.join(params[:path], "..") %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) } %td.tree-item-file-name = image_tag "dir.png" = link_to "..", tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true - %td - %td + %td + %td - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content| = render :partial => "projects/tree_item", :locals => { :content => content } @@ -52,7 +52,7 @@ }); - if params[:path] && request.xhr? - :javascript + :javascript $(window).unbind('popstate'); $(window).bind('popstate', function() { if(location.pathname.search("tree") != -1) { diff --git a/app/views/projects/_tree_file.html.haml b/app/views/projects/_tree_file.html.haml index 41a2287aa8..b5b1821388 100644 --- a/app/views/projects/_tree_file.html.haml +++ b/app/views/projects/_tree_file.html.haml @@ -4,7 +4,7 @@ %strong = name = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" - = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" + = link_to "history", project_commits_path(@project, :path => params[:path], :branch => params[:branch], :tag => params[:tag] ), :class => "right", :style => "margin-right:10px;" %br/ - if file.text? .view_file_content @@ -14,6 +14,6 @@ .view_file_content_image %img{ :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - else - %p + %p %center No preview for this file type From 5baa5fad0a1c6e2b8790f07f62c088fd505406d9 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Mon, 24 Oct 2011 22:38:03 +0300 Subject: [PATCH 24/27] Issue #149 --- app/helpers/commits_helper.rb | 9 --------- app/views/commits/_commits.html.haml | 2 +- app/views/commits/show.html.haml | 2 +- app/views/projects/_recent_commits.html.haml | 2 +- app/views/projects/_recent_messages.html.haml | 2 +- app/views/projects/_tree_item.html.haml | 2 +- config/initializers/grit_ext.rb | 4 ++++ lib/commit_ext.rb | 9 +++++++++ 8 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 lib/commit_ext.rb diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index b79e571819..f1b546684f 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -21,13 +21,4 @@ module CommitsHelper link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit), :remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link" end - - # Cause some errors with trucate & encoding use this method - def truncate_commit_message(commit, size = 60) - message = commit.message - message.length > size ? (message[0..(size - 1)] + "...") : message - # if special characters occurs - rescue - commit.message - end end diff --git a/app/views/commits/_commits.html.haml b/app/views/commits/_commits.html.haml index 94a1bd1b99..3ed70f1cff 100644 --- a/app/views/commits/_commits.html.haml +++ b/app/views/commits/_commits.html.haml @@ -11,7 +11,7 @@ = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" %p %strong - = truncate_commit_message(commit) + = commit.truncated_message = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right" %span diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml index a2c9149d06..0ba4261847 100644 --- a/app/views/commits/show.html.haml +++ b/app/views/commits/show.html.haml @@ -1,5 +1,5 @@ %h3 - = "[ #{@commit.committer} ] #{truncate_commit_message(@commit, 80)}" + = "[ #{@commit.committer} ] #{@commit.truncated_message(40)}" -#= link_to 'Back', project_commits_path(@project), :class => "button" %table.round-borders %tr diff --git a/app/views/projects/_recent_commits.html.haml b/app/views/projects/_recent_commits.html.haml index e435ea30f0..36f4b636d2 100644 --- a/app/views/projects/_recent_commits.html.haml +++ b/app/views/projects/_recent_commits.html.haml @@ -6,7 +6,7 @@ = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" %p{:style => "margin-bottom: 3px;"} %strong - = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id) + = link_to commit.truncated_message(60), project_commit_path(@project, :id => commit.id) %span %span.author diff --git a/app/views/projects/_recent_messages.html.haml b/app/views/projects/_recent_messages.html.haml index 1af7fe3bb2..36f1435b15 100644 --- a/app/views/projects/_recent_messages.html.haml +++ b/app/views/projects/_recent_messages.html.haml @@ -19,7 +19,7 @@ - css_class = "dash_commit" - commit = parent - item_code = commit.author.email - - link_item_name = truncate_commit_message(commit, 50) + - link_item_name = commit.truncated_message(50) - link_to_item = project_commit_path(@project, :id => commit.id) - else - css_class = "dash_wall" diff --git a/app/views/projects/_tree_item.html.haml b/app/views/projects/_tree_item.html.haml index 4ebcfbefea..538d2cc6e6 100644 --- a/app/views/projects/_tree_item.html.haml +++ b/app/views/projects/_tree_item.html.haml @@ -12,4 +12,4 @@ = time_ago_in_words(content_commit.committed_date) ago %td - = link_to truncate_commit_message(content_commit, 40), project_commit_path(@project, content_commit) + = link_to content_commit.truncated_message(40), project_commit_path(@project, content_commit) diff --git a/config/initializers/grit_ext.rb b/config/initializers/grit_ext.rb index 4bd7100353..9231da6ff9 100644 --- a/config/initializers/grit_ext.rb +++ b/config/initializers/grit_ext.rb @@ -6,3 +6,7 @@ Grit::Blob.class_eval do include Utils::FileHelper include Utils::Colorize end + +Grit::Commit.class_eval do + include CommitExt +end diff --git a/lib/commit_ext.rb b/lib/commit_ext.rb new file mode 100644 index 0000000000..c175fa0cc2 --- /dev/null +++ b/lib/commit_ext.rb @@ -0,0 +1,9 @@ +module CommitExt + # Cause of encoding rails truncate raise error + # this method is temporary decision + def truncated_message(size = 80) + message.length > size ? (message[0..(size - 1)] + "...") : message + rescue + "-- invalid encoding for commit message" + end +end From afe98ae74ab13d11908e74ada1d10dccc333228b Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Tue, 25 Oct 2011 07:32:02 +0300 Subject: [PATCH 25/27] Issue #149 fixed --- app/views/commits/_commits.html.haml | 2 +- app/views/commits/show.html.haml | 4 ++-- app/views/projects/_recent_commits.html.haml | 2 +- app/views/projects/_recent_messages.html.haml | 2 +- app/views/projects/_tree_item.html.haml | 2 +- lib/commit_ext.rb | 10 ++++++---- spec/requests/team_members_spec.rb | 4 +++- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/views/commits/_commits.html.haml b/app/views/commits/_commits.html.haml index 3ed70f1cff..9982306547 100644 --- a/app/views/commits/_commits.html.haml +++ b/app/views/commits/_commits.html.haml @@ -11,7 +11,7 @@ = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" %p %strong - = commit.truncated_message + = truncate(commit.safe_message, :length => 60) = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right" %span diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml index 0ba4261847..3beeada8c8 100644 --- a/app/views/commits/show.html.haml +++ b/app/views/commits/show.html.haml @@ -1,5 +1,5 @@ %h3 - = "[ #{@commit.committer} ] #{@commit.truncated_message(40)}" + = "[ #{@commit.committer} ] #{truncate(@commit.safe_message)}" -#= link_to 'Back', project_commits_path(@project), :class => "button" %table.round-borders %tr @@ -16,7 +16,7 @@ %td= @commit.committed_date %tr %td Message - %td= @commit.message + %td= @commit.safe_message %tr %td Tree %td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id) diff --git a/app/views/projects/_recent_commits.html.haml b/app/views/projects/_recent_commits.html.haml index 36f4b636d2..3157c35686 100644 --- a/app/views/projects/_recent_commits.html.haml +++ b/app/views/projects/_recent_commits.html.haml @@ -6,7 +6,7 @@ = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" %p{:style => "margin-bottom: 3px;"} %strong - = link_to commit.truncated_message(60), project_commit_path(@project, :id => commit.id) + = link_to truncate(commit.safe_message, :length => 60), project_commit_path(@project, :id => commit.id) %span %span.author diff --git a/app/views/projects/_recent_messages.html.haml b/app/views/projects/_recent_messages.html.haml index 36f1435b15..67f3449bd9 100644 --- a/app/views/projects/_recent_messages.html.haml +++ b/app/views/projects/_recent_messages.html.haml @@ -19,7 +19,7 @@ - css_class = "dash_commit" - commit = parent - item_code = commit.author.email - - link_item_name = commit.truncated_message(50) + - link_item_name = truncate(commit.safe_message, :length => 50) - link_to_item = project_commit_path(@project, :id => commit.id) - else - css_class = "dash_wall" diff --git a/app/views/projects/_tree_item.html.haml b/app/views/projects/_tree_item.html.haml index 538d2cc6e6..53c05d5a42 100644 --- a/app/views/projects/_tree_item.html.haml +++ b/app/views/projects/_tree_item.html.haml @@ -12,4 +12,4 @@ = time_ago_in_words(content_commit.committed_date) ago %td - = link_to content_commit.truncated_message(40), project_commit_path(@project, content_commit) + = link_to truncate(content_commit.safe_message, :length => 40), project_commit_path(@project, content_commit) diff --git a/lib/commit_ext.rb b/lib/commit_ext.rb index c175fa0cc2..e09dbdaf8e 100644 --- a/lib/commit_ext.rb +++ b/lib/commit_ext.rb @@ -1,8 +1,10 @@ module CommitExt - # Cause of encoding rails truncate raise error - # this method is temporary decision - def truncated_message(size = 80) - message.length > size ? (message[0..(size - 1)] + "...") : message + def safe_message + message.encode("UTF-8", + :invalid => :replace, + :undef => :replace, + :universal_newline => true, + :replace => "") rescue "-- invalid encoding for commit message" end diff --git a/spec/requests/team_members_spec.rb b/spec/requests/team_members_spec.rb index ec0af3214a..650ed4497f 100644 --- a/spec/requests/team_members_spec.rb +++ b/spec/requests/team_members_spec.rb @@ -10,7 +10,9 @@ describe "TeamMembers" do describe "View profile" do it "should be available" do visit(team_project_path(@project)) - find(:xpath, "//table[@id='team-table']//a[1]").click + within "#team-table" do + click_link(@user.name) + end page.should have_content @user.skype page.should_not have_content 'Twitter' end From 9afee5ad5298dc4c89ec74c5fda44adfc91de1b2 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Tue, 25 Oct 2011 07:34:02 +0300 Subject: [PATCH 26/27] Add critical status to issues --- app/assets/stylesheets/projects.css.scss | 34 +++++++++++++++++++ app/controllers/issues_controller.rb | 2 +- app/models/issue.rb | 11 ++++++ app/views/issues/_form.html.haml | 12 ++++--- app/views/issues/_issues.html.haml | 7 +++- app/views/issues/_show.html.haml | 20 +++++++++-- .../20111025134235_add_high_label_to_issue.rb | 5 +++ db/schema.rb | 3 +- 8 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20111025134235_add_high_label_to_issue.rb diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 8caa2810e7..3e7633a6ae 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -647,3 +647,37 @@ tbody tr:nth-child(2n) td, tbody tr.even td { background: none repeat scroll 0 0 #FFBBBB } } + +.tag { + @include round-borders-all(4px); + padding:2px 4px; + border:none; + + &.high { + background: #D12F19; + color:white; + } + + &.today { + background: #44aa22; + color:white; + } + + &.yours { + background: #4466cc; + color:white; + } + &.notes { + background: #2c5c66; + color:white; + } +} + +#issues-table .issue { + &.critical { + td { + //background: #D12F19; + //color:#fff; + } + } +} diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index cf8e1ebe66..757ada9476 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -12,7 +12,7 @@ class IssuesController < ApplicationController def index @issues = case params[:f].to_i - when 1 then @project.issues.all + when 1 then @project.issues when 2 then @project.issues.closed when 3 then @project.issues.opened.assigned(current_user) else @project.issues.opened diff --git a/app/models/issue.rb b/app/models/issue.rb index 556cdc1c1c..904965ac7e 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -18,11 +18,22 @@ class Issue < ActiveRecord::Base :presence => true, :length => { :within => 0..2000 } + scope :critical, where(:critical => true) + scope :non_critical, where(:critical => false) + scope :opened, where(:closed => false) scope :closed, where(:closed => true) scope :assigned, lambda { |u| where(:assignee_id => u.id)} acts_as_list + + def today? + Date.today == created_at.to_date + end + + def new? + today? && created_at == updated_at + end end # == Schema Information # diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml index 71acdba189..eae0ee0f52 100644 --- a/app/views/issues/_form.html.haml +++ b/app/views/issues/_form.html.haml @@ -5,17 +5,21 @@ - @issue.errors.full_messages.each do |msg| %li= msg - .span-6 + .span-8 = f.label :title = f.text_field :title, :style => "width:450px" - .span-6 + .span-8 = f.label :content = f.text_area :content, :style => "width:450px; height:130px" - .span-6.append-bottom + .span-8.append-bottom = f.label :assignee_id = f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) + .span-1 + = f.label :critical, "Critical" + %br + = f.check_box :critical - unless @issue.new_record? - .span-3.right + .span-2.right = f.label :closed %br = f.check_box :closed diff --git a/app/views/issues/_issues.html.haml b/app/views/issues/_issues.html.haml index d3e2194034..42e8371a0b 100644 --- a/app/views/issues/_issues.html.haml +++ b/app/views/issues/_issues.html.haml @@ -1,10 +1,15 @@ %table.round-borders#issues-table %tr + - if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0" + %th %th Assignee %th ID %th Title %th Closed? %th - - @issues.each do |issue| + - @issues.critical.each do |issue| + = render(:partial => 'show', :locals => {:issue => issue}) + + - @issues.non_critical.each do |issue| = render(:partial => 'show', :locals => {:issue => issue}) diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index 30157257ff..fcac006e81 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -1,10 +1,24 @@ -%tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) } +%tr{ :id => dom_id(issue), :class => "issue #{issue.critical ? "critical" : ""}", :url => project_issue_path(@project, issue) } + - if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0" + %td + = image_tag "move.png" , :class => [:handle, :left] %td - = image_tag "move.png" , :class => [:handle, :left] = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" = truncate issue.assignee.name, :lenght => 20 %td ##{issue.id} - %td= html_escape issue.title + %td + = html_escape issue.title + %br + - if issue.critical + %span.tag.high critical + - if issue.today? + %span.tag.today today + -#- if issue.author == current_user + -#%span.tag.yours yours + -#- if issue.notes.count > 0 + -#%span.tag.notes + -#= issue.notes.count + -#notes %td - if can? current_user, :write_issue, @project = form_for([@project, issue], :remote => true) do |f| diff --git a/db/migrate/20111025134235_add_high_label_to_issue.rb b/db/migrate/20111025134235_add_high_label_to_issue.rb new file mode 100644 index 0000000000..676eaaf8c1 --- /dev/null +++ b/db/migrate/20111025134235_add_high_label_to_issue.rb @@ -0,0 +1,5 @@ +class AddHighLabelToIssue < ActiveRecord::Migration + def change + add_column :issues, :critical, :boolean, :default => false, :null => false + end +end diff --git a/db/schema.rb b/db/schema.rb index cc805990a8..21c224d4a9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111021101550) do +ActiveRecord::Schema.define(:version => 20111025134235) do create_table "issues", :force => true do |t| t.string "title" @@ -23,6 +23,7 @@ ActiveRecord::Schema.define(:version => 20111021101550) do t.datetime "updated_at" t.boolean "closed", :default => false, :null => false t.integer "position", :default => 0 + t.boolean "critical", :default => false, :null => false end create_table "keys", :force => true do |t| From f6a67fbad5119e3d95e33cfd4f4e4992707d5ba0 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Tue, 25 Oct 2011 21:04:31 +0300 Subject: [PATCH 27/27] Issue #87 --- app/views/commits/_text_file.html.haml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml index b20aa8afe4..67033adea7 100644 --- a/app/views/commits/_text_file.html.haml +++ b/app/views/commits/_text_file.html.haml @@ -1,8 +1,14 @@ +- line_old = 0 +- line_new = 0 - lines_arr = diff.diff.lines.to_a -- line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 -- line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 -- lines = lines_arr[3..-1].join -- lines.each_line do |line| +- lines_arr.each do |line| + - next if line.match(/^--- a/) + - next if line.match(/^\+\+\+ b/) + - if line.match(/^@@ -/) + - line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0 + - line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0 + - next + = diff_line(line, line_new, line_old) - if line[0] == "+" - line_new += 1