From 0f604e62fb453f2359ebc0438fe7dfaff8e55d10 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Fri, 6 Jul 2012 06:08:17 -0700 Subject: [PATCH 01/33] refactor projects API --- lib/api/entities.rb | 6 +----- lib/api/helpers.rb | 4 ++++ lib/api/projects.rb | 24 ++++++++---------------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 35ad4d430ad..f57545ff2f5 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -16,11 +16,7 @@ module Gitlab expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :created_at end - class ProjectRepositoryBranches < Grape::Entity - expose :name, :commit - end - - class ProjectRepositoryTags < Grape::Entity + class RepoObject < Grape::Entity expose :name, :commit end diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 424a17b283c..e7b9a417b08 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -4,6 +4,10 @@ module Gitlab @current_user ||= User.find_by_authentication_token(params[:private_token]) end + def user_project + @project ||= current_user.projects.find_by_code(params[:id]) + end + def authenticate! error!({'message' => '401 Unauthorized'}, 401) unless current_user end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 70f8fa2aa62..34d1c23676e 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -20,8 +20,7 @@ module Gitlab # Example Request: # GET /projects/:id get ":id" do - @project = current_user.projects.find_by_code(params[:id]) - present @project, :with => Entities::Project + present user_project, :with => Entities::Project end # Get a project repository branches @@ -31,8 +30,7 @@ module Gitlab # Example Request: # GET /projects/:id/repository/branches get ":id/repository/branches" do - @project = current_user.projects.find_by_code(params[:id]) - present @project.repo.heads.sort_by(&:name), :with => Entities::ProjectRepositoryBranches + present user_project.repo.heads.sort_by(&:name), :with => Entities::RepoObject end # Get a project repository tags @@ -42,8 +40,7 @@ module Gitlab # Example Request: # GET /projects/:id/repository/tags get ":id/repository/tags" do - @project = current_user.projects.find_by_code(params[:id]) - present @project.repo.tags.sort_by(&:name).reverse, :with => Entities::ProjectRepositoryTags + present user_project.repo.tags.sort_by(&:name).reverse, :with => Entities::RepoObject end # Get a project snippet @@ -54,8 +51,7 @@ module Gitlab # Example Request: # GET /projects/:id/snippets/:snippet_id get ":id/snippets/:snippet_id" do - @project = current_user.projects.find_by_code(params[:id]) - @snippet = @project.snippets.find(params[:snippet_id]) + @snippet = user_project.snippets.find(params[:snippet_id]) present @snippet, :with => Entities::ProjectSnippet end @@ -70,8 +66,7 @@ module Gitlab # Example Request: # POST /projects/:id/snippets post ":id/snippets" do - @project = current_user.projects.find_by_code(params[:id]) - @snippet = @project.snippets.new( + @snippet = user_project.snippets.new( :title => params[:title], :file_name => params[:file_name], :expires_at => params[:lifetime], @@ -98,8 +93,7 @@ module Gitlab # Example Request: # PUT /projects/:id/snippets/:snippet_id put ":id/snippets/:snippet_id" do - @project = current_user.projects.find_by_code(params[:id]) - @snippet = @project.snippets.find(params[:snippet_id]) + @snippet = user_project.snippets.find(params[:snippet_id]) parameters = { :title => (params[:title] || @snippet.title), :file_name => (params[:file_name] || @snippet.file_name), @@ -122,8 +116,7 @@ module Gitlab # Example Request: # DELETE /projects/:id/snippets/:snippet_id delete ":id/snippets/:snippet_id" do - @project = current_user.projects.find_by_code(params[:id]) - @snippet = @project.snippets.find(params[:snippet_id]) + @snippet = user_project.snippets.find(params[:snippet_id]) @snippet.destroy end @@ -135,8 +128,7 @@ module Gitlab # Example Request: # GET /projects/:id/snippets/:snippet_id/raw get ":id/snippets/:snippet_id/raw" do - @project = current_user.projects.find_by_code(params[:id]) - @snippet = @project.snippets.find(params[:snippet_id]) + @snippet = user_project.snippets.find(params[:snippet_id]) present @snippet.content end end From 36efa2042cb94571957582c7bd4316a3559696e6 Mon Sep 17 00:00:00 2001 From: Ian Morgan Date: Thu, 19 Jul 2012 20:09:19 -0400 Subject: [PATCH 02/33] Add comments to Wiki pages --- app/assets/stylesheets/notes.scss | 3 ++- app/controllers/admin/mailer_controller.rb | 2 ++ app/controllers/notes_controller.rb | 2 ++ app/controllers/wikis_controller.rb | 2 ++ app/mailers/notify.rb | 7 ++++++ app/models/wiki.rb | 1 + app/observers/mailer_observer.rb | 1 + app/views/notify/note_wiki_email.html.haml | 24 ++++++++++++++++++ app/views/wikis/show.html.haml | 2 ++ spec/requests/wikis_notes_spec.rb | 29 ++++++++++++++++++++++ 10 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 app/views/notify/note_wiki_email.html.haml create mode 100644 spec/requests/wikis_notes_spec.rb diff --git a/app/assets/stylesheets/notes.scss b/app/assets/stylesheets/notes.scss index 39db704b1a9..39e03813a8b 100644 --- a/app/assets/stylesheets/notes.scss +++ b/app/assets/stylesheets/notes.scss @@ -14,7 +14,8 @@ border-bottom:1px solid #aaa; } -.issue_notes { +.issue_notes, +.wiki_notes { .note_content { float:left; width:400px; diff --git a/app/controllers/admin/mailer_controller.rb b/app/controllers/admin/mailer_controller.rb index 2352e189204..ec6d24bdaba 100644 --- a/app/controllers/admin/mailer_controller.rb +++ b/app/controllers/admin/mailer_controller.rb @@ -18,6 +18,8 @@ class Admin::MailerController < ApplicationController when "Issue" then @issue = Issue.first render :file => 'notify/note_issue_email', :layout => 'notify' + when "Wiki" then + render :file => 'notify/note_wiki_email', :layout => 'notify' else render :file => 'notify/note_wall_email', :layout => 'notify' end diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index a2638d9597c..9e89140e8f1 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -51,6 +51,8 @@ class NotesController < ApplicationController then project.issues.find(params[:target_id]).notes.inc_author.order("created_at DESC").limit(20) when "merge_request" then project.merge_requests.find(params[:target_id]).notes.inc_author.order("created_at DESC").limit(20) + when "wiki" + then project.wikis.find(params[:target_id]).notes.order("created_at DESC").limit(20) end @notes = if params[:last_id] diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index 9bcd20c3187..06e3564be56 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -17,6 +17,8 @@ class WikisController < ApplicationController return render_404 unless can?(current_user, :write_wiki, @project) end + @note = @project.notes.new(:noteable => @wiki) + respond_to do |format| if @wiki format.html diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index c673eb3d161..2ce940c35cc 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -46,6 +46,13 @@ class Notify < ActionMailer::Base mail(:to => recipient.email, :subject => "gitlab | note for issue #{@issue.id} | #{@note.project_name} ") end + def note_wiki_email(recipient_id, note_id) + recipient = User.find(recipient_id) + @note = Note.find(note_id) + @wiki = @note.noteable + mail(:to => recipient.email, :subject => "gitlab | note for wiki | #{@note.project_name}") + end + def new_merge_request_email(merge_request_id) @merge_request = MergeRequest.find(merge_request_id) mail(:to => @merge_request.assignee_email, :subject => "gitlab | new merge request | #{@merge_request.title} ") diff --git a/app/models/wiki.rb b/app/models/wiki.rb index ecc46fb4efb..d9ec069d14b 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -1,6 +1,7 @@ class Wiki < ActiveRecord::Base belongs_to :project belongs_to :user + has_many :notes, :as => :noteable, :dependent => :destroy validates :content, :title, :user_id, :presence => true validates :title, :length => 1..250 diff --git a/app/observers/mailer_observer.rb b/app/observers/mailer_observer.rb index 880fd5026a4..5d5f95ba7a6 100644 --- a/app/observers/mailer_observer.rb +++ b/app/observers/mailer_observer.rb @@ -34,6 +34,7 @@ class MailerObserver < ActiveRecord::Observer case note.noteable_type when "Commit"; Notify.note_commit_email(u.id, note.id).deliver when "Issue"; Notify.note_issue_email(u.id, note.id).deliver + when "Wiki"; Notify.note_wiki_email(u.id, note.id).deliver when "MergeRequest"; Notify.note_merge_request_email(u.id, note.id).deliver when "Snippet"; true else diff --git a/app/views/notify/note_wiki_email.html.haml b/app/views/notify/note_wiki_email.html.haml new file mode 100644 index 00000000000..91270682c6b --- /dev/null +++ b/app/views/notify/note_wiki_email.html.haml @@ -0,0 +1,24 @@ +%td.content{:align => "left", :style => "font-family: Helvetica, Arial, sans-serif; padding: 20px 0 0;", :valign => "top", :width => "600"} + %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :style => "color: #717171; font: normal 11px Helvetica, Arial, sans-serif; margin: 0; padding: 0;", :width => "600"} + %tr + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + %td{:align => "left", :style => "padding: 20px 0 0;"} + %h2{:style => "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} + New comment - + = link_to project_issue_url(@wiki.project, @wiki, :anchor => "note_#{@note.id}") do + = "Wiki ##{@wiki.title.to_s}" + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + %tr + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + %td{:style => "padding: 15px 0 15px;", :valign => "top"} + %p{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "} + %a{:href => "#", :style => "color: #0eb6ce; text-decoration: none;"} #{@note.author_name} + commented on Wiki page: + %br + %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :width => "558"} + %tr + %td{:valign => "top"} + %div{ :style => "background:#f5f5f5; padding:20px;border:1px solid #ddd" } + = markdown(@note.note) + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index 9aa287dff07..e9502430b34 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -15,3 +15,5 @@ - if can? current_user, :admin_wiki, @project = link_to project_wiki_path(@project, @wiki), :confirm => "Are you sure you want to delete this page?", :method => :delete do Delete this page + +.wiki_notes#notes= render "notes/notes", :tid => @wiki.id, :tt => "wiki" diff --git a/spec/requests/wikis_notes_spec.rb b/spec/requests/wikis_notes_spec.rb new file mode 100644 index 00000000000..144d0318bea --- /dev/null +++ b/spec/requests/wikis_notes_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe "Wikis" do + let(:project) { Factory :project } + + before do + login_as :user + project.add_access(@user, :read, :write) + end + + describe "add new note", :js => true do + before do + visit project_wiki_path(project, :index) + + fill_in "Title", :with => 'Test title' + fill_in "Content", :with => '[link test](test)' + click_on "Save" + + page.should have_content("Test title") + + fill_in "note_note", :with => "Comment on wiki!" + click_button "Add Comment" + end + + it "should contain the new note" do + page.should have_content("Comment on wiki!") + end + end +end From 04a85f458214304b8d96a1ea052b40e171a3f2f5 Mon Sep 17 00:00:00 2001 From: Ian Morgan Date: Fri, 20 Jul 2012 13:16:19 -0400 Subject: [PATCH 03/33] Show wiki comments for all revisions --- app/controllers/notes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 9e89140e8f1..3699d8e46ea 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -52,7 +52,7 @@ class NotesController < ApplicationController when "merge_request" then project.merge_requests.find(params[:target_id]).notes.inc_author.order("created_at DESC").limit(20) when "wiki" - then project.wikis.find(params[:target_id]).notes.order("created_at DESC").limit(20) + then project.wikis.reverse.map {|w| w.notes.fresh }.flatten[0..20] end @notes = if params[:last_id] From a2d244ec062f3348f6cd1c5218c6097402c5f562 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Sat, 21 Jul 2012 09:04:05 +0100 Subject: [PATCH 04/33] Handle LDAP missing credentials error with a flash message. If a user fails to provide a username or password to the LDAP login form then a 500 error is returned due to an exception being raised in omniauth-ldap. This gem has been amended to use the omniauth error propagation function (fail!) to pass this exception message to the registered omniauth failure handler so that the Rails application can handle it approriately. The failure function now knows about standard exceptions and no longer requires a specific check for the OmniAuth::Error exception added by commit f322975. This resolves issue #1077. Signed-off-by: Pat Thoyts --- Gemfile | 2 +- Gemfile.lock | 4 ++-- app/controllers/omniauth_callbacks_controller.rb | 11 ++++------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 76dc1856424..aa7cfad2934 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem "devise", "~> 2.1.0" gem "grit", :git => "https://github.com/gitlabhq/grit.git", :ref => "7f35cb98ff17d534a07e3ce6ec3d580f67402837" gem "gitolite", :git => "https://github.com/gitlabhq/gitolite-client.git", :ref => "9b715ca8bab6529f6c92204a25f84d12f25a6eb0" gem "pygments.rb", :git => "https://github.com/gitlabhq/pygments.rb.git", :ref => "2cada028da5054616634a1d9ca6941b65b3ce188" -gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "7edf27d0281e09561838122982c16b7e62181f44" +gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e" gem 'yaml_db', :git => "https://github.com/gitlabhq/yaml_db.git" gem 'grack', :git => "https://github.com/gitlabhq/grack.git" gem "linguist", "~> 1.0.0", :git => "https://github.com/gitlabhq/linguist.git" diff --git a/Gemfile.lock b/Gemfile.lock index e4c06fed229..9c8ecdd456d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,8 +42,8 @@ GIT GIT remote: https://github.com/gitlabhq/omniauth-ldap.git - revision: 7edf27d0281e09561838122982c16b7e62181f44 - ref: 7edf27d0281e09561838122982c16b7e62181f44 + revision: f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e + ref: f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e specs: omniauth-ldap (1.0.2) net-ldap (~> 0.2.2) diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index fb759c371c4..d19931e93d7 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -3,13 +3,10 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController # Extend the standard message generation to accept our custom exception def failure_message exception = env["omniauth.error"] - if exception.class == OmniAuth::Error - error = exception.message - else - error = exception.error_reason if exception.respond_to?(:error_reason) - error ||= exception.error if exception.respond_to?(:error) - error ||= env["omniauth.error.type"].to_s - end + error = exception.error_reason if exception.respond_to?(:error_reason) + error ||= exception.error if exception.respond_to?(:error) + error ||= exception.message if exception.respond_to?(:message) + error ||= env["omniauth.error.type"].to_s error.to_s.humanize if error end From 6035ad7e1fe519d0c6a42731790183889e3ba31d Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Sat, 21 Jul 2012 15:30:09 +0100 Subject: [PATCH 05/33] Create the githost.log file if necessary. This resolves issue #1121. Signed-off-by: Pat Thoyts --- lib/gitlab/logger.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb index aff13baf67b..c3a19e71c10 100644 --- a/lib/gitlab/logger.rb +++ b/lib/gitlab/logger.rb @@ -10,6 +10,7 @@ module Gitlab def self.read_latest path = Rails.root.join("log/githost.log") + self.build unless File.exist?(path) logs = File.read(path).split("\n") end From ff40b7de7a6451bb9e3bc12a18070bbff13b6a68 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sat, 21 Jul 2012 19:37:31 +0200 Subject: [PATCH 06/33] Add CommitDecorator#short_id --- app/decorators/commit_decorator.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/decorators/commit_decorator.rb b/app/decorators/commit_decorator.rb index cc8fa97587b..d9c880bee72 100644 --- a/app/decorators/commit_decorator.rb +++ b/app/decorators/commit_decorator.rb @@ -1,6 +1,10 @@ class CommitDecorator < ApplicationDecorator decorates :commit + def short_id(length = 10) + id.to_s[0..length] + end + # Returns the commits title. # # Usually, the commit title is the first line of the commit message. From 34cea1cb632c907ae399df64c60e93a5c716eeca Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 22 Jul 2012 13:08:24 +0200 Subject: [PATCH 07/33] Update views to use CommitDecorator --- app/controllers/commits_controller.rb | 1 + app/controllers/merge_requests_controller.rb | 1 + app/controllers/refs_controller.rb | 3 ++- app/views/commits/_commit.html.haml | 4 ++-- app/views/commits/index.atom.builder | 4 ++-- app/views/events/_commit.html.haml | 5 +++-- app/views/refs/_tree_commit.html.haml | 2 +- app/views/refs/blame.html.haml | 5 +++-- app/views/repositories/_branch.html.haml | 12 +++++++----- app/views/repositories/_feed.html.haml | 5 +++-- app/views/repositories/tags.html.haml | 5 +++-- 11 files changed, 28 insertions(+), 19 deletions(-) diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index cb1f74527a1..a8540569462 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -17,6 +17,7 @@ class CommitsController < ApplicationController @limit, @offset = (params[:limit] || 40), (params[:offset] || 0) @commits = @project.commits(@ref, params[:path], @limit, @offset) + @commits = CommitDecorator.decorate(@commits) respond_to do |format| format.html # index.html.erb diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index 1cb1d388465..f9a1c1dd67d 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -143,5 +143,6 @@ class MergeRequestsController < ApplicationController # Get commits from repository # or from cache if already merged @commits = @merge_request.commits + @commits = CommitDecorator.decorate(@commits) end end diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index b610c9f34d4..d180e708882 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -51,7 +51,8 @@ class RefsController < ApplicationController @logs = contents.map do |content| file = params[:path] ? File.join(params[:path], content.name) : content.name last_commit = @project.commits(@commit.id, file, 1).last - { + last_commit = CommitDecorator.decorate(last_commit) + { :file_name => content.name, :commit => last_commit } diff --git a/app/views/commits/_commit.html.haml b/app/views/commits/_commit.html.haml index 9f9502e30d4..c77e22d9a96 100644 --- a/app/views/commits/_commit.html.haml +++ b/app/views/commits/_commit.html.haml @@ -4,11 +4,11 @@ %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit.id), :class => "right" = link_to project_commit_path(@project, :id => commit.id) do %p - %code.left= commit.id.to_s[0..10] + %code.left= commit.short_id %strong.cgray= commit.author_name – = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16 - %span.row_title= truncate(commit.safe_message, :length => 50) + %span.row_title= truncate(commit.title, :length => 50) %span.committed_ago = time_ago_in_words(commit.committed_date) diff --git a/app/views/commits/index.atom.builder b/app/views/commits/index.atom.builder index 2a352dac1b7..86c9fc04e51 100644 --- a/app/views/commits/index.atom.builder +++ b/app/views/commits/index.atom.builder @@ -10,14 +10,14 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear xml.entry do xml.id project_commit_url(@project, :id => commit.id) xml.link :href => project_commit_url(@project, :id => commit.id) - xml.title truncate(commit.safe_message, :length => 80) + xml.title truncate(commit.title, :length => 80) xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email) xml.author do |author| xml.name commit.author_name xml.email commit.author_email end - xml.summary commit.safe_message + xml.summary commit.description end end end diff --git a/app/views/events/_commit.html.haml b/app/views/events/_commit.html.haml index 60112b508a8..b26b8f0a50b 100644 --- a/app/views/events/_commit.html.haml +++ b/app/views/events/_commit.html.haml @@ -1,9 +1,10 @@ +- commit = CommitDecorator.decorate(commit) %li.wll.commit = link_to project_commit_path(project, :id => commit.id) do %p - %code.left= commit.id.to_s[0..10] + %code.left= commit.short_id %strong.cgray= commit.author_name – = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16 - %span.row_title= truncate(commit.safe_message, :length => 50) rescue "--broken encoding" + %span.row_title= truncate(commit.title, :length => 50) rescue "--broken encoding" diff --git a/app/views/refs/_tree_commit.html.haml b/app/views/refs/_tree_commit.html.haml index 1f2524a4c3a..7da8ae1c501 100644 --- a/app/views/refs/_tree_commit.html.haml +++ b/app/views/refs/_tree_commit.html.haml @@ -1,3 +1,3 @@ - if tm %strong= link_to "[#{tm.user_name}]", project_team_member_path(@project, tm) -= link_to truncate(content_commit.safe_message, :length => tm ? 30 : 50), project_commit_path(@project, content_commit.id), :class => "tree-commit-link" += link_to truncate(content_commit.title, :length => tm ? 30 : 50), project_commit_path(@project, content_commit.id), :class => "tree-commit-link" diff --git a/app/views/refs/blame.html.haml b/app/views/refs/blame.html.haml index 6a86b91fe74..0f0b6927157 100644 --- a/app/views/refs/blame.html.haml +++ b/app/views/refs/blame.html.haml @@ -25,6 +25,7 @@ %table - @blame.each do |commit, lines| - commit = Commit.new(commit) + - commit = CommitDecorator.decorate(commit) %tr %td.author = image_tag gravatar_icon(commit.author_email, 16) @@ -32,8 +33,8 @@ %td.blame_commit   = link_to project_commit_path(@project, :id => commit.id) do - %code= commit.id.to_s[0..10] - %span.row_title= truncate(commit.safe_message, :length => 30) rescue "--broken encoding" + %code= commit.short_id + %span.row_title= truncate(commit.title, :length => 30) rescue "--broken encoding" %td.lines = preserve do %pre diff --git a/app/views/repositories/_branch.html.haml b/app/views/repositories/_branch.html.haml index 4742b92bd74..3efe83ec1a0 100644 --- a/app/views/repositories/_branch.html.haml +++ b/app/views/repositories/_branch.html.haml @@ -1,3 +1,5 @@ +- commit = Commit.new(branch.commit) +- commit = CommitDecorator.decorate(commit) %tr %td = link_to project_commits_path(@project, :ref => branch.name) do @@ -5,14 +7,14 @@ - if branch.name == @project.root_ref %span.label default %td - = link_to project_commit_path(@project, :id => branch.commit.id) do - %code= branch.commit.id.to_s[0..10] + = link_to project_commit_path(@project, :id => commit.id) do + %code= commit.short_id - = image_tag gravatar_icon(Commit.new(branch.commit).author_email), :class => "", :width => 16 - = truncate(Commit.new(branch.commit).safe_message, :length => 40) + = image_tag gravatar_icon(commit.author_email), :class => "", :width => 16 + = truncate(commit.title, :length => 40) %td %span.update-author.right - = time_ago_in_words(branch.commit.committed_date) + = time_ago_in_words(commit.committed_date) ago %td - if can? current_user, :download_code, @project diff --git a/app/views/repositories/_feed.html.haml b/app/views/repositories/_feed.html.haml index 0734327233e..a9a1181974b 100644 --- a/app/views/repositories/_feed.html.haml +++ b/app/views/repositories/_feed.html.haml @@ -1,4 +1,5 @@ - commit = update +- commit = CommitDecorator.new(commit) %tr %td = link_to project_commits_path(@project, :ref => commit.head.name) do @@ -10,9 +11,9 @@ %td %div = link_to project_commits_path(@project, commit.id) do - %code= commit.id.to_s[0..10] + %code= commit.short_id = image_tag gravatar_icon(commit.author_email), :class => "", :width => 16 - = truncate(commit.safe_message, :length => 40) + = truncate(commit.title, :length => 40) %td %span.right.cgray = time_ago_in_words(commit.committed_date) diff --git a/app/views/repositories/tags.html.haml b/app/views/repositories/tags.html.haml index 5e5cca31d8f..d09c40e15a3 100644 --- a/app/views/repositories/tags.html.haml +++ b/app/views/repositories/tags.html.haml @@ -9,14 +9,15 @@ %th - @tags.each do |tag| - commit = Commit.new(tag.commit) + - commit = CommitDecorator.decorate(commit) %tr %td %strong= link_to tag.name, project_commits_path(@project, :ref => tag.name), :class => "" %td = link_to project_commit_path(@project, commit.id) do - %code= commit.id.to_s[0..10] + %code= commit.short_id = image_tag gravatar_icon(commit.author_email), :class => "", :width => 16 - = truncate(commit.safe_message, :length => 40) + = truncate(commit.title, :length => 40) %td %span.update-author.right = time_ago_in_words(commit.committed_date) From f9877c529eb6864dbf4b21ef6ddd2ab48159f1b3 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 22 Jul 2012 13:08:32 +0200 Subject: [PATCH 08/33] Update specs --- spec/requests/commits_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/requests/commits_spec.rb b/spec/requests/commits_spec.rb index 00b69379848..0418697ea93 100644 --- a/spec/requests/commits_spec.rb +++ b/spec/requests/commits_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "Commits" do let(:project) { Factory :project } - let!(:commit) { project.commit } + let!(:commit) { CommitDecorator.decorate(project.commit) } before do login_as :user project.add_access(@user, :read) @@ -22,8 +22,8 @@ describe "Commits" do end it "should list commits" do - page.should have_content(commit.message) - page.should have_content(commit.id.to_s[0..5]) + page.should have_content(commit.description) + page.should have_content(commit.short_id) end it "should render atom feed" do @@ -32,7 +32,7 @@ describe "Commits" do 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("author email", :text => commit.author_email) - page.body.should have_selector("entry summary", :text => commit.message) + page.body.should have_selector("entry summary", :text => commit.description) end it "should render atom feed via private token" do @@ -42,7 +42,7 @@ describe "Commits" do 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("author email", :text => commit.author_email) - page.body.should have_selector("entry summary", :text => commit.message) + page.body.should have_selector("entry summary", :text => commit.description) end end From dce6f7beb4db3074d989d57318e3b4c1b7e9bd00 Mon Sep 17 00:00:00 2001 From: Rob Taylor Date: Tue, 24 Jul 2012 11:22:13 +0100 Subject: [PATCH 09/33] Updated merge request subheading. Changed "authored or assigned to you" to read "authored by or assigned to you" which reads better. --- app/views/dashboard/merge_requests.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/dashboard/merge_requests.html.haml b/app/views/dashboard/merge_requests.html.haml index ce3cd6b5959..407bf532422 100644 --- a/app/views/dashboard/merge_requests.html.haml +++ b/app/views/dashboard/merge_requests.html.haml @@ -1,6 +1,6 @@ %h3.page_title Merge Requests - %small (authored or assigned to you) + %small (authored by or assigned to you) %small.right #{@merge_requests.total_count} merge requests %br From 7b33d8cbcab3b0ee5789ec607455ab62130db69f Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Tue, 24 Jul 2012 05:19:51 -0700 Subject: [PATCH 10/33] add issues API --- lib/api.rb | 1 + lib/api/entities.rb | 12 +++++ lib/api/issues.rb | 111 ++++++++++++++++++++++++++++++++++++++++ spec/api/issues_spec.rb | 71 +++++++++++++++++++++++++ 4 files changed, 195 insertions(+) create mode 100644 lib/api/issues.rb create mode 100644 spec/api/issues_spec.rb diff --git a/lib/api.rb b/lib/api.rb index e24e0a78f71..6a8a3d651c0 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -15,5 +15,6 @@ module Gitlab mount Users mount Projects + mount Issues end end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index f57545ff2f5..e5095f7189e 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -25,5 +25,17 @@ module Gitlab expose :author, :using => Entities::UserBasic expose :expires_at, :updated_at, :created_at end + + class Milestone < Grape::Entity + expose :id, :title, :description, :due_date, :closed, :updated_at, :created_at + end + + class Issue < Grape::Entity + expose :id, :title, :description + expose :label_list, :as => :labels + expose :milestone, :using => Entities::Milestone + expose :assignee, :author, :using => Entities::UserBasic + expose :closed, :updated_at, :created_at + end end end diff --git a/lib/api/issues.rb b/lib/api/issues.rb new file mode 100644 index 00000000000..2b6a1ac269d --- /dev/null +++ b/lib/api/issues.rb @@ -0,0 +1,111 @@ +module Gitlab + # Issues API + class Issues < Grape::API + before { authenticate! } + + resource :issues do + # Get currently authenticated user's issues + # + # Example Request: + # GET /issues + get do + present current_user.issues, :with => Entities::Issue + end + end + + resource :projects do + # Get a list of project issues + # + # Parameters: + # id (required) - The code name of a project + # Example Request: + # GET /projects/:id/issues + get ":id/issues" do + present user_project.issues, :with => Entities::Issue + end + + # Get a single project issue + # + # Parameters: + # id (required) - The code name of a project + # issue_id (required) - The ID of a project issue + # Example Request: + # GET /projects/:id/issues/:issue_id + get ":id/issues/:issue_id" do + @issue = user_project.issues.find(params[:issue_id]) + present @issue, :with => Entities::Issue + end + + # Create a new project issue + # + # Parameters: + # id (required) - The code name of a project + # title (required) - The title of an issue + # description (optional) - The description of an issue + # assignee_id (optional) - The ID of a user to assign issue + # milestone_id (optional) - The ID of a milestone to assign issue + # labels (optional) - The labels of an issue + # Example Request: + # POST /projects/:id/issues + post ":id/issues" do + @issue = user_project.issues.new( + :title => params[:title], + :description => params[:description], + :assignee_id => params[:assignee_id], + :milestone_id => params[:milestone_id], + :label_list => params[:labels] + ) + @issue.author = current_user + + if @issue.save + present @issue, :with => Entities::Issue + else + error!({'message' => '404 Not found'}, 404) + end + end + + # Update an existing issue + # + # Parameters: + # id (required) - The code name of a project + # issue_id (required) - The ID of a project issue + # title (optional) - The title of an issue + # description (optional) - The description of an issue + # assignee_id (optional) - The ID of a user to assign issue + # milestone_id (optional) - The ID of a milestone to assign issue + # labels (optional) - The labels of an issue + # closed (optional) - The state of an issue (0 = false, 1 = true) + # Example Request: + # PUT /projects/:id/issues/:issue_id + put ":id/issues/:issue_id" do + @issue = user_project.issues.find(params[:issue_id]) + parameters = { + :title => (params[:title] || @issue.title), + :description => (params[:description] || @issue.description), + :assignee_id => (params[:assignee_id] || @issue.assignee_id), + :milestone_id => (params[:milestone_id] || @issue.milestone_id), + :label_list => (params[:labels] || @issue.label_list), + :closed => (params[:closed] || @issue.closed) + } + + if @issue.update_attributes(parameters) + present @issue, :with => Entities::Issue + else + error!({'message' => '404 Not found'}, 404) + end + end + + # Delete a project issue + # + # Parameters: + # id (required) - The code name of a project + # issue_id (required) - The ID of a project issue + # Example Request: + # DELETE /projects/:id/issues/:issue_id + delete ":id/issues/:issue_id" do + @issue = user_project.issues.find(params[:issue_id]) + @issue.destroy + end + end + end +end diff --git a/spec/api/issues_spec.rb b/spec/api/issues_spec.rb new file mode 100644 index 00000000000..d81a07e214b --- /dev/null +++ b/spec/api/issues_spec.rb @@ -0,0 +1,71 @@ +require 'spec_helper' + +describe Gitlab::API do + let(:user) { Factory :user } + let!(:project) { Factory :project, :owner => user } + let!(:issue) { Factory :issue, :author => user, :assignee => user, :project => project } + before { project.add_access(user, :read) } + + describe "GET /issues" do + it "should return authentication error" do + get "#{api_prefix}/issues" + response.status.should == 401 + end + + describe "authenticated GET /issues" do + it "should return an array of issues" do + get "#{api_prefix}/issues?private_token=#{user.private_token}" + response.status.should == 200 + json_response.should be_an Array + json_response.first['title'].should == issue.title + end + end + end + + describe "GET /projects/:id/issues" do + it "should return project issues" do + get "#{api_prefix}/projects/#{project.code}/issues?private_token=#{user.private_token}" + response.status.should == 200 + json_response.should be_an Array + json_response.first['title'].should == issue.title + end + end + + describe "GET /projects/:id/issues/:issue_id" do + it "should return a project issue by id" do + get "#{api_prefix}/projects/#{project.code}/issues/#{issue.id}?private_token=#{user.private_token}" + response.status.should == 200 + json_response['title'].should == issue.title + end + end + + describe "POST /projects/:id/issues" do + it "should create a new project issue" do + post "#{api_prefix}/projects/#{project.code}/issues?private_token=#{user.private_token}", + :title => 'new issue', :labels => 'label, label2' + response.status.should == 201 + json_response['title'].should == 'new issue' + json_response['description'].should be_nil + json_response['labels'].should == ['label', 'label2'] + end + end + + describe "PUT /projects/:id/issues/:issue_id" do + it "should update a project issue" do + put "#{api_prefix}/projects/#{project.code}/issues/#{issue.id}?private_token=#{user.private_token}", + :title => 'updated title', :labels => 'label2', :closed => 1 + response.status.should == 200 + json_response['title'].should == 'updated title' + json_response['labels'].should == ['label2'] + json_response['closed'].should be_true + end + end + + describe "DELETE /projects/:id/issues/:issue_id" do + it "should delete a project issue" do + expect { + delete "#{api_prefix}/projects/#{project.code}/issues/#{issue.id}?private_token=#{user.private_token}" + }.to change { Issue.count }.by(-1) + end + end +end From 024e0348904179a8dea81c01e27a5f014cf57499 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Tue, 24 Jul 2012 05:25:01 -0700 Subject: [PATCH 11/33] update API docs --- doc/api/README.md | 1 + doc/api/issues.md | 181 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 doc/api/issues.md diff --git a/doc/api/README.md b/doc/api/README.md index dcf75afda1f..e01119661f0 100644 --- a/doc/api/README.md +++ b/doc/api/README.md @@ -27,3 +27,4 @@ The API uses JSON to serialize data. You don't need to specify `.json` at the en + [Users](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/users.md) + [Projects](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/projects.md) ++ [Issues](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/issues.md) diff --git a/doc/api/issues.md b/doc/api/issues.md new file mode 100644 index 00000000000..bad2d474020 --- /dev/null +++ b/doc/api/issues.md @@ -0,0 +1,181 @@ +## List issues + +Get all issues created by authenticed user. + +``` +GET /issues +``` + +```json +[ + { + "id": 43, + "title": "4xx/5xx pages", + "description": "", + "labels": [ ], + "milestone": null, + "assignee": null, + "author": { + "id": 1, + "email": "john@example.com", + "name": "John Smith", + "blocked": false, + "created_at": "2012-05-23T08:00:58Z" + }, + "closed": true, + "updated_at": "2012-07-02T17:53:12Z", + "created_at": "2012-07-02T17:53:12Z" + }, + { + "id": 42, + "title": "Add user settings", + "description": "", + "labels": [ + "feature" + ], + "milestone": { + "id": 1, + "title": "v1.0", + "description": "", + "due_date": "2012-07-20", + "closed": false, + "updated_at": "2012-07-04T13:42:48Z", + "created_at": "2012-07-04T13:42:48Z" + }, + "assignee": { + "id": 2, + "email": "jack@example.com", + "name": "Jack Smith", + "blocked": false, + "created_at": "2012-05-23T08:01:01Z" + }, + "author": { + "id": 1, + "email": "john@example.com", + "name": "John Smith", + "blocked": false, + "created_at": "2012-05-23T08:00:58Z" + }, + "closed": false, + "updated_at": "2012-07-12T13:43:19Z", + "created_at": "2012-06-28T12:58:06Z" + } +] +``` + +## List project issues + +Get a list of project issues. + +``` +GET /projects/:id/issues +``` + +Parameters: + ++ `id` (required) - The code name of a project + +## Single issue + +Get a project issue. + +``` +GET /projects/:id/issues/:issue_id +``` + +Parameters: + ++ `id` (required) - The code name of a project ++ `issue_id` (required) - The ID of a project issue + +```json +{ + "id": 42, + "title": "Add user settings", + "description": "", + "labels": [ + "feature" + ], + "milestone": { + "id": 1, + "title": "v1.0", + "description": "", + "due_date": "2012-07-20", + "closed": false, + "updated_at": "2012-07-04T13:42:48Z", + "created_at": "2012-07-04T13:42:48Z" + }, + "assignee": { + "id": 2, + "email": "jack@example.com", + "name": "Jack Smith", + "blocked": false, + "created_at": "2012-05-23T08:01:01Z" + }, + "author": { + "id": 1, + "email": "john@example.com", + "name": "John Smith", + "blocked": false, + "created_at": "2012-05-23T08:00:58Z" + }, + "closed": false, + "updated_at": "2012-07-12T13:43:19Z", + "created_at": "2012-06-28T12:58:06Z" +} +``` + +## New issue + +Create a new project issue. + +``` +POST /projects/:id/issues +``` + +Parameters: + ++ `id` (required) - The code name of a project ++ `title` (required) - The title of an issue ++ `description` (optional) - The description of an issue ++ `assignee_id` (optional) - The ID of a user to assign issue ++ `milestone_id` (optional) - The ID of a milestone to assign issue ++ `labels` (optional) - Comma-separated label names for an issue + +Will return created issue with status `201 Created` on success, or `404 Not found` on fail. + +## Edit issue + +Update an existing project issue. + +``` +PUT /projects/:id/issues/:issue_id +``` + +Parameters: + ++ `id` (required) - The code name of a project ++ `issue_id` (required) - The ID of a project's issue ++ `title` (optional) - The title of an issue ++ `description` (optional) - The description of an issue ++ `assignee_id` (optional) - The ID of a user to assign issue ++ `milestone_id` (optional) - The ID of a milestone to assign issue ++ `labels` (optional) - Comma-separated label names for an issue ++ `closed` (optional) - The state of an issue (0 = false, 1 = true) + +Will return updated issue with status `200 OK` on success, or `404 Not found` on fail. + +## Delete issue + +Delete existing project issue. + +``` +DELETE /projects/:id/issues/:issue_id +``` + +Parameters: + ++ `id` (required) - The code name of a project ++ `issue_id` (required) - The ID of a project's issue + +Status code `200` will be returned on success. From fbb41100db35cf2def2c8b4d896b7015d56bd15b Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Tue, 24 Jul 2012 05:52:43 -0700 Subject: [PATCH 12/33] update help section with issues API docs --- app/views/help/api.html.haml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/views/help/api.html.haml b/app/views/help/api.html.haml index 4964c1bbd87..e184df549de 100644 --- a/app/views/help/api.html.haml +++ b/app/views/help/api.html.haml @@ -1,16 +1,18 @@ %h3 API .back_link - = link_to help_path do + = link_to help_path do ← to index %hr %ol - %li + %li %a{:href => "#README"} README - %li + %li %a{:href => "#projects"} Projects - %li + %li %a{:href => "#users"} Users + %li + %a{:href => "#issues"} Issues .file_holder#README .file_title @@ -39,3 +41,13 @@ .file_content.wiki = preserve do = markdown File.read(Rails.root.join("doc", "api", "users.md")) + +%br + +.file_holder#issues + .file_title + %i.icon-file + Issues + .file_content.wiki + = preserve do + = markdown File.read(Rails.root.join("doc", "api", "issues.md")) From 1b95c8bff351f6718ec31ac1de1e48c57bc95d44 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 25 Jul 2012 02:18:30 -0700 Subject: [PATCH 13/33] API: ability to get project by id --- lib/api/helpers.rb | 3 ++- spec/api/projects_spec.rb | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index e7b9a417b08..4dfe35f49ef 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -5,7 +5,8 @@ module Gitlab end def user_project - @project ||= current_user.projects.find_by_code(params[:id]) + @project ||= current_user.projects.find_by_id(params[:id]) || + current_user.projects.find_by_code(params[:id]) end def authenticate! diff --git a/spec/api/projects_spec.rb b/spec/api/projects_spec.rb index 9998ee509bf..92a255438ab 100644 --- a/spec/api/projects_spec.rb +++ b/spec/api/projects_spec.rb @@ -25,11 +25,17 @@ describe Gitlab::API do describe "GET /projects/:id" do it "should return a project by id" do - get "#{api_prefix}/projects/#{project.code}?private_token=#{user.private_token}" + get "#{api_prefix}/projects/#{project.id}?private_token=#{user.private_token}" response.status.should == 200 json_response['name'].should == project.name json_response['owner']['email'].should == user.email end + + it "should return a project by code name" do + get "#{api_prefix}/projects/#{project.code}?private_token=#{user.private_token}" + response.status.should == 200 + json_response['name'].should == project.name + end end describe "GET /projects/:id/repository/branches" do From 949b1df930bedace1dbd755aaa4a82e8c451a616 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 25 Jul 2012 02:35:41 -0700 Subject: [PATCH 14/33] API: update docs --- doc/api/issues.md | 10 +++++----- doc/api/projects.md | 22 +++++++++++----------- lib/api/issues.rb | 10 +++++----- lib/api/projects.rb | 16 ++++++++-------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/doc/api/issues.md b/doc/api/issues.md index bad2d474020..0ce14503ffc 100644 --- a/doc/api/issues.md +++ b/doc/api/issues.md @@ -73,7 +73,7 @@ GET /projects/:id/issues Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project ## Single issue @@ -85,7 +85,7 @@ GET /projects/:id/issues/:issue_id Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project + `issue_id` (required) - The ID of a project issue ```json @@ -135,7 +135,7 @@ POST /projects/:id/issues Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project + `title` (required) - The title of an issue + `description` (optional) - The description of an issue + `assignee_id` (optional) - The ID of a user to assign issue @@ -154,7 +154,7 @@ PUT /projects/:id/issues/:issue_id Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project + `issue_id` (required) - The ID of a project's issue + `title` (optional) - The title of an issue + `description` (optional) - The description of an issue @@ -175,7 +175,7 @@ DELETE /projects/:id/issues/:issue_id Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project + `issue_id` (required) - The ID of a project's issue Status code `200` will be returned on success. diff --git a/doc/api/projects.md b/doc/api/projects.md index c748745e063..cd94cd42328 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -1,6 +1,6 @@ ## List projects -Get a list of authenticated users' projects. +Get a list of authenticated user's projects. ``` GET /projects @@ -63,7 +63,7 @@ GET /projects/:id Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project ```json { @@ -91,7 +91,7 @@ Parameters: ## Project repository branches -Get a list of project repository branches. +Get a list of project repository branches sorted by name alphabetically. ``` GET /projects/:id/repository/branches @@ -99,7 +99,7 @@ GET /projects/:id/repository/branches Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project ```json [ @@ -131,7 +131,7 @@ Parameters: ## Project repository tags -Get a list of project repository tags. +Get a list of project repository tags sorted by name in reverse alphabetical order. ``` GET /projects/:id/repository/tags @@ -139,7 +139,7 @@ GET /projects/:id/repository/tags Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project ```json [ @@ -183,7 +183,7 @@ GET /projects/:id/snippets/:snippet_id Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project + `snippet_id` (required) - The ID of a project's snippet ```json @@ -214,7 +214,7 @@ GET /projects/:id/snippets/:snippet_id/raw Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project + `snippet_id` (required) - The ID of a project's snippet ## New snippet @@ -227,7 +227,7 @@ POST /projects/:id/snippets Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project + `title` (required) - The title of a snippet + `file_name` (required) - The name of a snippet file + `lifetime` (optional) - The expiration date of a snippet @@ -245,7 +245,7 @@ PUT /projects/:id/snippets/:snippet_id Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project + `snippet_id` (required) - The ID of a project's snippet + `title` (optional) - The title of a snippet + `file_name` (optional) - The name of a snippet file @@ -264,7 +264,7 @@ DELETE /projects/:id/snippets/:snippet_id Parameters: -+ `id` (required) - The code name of a project ++ `id` (required) - The ID or code name of a project + `snippet_id` (required) - The ID of a project's snippet Status code `200` will be returned on success. diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 2b6a1ac269d..dcb6e53588c 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -17,7 +17,7 @@ module Gitlab # Get a list of project issues # # Parameters: - # id (required) - The code name of a project + # id (required) - The ID or code name of a project # Example Request: # GET /projects/:id/issues get ":id/issues" do @@ -27,7 +27,7 @@ module Gitlab # Get a single project issue # # Parameters: - # id (required) - The code name of a project + # id (required) - The ID or code name of a project # issue_id (required) - The ID of a project issue # Example Request: # GET /projects/:id/issues/:issue_id @@ -39,7 +39,7 @@ module Gitlab # Create a new project issue # # Parameters: - # id (required) - The code name of a project + # id (required) - The ID or code name of a project # title (required) - The title of an issue # description (optional) - The description of an issue # assignee_id (optional) - The ID of a user to assign issue @@ -67,7 +67,7 @@ module Gitlab # Update an existing issue # # Parameters: - # id (required) - The code name of a project + # id (required) - The ID or code name of a project # issue_id (required) - The ID of a project issue # title (optional) - The title of an issue # description (optional) - The description of an issue @@ -98,7 +98,7 @@ module Gitlab # Delete a project issue # # Parameters: - # id (required) - The code name of a project + # id (required) - The ID or code name of a project # issue_id (required) - The ID of a project issue # Example Request: # DELETE /projects/:id/issues/:issue_id diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 34d1c23676e..8edfa481c10 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -16,7 +16,7 @@ module Gitlab # Get a single project # # Parameters: - # id (required) - The code of a project + # id (required) - The ID or code name of a project # Example Request: # GET /projects/:id get ":id" do @@ -26,7 +26,7 @@ module Gitlab # Get a project repository branches # # Parameters: - # id (required) - The code of a project + # id (required) - The ID or code name of a project # Example Request: # GET /projects/:id/repository/branches get ":id/repository/branches" do @@ -36,7 +36,7 @@ module Gitlab # Get a project repository tags # # Parameters: - # id (required) - The code of a project + # id (required) - The ID or code name of a project # Example Request: # GET /projects/:id/repository/tags get ":id/repository/tags" do @@ -46,7 +46,7 @@ module Gitlab # Get a project snippet # # Parameters: - # id (required) - The code of a project + # id (required) - The ID or code name of a project # snippet_id (required) - The ID of a project snippet # Example Request: # GET /projects/:id/snippets/:snippet_id @@ -58,7 +58,7 @@ module Gitlab # Create a new project snippet # # Parameters: - # id (required) - The code name of a project + # id (required) - The ID or code name of a project # title (required) - The title of a snippet # file_name (required) - The name of a snippet file # lifetime (optional) - The expiration date of a snippet @@ -84,7 +84,7 @@ module Gitlab # Update an existing project snippet # # Parameters: - # id (required) - The code name of a project + # id (required) - The ID or code name of a project # snippet_id (required) - The ID of a project snippet # title (optional) - The title of a snippet # file_name (optional) - The name of a snippet file @@ -111,7 +111,7 @@ module Gitlab # Delete a project snippet # # Parameters: - # id (required) - The code of a project + # id (required) - The ID or code name of a project # snippet_id (required) - The ID of a project snippet # Example Request: # DELETE /projects/:id/snippets/:snippet_id @@ -123,7 +123,7 @@ module Gitlab # Get a raw project snippet # # Parameters: - # id (required) - The code of a project + # id (required) - The ID or code name of a project # snippet_id (required) - The ID of a project snippet # Example Request: # GET /projects/:id/snippets/:snippet_id/raw From f7dd067490fe57505f7226c3b54d3127d2f7fd46 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 25 Jul 2012 04:22:21 -0700 Subject: [PATCH 15/33] API: expose issues project id --- doc/api/issues.md | 3 +++ lib/api/entities.rb | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/api/issues.md b/doc/api/issues.md index 0ce14503ffc..aaad3305489 100644 --- a/doc/api/issues.md +++ b/doc/api/issues.md @@ -10,6 +10,7 @@ GET /issues [ { "id": 43, + "project_id": 8, "title": "4xx/5xx pages", "description": "", "labels": [ ], @@ -28,6 +29,7 @@ GET /issues }, { "id": 42, + "project_id": 8, "title": "Add user settings", "description": "", "labels": [ @@ -91,6 +93,7 @@ Parameters: ```json { "id": 42, + "project_id": 8, "title": "Add user settings", "description": "", "labels": [ diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e5095f7189e..d86fb79c78b 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -31,7 +31,9 @@ module Gitlab end class Issue < Grape::Entity - expose :id, :title, :description + expose :id + expose (:project_id) {|issue| issue.project.id} + expose :title, :description expose :label_list, :as => :labels expose :milestone, :using => Entities::Milestone expose :assignee, :author, :using => Entities::UserBasic From cb32e0320ab538b465574bb73c7bd3d32db56d3c Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 25 Jul 2012 05:24:28 -0700 Subject: [PATCH 16/33] return 404 if project not found --- lib/api/helpers.rb | 9 +++++++-- spec/api/projects_spec.rb | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 4dfe35f49ef..c1ea05667ae 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -5,8 +5,13 @@ module Gitlab end def user_project - @project ||= current_user.projects.find_by_id(params[:id]) || - current_user.projects.find_by_code(params[:id]) + if @project ||= current_user.projects.find_by_id(params[:id]) || + current_user.projects.find_by_code(params[:id]) + else + error!({'message' => '404 Not found'}, 404) + end + + @project end def authenticate! diff --git a/spec/api/projects_spec.rb b/spec/api/projects_spec.rb index 92a255438ab..8852a0d346b 100644 --- a/spec/api/projects_spec.rb +++ b/spec/api/projects_spec.rb @@ -36,6 +36,12 @@ describe Gitlab::API do response.status.should == 200 json_response['name'].should == project.name end + + it "should return a 404 error if not found" do + get "#{api_prefix}/projects/42?private_token=#{user.private_token}" + response.status.should == 404 + json_response['message'].should == '404 Not found' + end end describe "GET /projects/:id/repository/branches" do From 0296121f08cd960f5a96686b3bedd75f5651765a Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 25 Jul 2012 21:38:33 +0300 Subject: [PATCH 17/33] Remove recreated mailer controller for admin --- app/controllers/admin/mailer_controller.rb | 47 ---------------------- 1 file changed, 47 deletions(-) delete mode 100644 app/controllers/admin/mailer_controller.rb diff --git a/app/controllers/admin/mailer_controller.rb b/app/controllers/admin/mailer_controller.rb deleted file mode 100644 index ec6d24bdaba..00000000000 --- a/app/controllers/admin/mailer_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -class Admin::MailerController < ApplicationController - layout "admin" - before_filter :authenticate_user! - before_filter :authenticate_admin! - - def preview - - end - - def preview_note - @note = Note.first - @user = @note.author - @project = @note.project - case params[:type] - when "Commit" then - @commit = @project.commit - render :file => 'notify/note_commit_email', :layout => 'notify' - when "Issue" then - @issue = Issue.first - render :file => 'notify/note_issue_email', :layout => 'notify' - when "Wiki" then - render :file => 'notify/note_wiki_email', :layout => 'notify' - else - render :file => 'notify/note_wall_email', :layout => 'notify' - end - rescue - render :text => "Preview not available" - end - - def preview_user_new - @user = User.first - @password = "DHasJKDHAS!" - - render :file => 'notify/new_user_email', :layout => 'notify' - rescue - render :text => "Preview not available" - end - - def preview_issue_new - @issue = Issue.first - @user = @issue.assignee - @project = @issue.project - render :file => 'notify/new_issue_email', :layout => 'notify' - rescue - render :text => "Preview not available" - end -end From 501ca8e6e83c221487ccc03da906ccda385831c8 Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 25 Jul 2012 21:45:53 +0300 Subject: [PATCH 18/33] Fix compare crash after decorator refactoring --- app/controllers/commits_controller.rb | 2 ++ app/views/commits/compare.html.haml | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index a8540569462..05f29da3ddd 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -52,6 +52,8 @@ class CommitsController < ApplicationController @commit = result[:commit] @diffs = result[:diffs] @line_notes = [] + + @commits = CommitDecorator.decorate(@commits) end def patch diff --git a/app/views/commits/compare.html.haml b/app/views/commits/compare.html.haml index 66ed8dad595..04d8af5459d 100644 --- a/app/views/commits/compare.html.haml +++ b/app/views/commits/compare.html.haml @@ -24,8 +24,9 @@ - unless @commits.empty? - %h4 Commits (#{@commits.count}) - %ul.unstyled= render @commits + %div.ui-box + %h5.small Commits (#{@commits.count}) + %ul.unstyled= render @commits - unless @diffs.empty? %h4 Diff From 14c97237246f01da60ad73d9efd2c08c45927f09 Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 25 Jul 2012 22:08:47 +0300 Subject: [PATCH 19/33] Styled wiki area. fixed commit feed feature --- app/views/wikis/history.html.haml | 5 +++-- app/views/wikis/show.html.haml | 11 +++++++---- features/step_definitions/project_commits_steps.rb | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/views/wikis/history.html.haml b/app/views/wikis/history.html.haml index 6a9b56ae771..2e46a90ef51 100644 --- a/app/views/wikis/history.html.haml +++ b/app/views/wikis/history.html.haml @@ -1,5 +1,6 @@ -%h3 Versions -%table +%h3.page_title Versions +%br +%table.admin-table %thead %tr %th # diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index e9502430b34..3e92275102c 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -5,15 +5,18 @@ = link_to history_project_wiki_path(@project, @wiki), :class => "btn small grouped" do History = link_to edit_project_wiki_path(@project, @wiki), :class => "btn small grouped" do + %i.icon-edit Edit -%hr -.wiki_content - = preserve do - = markdown @wiki.content +%br +.file_holder + .file_content.wiki + = preserve do + = markdown @wiki.content %p.time Last edited by #{@wiki.user.name}, #{time_ago_in_words @wiki.created_at} ago - if can? current_user, :admin_wiki, @project = link_to project_wiki_path(@project, @wiki), :confirm => "Are you sure you want to delete this page?", :method => :delete do Delete this page +%hr .wiki_notes#notes= render "notes/notes", :tid => @wiki.id, :tt => "wiki" diff --git a/features/step_definitions/project_commits_steps.rb b/features/step_definitions/project_commits_steps.rb index 9bfccfc06ed..9b3b0aa1f81 100644 --- a/features/step_definitions/project_commits_steps.rb +++ b/features/step_definitions/project_commits_steps.rb @@ -16,11 +16,11 @@ Given /^I click atom feed link$/ do end Then /^I see commits atom feed$/ do - commit = @project.commit + commit = CommitDecorator.decorate(@project.commit) 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("author email", :text => commit.author_email) - page.body.should have_selector("entry summary", :text => commit.message) + page.body.should have_selector("entry summary", :text => commit.description) end Given /^I click on commit link$/ do From cbce4528d0e0aace791ed2d9d16176d29596a615 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 22 Jul 2012 14:31:42 +0200 Subject: [PATCH 20/33] Update links to commits --- app/views/commits/_commit.html.haml | 21 ++++++++++----------- app/views/events/_commit.html.haml | 4 ++-- app/views/refs/blame.html.haml | 5 ++--- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/views/commits/_commit.html.haml b/app/views/commits/_commit.html.haml index c77e22d9a96..63339d36367 100644 --- a/app/views/commits/_commit.html.haml +++ b/app/views/commits/_commit.html.haml @@ -2,16 +2,15 @@ .browse_code_link_holder %p %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit.id), :class => "right" - = link_to project_commit_path(@project, :id => commit.id) do - %p - %code.left= commit.short_id - %strong.cgray= commit.author_name - – - = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16 - %span.row_title= truncate(commit.title, :length => 50) + %p + %code.left= link_to commit.short_id, project_commit_path(@project, :id => commit.id) + %strong.cgray= commit.author_name + – + = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16 + = link_to truncate(commit.title, :length => 50), project_commit_path(@project, :id => commit.id), :class => "row_title" - %span.committed_ago - = time_ago_in_words(commit.committed_date) - ago -   + %span.committed_ago + = time_ago_in_words(commit.committed_date) + ago +   diff --git a/app/views/events/_commit.html.haml b/app/views/events/_commit.html.haml index b26b8f0a50b..ef57c1b6625 100644 --- a/app/views/events/_commit.html.haml +++ b/app/views/events/_commit.html.haml @@ -2,9 +2,9 @@ %li.wll.commit = link_to project_commit_path(project, :id => commit.id) do %p - %code.left= commit.short_id + %code.left= link_to commit.short_id, project_commit_path(project, :id => commit.id) %strong.cgray= commit.author_name – = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16 - %span.row_title= truncate(commit.title, :length => 50) rescue "--broken encoding" + = link_to truncate(commit.title, :length => 50), project_commit_path(project, :id => commit.id), :class => "row_title" rescue "--broken encoding" diff --git a/app/views/refs/blame.html.haml b/app/views/refs/blame.html.haml index 0f0b6927157..0fc08e0c7d7 100644 --- a/app/views/refs/blame.html.haml +++ b/app/views/refs/blame.html.haml @@ -32,9 +32,8 @@ = commit.author_name %td.blame_commit   - = link_to project_commit_path(@project, :id => commit.id) do - %code= commit.short_id - %span.row_title= truncate(commit.title, :length => 30) rescue "--broken encoding" + %code= link_to commit.short_id, project_commit_path(@project, :id => commit.id) + = link_to truncate(commit.title, :length => 30), project_commit_path(@project, :id => commit.id), :class => "row_title" rescue "--broken encoding" %td.lines = preserve do %pre From 73dabcb35797480075ae872218bfdbd100e48e63 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 22 Jul 2012 14:33:03 +0200 Subject: [PATCH 21/33] Update links to issues --- app/assets/stylesheets/sections/issues.scss | 2 +- app/views/issues/_show.html.haml | 3 +-- app/views/milestones/show.html.haml | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index dd1c22d4e76..7fbfa8b167b 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -34,7 +34,7 @@ width:32px; margin-top:4px; } - p.row_title { + .row_title { padding:0px; padding-bottom:2px; } diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index e12c3c1a99c..18294af40a9 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -24,8 +24,7 @@ - else = image_tag "no_avatar.png", :class => "avatar" - = link_to project_issue_path(issue.project, issue) do - %p.row_title= truncate(issue.title, :length => 100) + %p= link_to truncate(issue.title, :length => 100), project_issue_path(issue.project, issue), :class => "row_title" %span.update-author %small.cdark= "##{issue.id}" diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml index dc3dcd01de8..7ec49b55f47 100644 --- a/app/views/milestones/show.html.haml +++ b/app/views/milestones/show.html.haml @@ -50,8 +50,8 @@ %td = link_to [@project, issue] do %span.badge.badge-info ##{issue.id} - – - = truncate issue.title, :length => 60 + – + = link_to truncate(issue.title, :length => 60), [@project, issue] %br = paginate @issues, :theme => "gitlab" From e6bb4f1491e8a2420ff4965dc48ade144d87676e Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 22 Jul 2012 14:33:31 +0200 Subject: [PATCH 22/33] Update links to merge requests --- app/views/merge_requests/_merge_request.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/merge_requests/_merge_request.html.haml b/app/views/merge_requests/_merge_request.html.haml index b9a005e08be..5cd9b9b2497 100644 --- a/app/views/merge_requests/_merge_request.html.haml +++ b/app/views/merge_requests/_merge_request.html.haml @@ -16,8 +16,7 @@ = merge_request.target_branch = image_tag gravatar_icon(merge_request.author_email), :class => "avatar" - = link_to project_merge_request_path(merge_request.project, merge_request) do - %p.row_title= truncate(merge_request.title, :length => 80) + %p= link_to truncate(merge_request.title, :length => 80), project_merge_request_path(merge_request.project, merge_request), :class => "row_title" %span.update-author %small.cdark= "##{merge_request.id}" From 0aee7c94d011bb760523f1dfd3bd1e2e31ac0e49 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 22 Jul 2012 14:37:46 +0200 Subject: [PATCH 23/33] Update links to milestones --- app/views/issues/show.html.haml | 4 +--- app/views/milestones/_milestone.html.haml | 15 +++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 8ffc9c2b662..4e8bcb89373 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -46,9 +46,7 @@ - if @issue.milestone - milestone = @issue.milestone %cite.cgray and attached to milestone - = link_to project_milestone_path(milestone.project, milestone) do - %strong - = truncate(milestone.title, :length => 20) + %strong= link_to truncate(milestone.title, :length => 20), project_milestone_path(milestone.project, milestone) .right - @issue.labels.each do |label| diff --git a/app/views/milestones/_milestone.html.haml b/app/views/milestones/_milestone.html.haml index 9912cf9ed54..81ec92ef6bc 100644 --- a/app/views/milestones/_milestone.html.haml +++ b/app/views/milestones/_milestone.html.haml @@ -6,14 +6,13 @@ = link_to 'Browse Issues', project_issues_path(milestone.project, :milestone_id => milestone.id), :class => "btn small grouped" - if can? current_user, :admin_milestone, milestone.project = link_to 'Edit', edit_project_milestone_path(milestone.project, milestone), :class => "btn small edit-milestone-link grouped" - = link_to project_milestone_path(milestone.project, milestone) do - %h4.row_title - = truncate(milestone.title, :length => 100) - %small - = milestone.expires_at - %br - .progress.progress-success.span3 - .bar{:style => "width: #{milestone.percent_complete}%;"} + %h4 + = link_to truncate(milestone.title, :length => 100), project_milestone_path(milestone.project, milestone), :class => "row_title" + %small + = milestone.expires_at + %br + .progress.progress-success.span3 + .bar{:style => "width: #{milestone.percent_complete}%;"}   From 6fc6833cdbabb44c4a1f3b8f72e99b735e13f134 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 22 Jul 2012 14:36:22 +0200 Subject: [PATCH 24/33] Fix styles * don't show pointer cursor for for the whole list item any more * fix hover color for links in .row_title --- app/assets/stylesheets/gitlab_bootstrap.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/gitlab_bootstrap.scss b/app/assets/stylesheets/gitlab_bootstrap.scss index 39e5998305a..a233dce218e 100644 --- a/app/assets/stylesheets/gitlab_bootstrap.scss +++ b/app/assets/stylesheets/gitlab_bootstrap.scss @@ -381,7 +381,6 @@ form { min-height: 20px; border-bottom: 1px solid #eee; border-bottom: 1px solid rgba(0, 0, 0, 0.05); - cursor:pointer; &.smoke { background-color:#f5f5f5; } @@ -516,7 +515,8 @@ form { .row_title { font-weight:bold; color:#444; - &:hover { + &:hover { + color:#444; text-decoration:underline; } } From f6a67ef207612b507b1facb05fc8579c5e3d3f6e Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Tue, 24 Jul 2012 01:22:01 +0200 Subject: [PATCH 25/33] Update links in events --- app/views/events/_commit.html.haml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/views/events/_commit.html.haml b/app/views/events/_commit.html.haml index ef57c1b6625..5a9d223d546 100644 --- a/app/views/events/_commit.html.haml +++ b/app/views/events/_commit.html.haml @@ -1,10 +1,9 @@ - commit = CommitDecorator.decorate(commit) %li.wll.commit - = link_to project_commit_path(project, :id => commit.id) do - %p - %code.left= link_to commit.short_id, project_commit_path(project, :id => commit.id) - %strong.cgray= commit.author_name - – - = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16 - = link_to truncate(commit.title, :length => 50), project_commit_path(project, :id => commit.id), :class => "row_title" rescue "--broken encoding" + %p + %code.left= link_to commit.short_id, project_commit_path(project, :id => commit.id) + %strong.cgray= commit.author_name + – + = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16 + = link_to truncate(commit.title, :length => 50), project_commit_path(project, :id => commit.id), :class => "row_title" rescue "--broken encoding" From c27105f8c3dc8b0baec0d36f339dbfc943ff155b Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 26 Jul 2012 14:45:17 +0300 Subject: [PATCH 26/33] Fixed dashboard loader, fixed 404 for reporter on empty wiki page. Styled Wiki edit page --- app/assets/javascripts/pager.js | 1 - app/controllers/wikis_controller.rb | 16 +++++++--------- app/views/help/permissions.html.haml | 2 -- app/views/projects/files.html.haml | 2 +- app/views/wikis/_form.html.haml | 28 +++++++++++++++------------- app/views/wikis/edit.html.haml | 2 +- app/views/wikis/empty.html.haml | 4 ++++ 7 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 app/views/wikis/empty.html.haml diff --git a/app/assets/javascripts/pager.js b/app/assets/javascripts/pager.js index d42ae1e05d1..769e8a62343 100644 --- a/app/assets/javascripts/pager.js +++ b/app/assets/javascripts/pager.js @@ -8,7 +8,6 @@ var Pager = { this.limit=limit; this.offset=limit; this.initLoadMore(); - $('.loading').show(); }, getOld: diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index 06e3564be56..1fa38034c66 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -13,18 +13,16 @@ class WikisController < ApplicationController @wiki = @project.wikis.where(:slug => params[:id]).order("created_at").last end - unless @wiki - return render_404 unless can?(current_user, :write_wiki, @project) - end - @note = @project.notes.new(:noteable => @wiki) - respond_to do |format| - if @wiki - format.html - else + if @wiki + render 'show' + else + if can?(current_user, :write_wiki, @project) @wiki = @project.wikis.new(:slug => params[:id]) - format.html { render "edit" } + render 'edit' + else + render 'empty' end end end diff --git a/app/views/help/permissions.html.haml b/app/views/help/permissions.html.haml index 860cfc8669c..7511d15d995 100644 --- a/app/views/help/permissions.html.haml +++ b/app/views/help/permissions.html.haml @@ -38,7 +38,6 @@ %li Push to non-protected branches %li Remove non-protected branches %li Add tags - %li Create new merge request %li Write a wiki .ui-box.span3 @@ -55,7 +54,6 @@ %li Push to non-protected branches %li Remove non-protected branches %li Add tags - %li Create new merge request %li Write a wiki %li Add new team members %li Push to protected branches diff --git a/app/views/projects/files.html.haml b/app/views/projects/files.html.haml index d171b0d09a1..52424ae4353 100644 --- a/app/views/projects/files.html.haml +++ b/app/views/projects/files.html.haml @@ -14,6 +14,6 @@ ago - else .alert-message.block-message - %p All files attached to project wall, issues etc will be displayed here + %span All files attached to project wall, issues etc will be displayed here diff --git a/app/views/wikis/_form.html.haml b/app/views/wikis/_form.html.haml index dbb8648d664..20b5b112819 100644 --- a/app/views/wikis/_form.html.haml +++ b/app/views/wikis/_form.html.haml @@ -6,19 +6,21 @@ - @wiki.errors.full_messages.each do |msg| %li= msg - .alert-message.block-message.warning - %p - Wiki content is parsed with #{link_to "Markdown", "http://en.wikipedia.org/wiki/Markdown"}. - %br - To add link to new page you can just type - %code [Link Title](page-slug) - .clearfix - = f.label :title - .input= f.text_field :title, :class => :xxlarge - = f.hidden_field :slug - .clearfix - = f.label :content - .input= f.text_area :content, :class => :xxlarge + .main_box + .top_box_content + = f.label :title + .input= f.text_field :title, :class => 'span8' + = f.hidden_field :slug + .middle_box_content + .input + %span.cgray + Wiki content is parsed with #{link_to "Markdown", "http://en.wikipedia.org/wiki/Markdown"}. + To add link to new page you can just type + %code [Link Title](page-slug) + + .bottom_box_content + = f.label :content + .input= f.text_area :content, :class => 'span8' .actions = f.submit 'Save', :class => "primary btn" = link_to "Cancel", project_wiki_path(@project, :index), :class => "btn" diff --git a/app/views/wikis/edit.html.haml b/app/views/wikis/edit.html.haml index 26cbd52a9a8..27d2a8f915f 100644 --- a/app/views/wikis/edit.html.haml +++ b/app/views/wikis/edit.html.haml @@ -1,3 +1,3 @@ -%h3 Editing page +%h3.page_title Editing page %hr = render 'form' diff --git a/app/views/wikis/empty.html.haml b/app/views/wikis/empty.html.haml new file mode 100644 index 00000000000..32b1c9258c5 --- /dev/null +++ b/app/views/wikis/empty.html.haml @@ -0,0 +1,4 @@ +%h3.page_title Empty page +%hr +.alert-message.block-message.warning + %span You are not allowed to create wiki pages From 18f83016b15a1ad388ccb85a6e0878e7f5f14527 Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 26 Jul 2012 16:14:34 +0300 Subject: [PATCH 27/33] Fixed persmission issue in doc. Added validation of hooks in gitlab:app:status --- app/assets/stylesheets/gitlab_bootstrap.scss | 4 -- app/assets/stylesheets/sections/commits.scss | 5 +++ app/views/errors/gitolite.html.haml | 41 +++++++++++++------- doc/installation.md | 1 + lib/tasks/gitlab/status.rake | 25 +++++++++++- 5 files changed, 55 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/gitlab_bootstrap.scss b/app/assets/stylesheets/gitlab_bootstrap.scss index 39e5998305a..29c65b828de 100644 --- a/app/assets/stylesheets/gitlab_bootstrap.scss +++ b/app/assets/stylesheets/gitlab_bootstrap.scss @@ -74,10 +74,6 @@ h5 { font-size:14px; } -code { - background:#FCEEC1; - color:$style_color; -} table { width:100%; diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss index 6052ec3fabb..35c3cffd7f1 100644 --- a/app/assets/stylesheets/sections/commits.scss +++ b/app/assets/stylesheets/sections/commits.scss @@ -194,4 +194,9 @@ float:right; @extend .cgray; } + + code { + background:#FCEEC1; + color:$style_color; + } } diff --git a/app/views/errors/gitolite.html.haml b/app/views/errors/gitolite.html.haml index ccee757378d..eb09d2141b9 100644 --- a/app/views/errors/gitolite.html.haml +++ b/app/views/errors/gitolite.html.haml @@ -1,19 +1,30 @@ .alert-message.block-message.error %h3 Gitolite Error - %hr %h4 Application cant get access to your gitolite system. - %ol - %li - %p - Check 'config/gitlab.yml' for correct settings. - %li - %p - Make sure web server user has access to gitolite. - %a{:href => "https://github.com/gitlabhq/gitlabhq/wiki/Gitolite"} Setup tutorial - %li - %p - Try: + + + + +%h4 Tips for Administrator: + +%ul + %li + %p + Check git logs in admin area + %li + %p + Check config/gitlab.yml for correct settings. + %li + %p + Diagnostic tool: %pre - = preserve do - sudo chmod -R 770 /home/git/repositories/ - sudo chown -R git:git /home/git/repositories/ + bundle exec rake gitlab:app:status RAILS_ENV=production + %li + %p + Permissions: + %pre + = preserve do + sudo chmod -R 770 /home/git/repositories/ + sudo chown -R git:git /home/git/repositories/ + sudo chown gitlab:gitlab /home/git/repositories/**/hooks/post-receive + diff --git a/doc/installation.md b/doc/installation.md index 3dfedfe10ad..cb54663e79e 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -119,6 +119,7 @@ Permissions: sudo chmod -R g+rwX /home/git/repositories/ sudo chown -R git:git /home/git/repositories/ + sudo chown gitlab:gitlab /home/git/repositories/**/hooks/post-receive #### CHECK: Logout & login again to apply git group to your user diff --git a/lib/tasks/gitlab/status.rake b/lib/tasks/gitlab/status.rake index ac712234b27..96b8886fa89 100644 --- a/lib/tasks/gitlab/status.rake +++ b/lib/tasks/gitlab/status.rake @@ -2,7 +2,7 @@ namespace :gitlab do namespace :app do desc "GITLAB | Check gitlab installation status" task :status => :environment do - puts "Starting diagnostic" + puts "Starting diagnostic".yellow git_base_path = Gitlab.config.git_base_path print "config/database.yml............" @@ -56,7 +56,28 @@ namespace :gitlab do return end - puts "\nFinished" + if Project.count > 0 + puts "Validating projects repositories:".yellow + Project.find_each(:batch_size => 100) do |project| + print "#{project.name}....." + hook_file = File.join(project.path_to_repo, 'hooks','post-receive') + + unless File.exists?(hook_file) + puts "post-receive file missing".red + next + end + + + unless File.owned?(hook_file) + puts "post-receive file is not owner by gitlab".red + next + end + + puts "post-reveice file ok".green + end + end + + puts "\nFinished".blue end end end From ec01cbef9452dcbe7a09f1709370a7939f66c542 Mon Sep 17 00:00:00 2001 From: Michael van Rooijen Date: Sun, 22 Jul 2012 14:48:23 +0200 Subject: [PATCH 28/33] Modified the `repo_dump` and `repo_restore` rake tasks to properly dump and restore repositories based on their `path` rather than their (project) `name`. The project name can be uppercase and may contain spaces. This caused the repository to be restored as a different `path` that it was initially created as, thus, breaking the `git remote` and the web interface can no longer detect the repository either because it searches by `path` and not by `name`. Also, when restoring the permissions are incorrect making it impossible to push new commits to the remote repository. So now on success it'll set the correct permissions (but requires that the `gitlab` user has `sudo` privileges, or this task must be executed as root). --- lib/tasks/gitlab/backup.rake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index 014483d4e8c..5ae51f52218 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -121,7 +121,7 @@ namespace :gitlab do backup_path_repo = File.join(Gitlab.config.backup_path, "repositories") FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo) puts "Dumping repositories:" - project = Project.all.map { |n| [n.name,n.path_to_repo] } + project = Project.all.map { |n| [n.path,n.path_to_repo] } project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")] project.each do |project| print "- Dumping repository #{project.first}... " @@ -136,12 +136,14 @@ namespace :gitlab do task :repo_restore => :environment do backup_path_repo = File.join(Gitlab.config.backup_path, "repositories") puts "Restoring repositories:" - project = Project.all.map { |n| [n.name,n.path_to_repo] } + project = Project.all.map { |n| [n.path,n.path_to_repo] } project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")] project.each do |project| print "- Restoring repository #{project.first}... " FileUtils.rm_rf(project.second) if File.dirname(project.second) # delet old stuff if Kernel.system("cd #{File.dirname(project.second)} > /dev/null 2>&1 && git clone --bare #{backup_path_repo}/#{project.first}.bundle #{project.first}.git > /dev/null 2>&1") + Kernel.system("sudo chmod -R g+rwX #{Gitlab.config.git_base_path}") + Kernel.system("sudo chown -R #{Gitlab.config.ssh_user}:#{Gitlab.config.ssh_user} #{Gitlab.config.git_base_path}") puts "[DONE]".green else puts "[FAILED]".red From 0590aa9d6073e79ba47c4fe5c34318f6889c44d8 Mon Sep 17 00:00:00 2001 From: randx Date: Fri, 27 Jul 2012 11:22:05 +0300 Subject: [PATCH 29/33] commit.short_id as model method. Styled inline comment form --- app/assets/javascripts/note.js | 2 +- app/assets/stylesheets/notes.scss | 23 ++++++++++++++++--- app/decorators/commit_decorator.rb | 4 ---- app/models/commit.rb | 8 +++++++ app/views/commits/_commit_box.html.haml | 2 +- app/views/notes/_form.html.haml | 2 +- app/views/notes/_per_line_form.html.haml | 28 +++++++++++++----------- 7 files changed, 46 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/note.js b/app/assets/javascripts/note.js index c45a45d2fcb..d9ae45d93c7 100644 --- a/app/assets/javascripts/note.js +++ b/app/assets/javascripts/note.js @@ -33,7 +33,7 @@ init: }) $("#note_note").live("focus", function(){ - $(this).css("height", "100px"); + $(this).css("height", "80px"); $('.note_advanced_opts').show(); }); diff --git a/app/assets/stylesheets/notes.scss b/app/assets/stylesheets/notes.scss index 39e03813a8b..abce4c6893f 100644 --- a/app/assets/stylesheets/notes.scss +++ b/app/assets/stylesheets/notes.scss @@ -24,8 +24,8 @@ /* Note textare */ #note_note { - height:100px; - width:97%; + height:80px; + width:99%; font-size:14px; } @@ -100,8 +100,25 @@ tr.line_notes_row { td { border-bottom:1px solid #ddd; } - .actions { + .note_actions { margin:0; + padding-top: 10px; + + .buttons { + float:left; + width:300px; + } + .options { + .labels { + float:left; + padding-left:10px; + label { + padding: 6px 0; + margin: 0; + width:120px; + } + } + } } } diff --git a/app/decorators/commit_decorator.rb b/app/decorators/commit_decorator.rb index d9c880bee72..cc8fa97587b 100644 --- a/app/decorators/commit_decorator.rb +++ b/app/decorators/commit_decorator.rb @@ -1,10 +1,6 @@ class CommitDecorator < ApplicationDecorator decorates :commit - def short_id(length = 10) - id.to_s[0..length] - end - # Returns the commits title. # # Usually, the commit title is the first line of the commit message. diff --git a/app/models/commit.rb b/app/models/commit.rb index 859bee29fa5..71c41350c95 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -114,6 +114,10 @@ class Commit @head = head end + def short_id(length = 10) + id.to_s[0..length] + end + def safe_message utf8 message end @@ -150,4 +154,8 @@ class Commit def prev_commit_id prev_commit.try :id end + + def parents_count + parents && parents.count || 0 + end end diff --git a/app/views/commits/_commit_box.html.haml b/app/views/commits/_commit_box.html.haml index 8ccb3f1b72a..6994de4a134 100644 --- a/app/views/commits/_commit_box.html.haml +++ b/app/views/commits/_commit_box.html.haml @@ -1,4 +1,4 @@ -.commit-box{class: @commit.parents.count > 1 ? "merge-commit" : ""} +.commit-box{class: @commit.parents_count > 1 ? "merge-commit" : ""} .commit-head .right - if @notes_count > 0 diff --git a/app/views/notes/_form.html.haml b/app/views/notes/_form.html.haml index f5aa1495796..aeaf57e6ddc 100644 --- a/app/views/notes/_form.html.haml +++ b/app/views/notes/_form.html.haml @@ -1,5 +1,5 @@ = form_for [@project, @note], :remote => "true", :multipart => true do |f| - %h3 Leave a comment + %h3.page_title Leave a comment -if @note.errors.any? .alert-message.block-message.error - @note.errors.full_messages.each do |msg| diff --git a/app/views/notes/_per_line_form.html.haml b/app/views/notes/_per_line_form.html.haml index 8beaf9b5e0c..a5a70053480 100644 --- a/app/views/notes/_per_line_form.html.haml +++ b/app/views/notes/_per_line_form.html.haml @@ -2,7 +2,7 @@ %tr.per_line_form %td{:colspan => 3 } = form_for [@project, @note], :remote => "true", :multipart => true do |f| - %h3 Leave a note + %h3.page_title Leave a note %div.span10 -if @note.errors.any? .alert-message.block-message.error @@ -13,19 +13,21 @@ = f.hidden_field :noteable_type = f.hidden_field :line_code = f.text_area :note, :size => 255 - %h5 Notify via email: - .clearfix - = label_tag :notify do - = check_box_tag :notify, 1, @note.noteable_type != "Commit" - %span Project team + .note_actions + .buttons + = f.submit 'Add note', :class => "btn primary submit_note", :id => "submit_note" + = link_to "Cancel", "#", :class => "btn hide-button" + .options + %h6.left Notify via email: + .labels + = label_tag :notify do + = check_box_tag :notify, 1, @note.noteable_type != "Commit" + %span Project team - - if @note.notify_only_author?(current_user) - = label_tag :notify_author do - = check_box_tag :notify_author, 1 , @note.noteable_type == "Commit" - %span Commit author - .actions - = f.submit 'Add note', :class => "btn primary submit_note", :id => "submit_note" - = link_to "Close", "#", :class => "btn hide-button" + - if @note.notify_only_author?(current_user) + = label_tag :notify_author do + = check_box_tag :notify_author, 1 , @note.noteable_type == "Commit" + %span Commit author :javascript $(function(){ From 19f7b038cbf3f6097b322eb3e76df3f852f0acd4 Mon Sep 17 00:00:00 2001 From: Michael van Rooijen Date: Fri, 27 Jul 2012 15:30:36 +0200 Subject: [PATCH 30/33] Post-receive hook should be owned by gitlab user, not git. --- lib/tasks/gitlab/backup.rake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index 5ae51f52218..d9053c232cd 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -142,8 +142,12 @@ namespace :gitlab do print "- Restoring repository #{project.first}... " FileUtils.rm_rf(project.second) if File.dirname(project.second) # delet old stuff if Kernel.system("cd #{File.dirname(project.second)} > /dev/null 2>&1 && git clone --bare #{backup_path_repo}/#{project.first}.bundle #{project.first}.git > /dev/null 2>&1") - Kernel.system("sudo chmod -R g+rwX #{Gitlab.config.git_base_path}") - Kernel.system("sudo chown -R #{Gitlab.config.ssh_user}:#{Gitlab.config.ssh_user} #{Gitlab.config.git_base_path}") + permission_commands = [ + "sudo chmod -R g+rwX #{Gitlab.config.git_base_path}", + "sudo chown -R #{Gitlab.config.ssh_user}:#{Gitlab.config.ssh_user} #{Gitlab.config.git_base_path}", + "sudo chown gitlab:gitlab /home/git/repositories/**/hooks/post-receive" + ] + permission_commands.each { |command| Kernel.system(command) } puts "[DONE]".green else puts "[FAILED]".red From 9a709f76be3a3e8911f404aec6116a848748c943 Mon Sep 17 00:00:00 2001 From: randx Date: Fri, 27 Jul 2012 23:57:42 +0300 Subject: [PATCH 31/33] Fix issue padding cause PR 1144 --- app/assets/stylesheets/sections/issues.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index 7fbfa8b167b..0f144cf8235 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -30,6 +30,10 @@ .issue { padding:7px 10px; + p { + padding-top:0; + } + img.avatar { width:32px; margin-top:4px; From bc7897180d8cfad0f573137d379fedfa7939ee0f Mon Sep 17 00:00:00 2001 From: randx Date: Sat, 28 Jul 2012 00:27:54 +0300 Subject: [PATCH 32/33] Better visibility of event commit links & commits ids --- app/assets/stylesheets/common.scss | 9 +++++++++ app/assets/stylesheets/gitlab_bootstrap.scss | 3 ++- app/assets/stylesheets/sections/commits.scss | 7 +++++++ app/assets/stylesheets/sections/issues.scss | 5 +---- app/views/commits/_commit.html.haml | 2 +- app/views/events/_commit.html.haml | 6 +++--- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 0db803aae23..9d9bfb7db72 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -337,6 +337,15 @@ p.time { padding: 15px 5px; &:last-child { border:none } .wll:hover { background:none } + + .event_commits { + margin-top: 5px; + + li.commit { + padding:5px; + border:none; + } + } } .ico { diff --git a/app/assets/stylesheets/gitlab_bootstrap.scss b/app/assets/stylesheets/gitlab_bootstrap.scss index 75d246cd349..b01f1274407 100644 --- a/app/assets/stylesheets/gitlab_bootstrap.scss +++ b/app/assets/stylesheets/gitlab_bootstrap.scss @@ -18,7 +18,8 @@ a { } &.lined { - text-decoration:underlined; + text-decoration:underline; + &:hover { text-decoration:underline; } } &.gray { diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss index 35c3cffd7f1..e2db701db71 100644 --- a/app/assets/stylesheets/sections/commits.scss +++ b/app/assets/stylesheets/sections/commits.scss @@ -199,4 +199,11 @@ background:#FCEEC1; color:$style_color; } + + .commit_short_id { + float:left; + @extend .lined; + min-width:65px; + font-family: 'Menlo', 'Liberation Mono', 'Consolas', 'Courier New', 'andale mono','lucida console',monospace; + } } diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index 0f144cf8235..12926d3fdb1 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -32,15 +32,12 @@ p { padding-top:0; + padding-bottom:2px; } img.avatar { width:32px; margin-top:4px; } - .row_title { - padding:0px; - padding-bottom:2px; - } } } diff --git a/app/views/commits/_commit.html.haml b/app/views/commits/_commit.html.haml index 63339d36367..9824161493d 100644 --- a/app/views/commits/_commit.html.haml +++ b/app/views/commits/_commit.html.haml @@ -3,7 +3,7 @@ %p %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit.id), :class => "right" %p - %code.left= link_to commit.short_id, project_commit_path(@project, :id => commit.id) + = link_to commit.short_id(8), project_commit_path(@project, :id => commit.id), :class => "commit_short_id" %strong.cgray= commit.author_name – = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16 diff --git a/app/views/events/_commit.html.haml b/app/views/events/_commit.html.haml index 5a9d223d546..d6c5546148d 100644 --- a/app/views/events/_commit.html.haml +++ b/app/views/events/_commit.html.haml @@ -1,9 +1,9 @@ - commit = CommitDecorator.decorate(commit) %li.wll.commit %p - %code.left= link_to commit.short_id, project_commit_path(project, :id => commit.id) - %strong.cgray= commit.author_name + = link_to commit.short_id(8), project_commit_path(project, :id => commit.id), :class => "commit_short_id" + %strong.cdark= commit.author_name – = image_tag gravatar_icon(commit.author_email), :class => "avatar", :width => 16 - = link_to truncate(commit.title, :length => 50), project_commit_path(project, :id => commit.id), :class => "row_title" rescue "--broken encoding" + = truncate(commit.title, :length => 50) rescue "--broken encoding" From 3caf0aa89a964b8b3dcd21536e5bc274165ed2a2 Mon Sep 17 00:00:00 2001 From: randx Date: Sat, 28 Jul 2012 00:40:14 +0300 Subject: [PATCH 33/33] fix commits spec --- spec/requests/commits_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/requests/commits_spec.rb b/spec/requests/commits_spec.rb index 0418697ea93..ae36a932ae0 100644 --- a/spec/requests/commits_spec.rb +++ b/spec/requests/commits_spec.rb @@ -23,7 +23,7 @@ describe "Commits" do it "should list commits" do page.should have_content(commit.description) - page.should have_content(commit.short_id) + page.should have_content(commit.short_id(8)) end it "should render atom feed" do