From b78fd0c13088ce2c19d939a26a26e247ca5047ea Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 5 Sep 2012 16:49:59 -0400 Subject: [PATCH 01/24] Add github-markup gem --- Gemfile | 1 + Gemfile.lock | 2 ++ app/controllers/refs_controller.rb | 2 ++ 3 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index b0724fad..34f7c274 100644 --- a/Gemfile +++ b/Gemfile @@ -45,6 +45,7 @@ gem "seed-fu" # Markdown to HTML gem "redcarpet", "~> 2.1.1" +gem 'github-markup' # Servers gem "thin" diff --git a/Gemfile.lock b/Gemfile.lock index f350b3fc..fc730802 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -178,6 +178,7 @@ GEM gherkin (2.11.0) json (>= 1.4.6) git (1.2.5) + github-markup (0.7.4) gitlab_meta (2.9) grape (0.2.1) hashie (~> 1.2) @@ -396,6 +397,7 @@ DEPENDENCIES ffaker foreman git + github-markup gitlab_meta (= 2.9) gitolite! grack! diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 3f81a2ca..90361437 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -1,3 +1,5 @@ +require 'github/markup' + class RefsController < ApplicationController include Gitlab::Encode before_filter :project From 52c521ffe84dac5dc72a299ee1ecf4736a10f07f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 5 Sep 2012 16:52:49 -0400 Subject: [PATCH 02/24] Use GitHub::Markup to parse markup files Closes #1382 --- app/helpers/tree_helper.rb | 10 ++++++++++ app/views/refs/_tree.html.haml | 6 +----- app/views/refs/_tree_file.html.haml | 5 ++--- spec/helpers/tree_helper_spec.rb | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 spec/helpers/tree_helper_spec.rb diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index ed3053d8..c51ee84a 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -24,4 +24,14 @@ module TreeHelper content.name end end + + # Public: Determines if a given filename is compatible with GitHub::Markup. + # + # filename - Filename string to check + # + # Returns boolean + def markup?(filename) + filename.end_with?(*%w(.mdown .md .markdown .textile .rdoc .org .creole + .mediawiki .rst .asciidoc .pod)) + end end diff --git a/app/views/refs/_tree.html.haml b/app/views/refs/_tree.html.haml index a4765c10..297a3b5f 100644 --- a/app/views/refs/_tree.html.haml +++ b/app/views/refs/_tree.html.haml @@ -43,11 +43,7 @@ %i.icon-file = content.name .file_content.wiki - - if content.name =~ /\.(md|markdown)$/i - = preserve do - = markdown(content.data) - - else - = simple_format(content.data) + = raw GitHub::Markup.render(content.name, content.data) :javascript $(function(){ diff --git a/app/views/refs/_tree_file.html.haml b/app/views/refs/_tree_file.html.haml index b5ed61bb..765f271a 100644 --- a/app/views/refs/_tree_file.html.haml +++ b/app/views/refs/_tree_file.html.haml @@ -9,10 +9,9 @@ = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" = link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small" - if file.text? - - if name =~ /\.(md|markdown)$/i + - if markup?(name) .file_content.wiki - = preserve do - = markdown(file.data) + = raw GitHub::Markup.render(name, file.data) - else .file_content.code - unless file.empty? diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb new file mode 100644 index 00000000..bb124d8b --- /dev/null +++ b/spec/helpers/tree_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe TreeHelper do + describe '#markup?' do + %w(mdown md markdown textile rdoc org creole mediawiki rst asciidoc pod).each do |type| + it "returns true for #{type} files" do + markup?("README.#{type}").should be_true + end + end + + it "returns false when given a non-markup filename" do + markup?('README.rb').should_not be_true + end + end +end From 1814ee0ced59aa3203ce265410ae5a7c83e096aa Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 5 Sep 2012 17:02:23 -0400 Subject: [PATCH 03/24] Give github-markup gem a version requirement --- Gemfile | 4 ++-- Gemfile.lock | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 34f7c274..c8d3821f 100644 --- a/Gemfile +++ b/Gemfile @@ -44,8 +44,8 @@ gem "ffaker" gem "seed-fu" # Markdown to HTML -gem "redcarpet", "~> 2.1.1" -gem 'github-markup' +gem "redcarpet", "~> 2.1.1" +gem "github-markup", "~> 0.7.4" # Servers gem "thin" diff --git a/Gemfile.lock b/Gemfile.lock index fc730802..830e28b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -397,7 +397,7 @@ DEPENDENCIES ffaker foreman git - github-markup + github-markup (~> 0.7.4) gitlab_meta (= 2.9) gitolite! grack! From 8559d9a156819b576127a944dbcce1fe335d68ba Mon Sep 17 00:00:00 2001 From: Dae Myung Date: Sat, 8 Sep 2012 04:24:38 -0700 Subject: [PATCH 04/24] sending argument project but there is no project to send --- lib/gitlab/backend/gitolite.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/backend/gitolite.rb b/lib/gitlab/backend/gitolite.rb index 658182c7..fe5dcef4 100644 --- a/lib/gitlab/backend/gitolite.rb +++ b/lib/gitlab/backend/gitolite.rb @@ -35,7 +35,7 @@ module Gitlab end def enable_automerge - config.admin_all_repo!(project) + config.admin_all_repo! end alias_method :create_repository, :update_repository From 1c0153682927f72f6b3011db11ddf5a139f9d16a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sun, 9 Sep 2012 05:40:22 -0400 Subject: [PATCH 05/24] Fix spelling of "empty" in disableButtonIfEmptyField function name --- app/assets/javascripts/issues.js | 4 ++-- app/assets/javascripts/note.js | 4 ++-- app/assets/javascripts/projects.js.coffee | 2 +- app/views/merge_requests/_form.html.haml | 2 +- app/views/milestones/_form.html.haml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/issues.js b/app/assets/javascripts/issues.js index 148dc7b9..3ddc6926 100644 --- a/app/assets/javascripts/issues.js +++ b/app/assets/javascripts/issues.js @@ -5,7 +5,7 @@ function switchToNewIssue(form){ $('select#issue_milestone_id').chosen(); $("#new_issue_dialog").show("fade", { direction: "right" }, 150); $('.top-tabs .add_new').hide(); - disableButtonIfEmtpyField("#issue_title", ".save-btn"); + disableButtonIfEmptyField("#issue_title", ".save-btn"); }); } @@ -16,7 +16,7 @@ function switchToEditIssue(form){ $('select#issue_milestone_id').chosen(); $("#edit_issue_dialog").show("fade", { direction: "right" }, 150); $('.add_new').hide(); - disableButtonIfEmtpyField("#issue_title", ".save-btn"); + disableButtonIfEmptyField("#issue_title", ".save-btn"); }); } diff --git a/app/assets/javascripts/note.js b/app/assets/javascripts/note.js index 9cd3e36e..160f75c9 100644 --- a/app/assets/javascripts/note.js +++ b/app/assets/javascripts/note.js @@ -32,7 +32,7 @@ var NoteList = { $(".submit_note").removeAttr("disabled"); }) - disableButtonIfEmtpyField(".note-text", ".submit_note"); + disableButtonIfEmptyField(".note-text", ".submit_note"); $(".note-text").live("focus", function(){ $(this).css("height", "80px"); @@ -177,6 +177,6 @@ var PerLineNotes = { form.show(); return false; }); - disableButtonIfEmtpyField(".line-note-text", ".submit_inline_note"); + disableButtonIfEmptyField(".line-note-text", ".submit_inline_note"); } } diff --git a/app/assets/javascripts/projects.js.coffee b/app/assets/javascripts/projects.js.coffee index 85ab2a06..14738e14 100644 --- a/app/assets/javascripts/projects.js.coffee +++ b/app/assets/javascripts/projects.js.coffee @@ -8,7 +8,7 @@ window.Projects = -> $('.save-project-loader').show() $('form #project_default_branch').chosen() - disableButtonIfEmtpyField '#project_name', '.project-submit' + disableButtonIfEmptyField '#project_name', '.project-submit' # Git clone panel switcher $ -> diff --git a/app/views/merge_requests/_form.html.haml b/app/views/merge_requests/_form.html.haml index b554c051..d5271ed0 100644 --- a/app/views/merge_requests/_form.html.haml +++ b/app/views/merge_requests/_form.html.haml @@ -60,7 +60,7 @@ :javascript $(function(){ - disableButtonIfEmtpyField("#merge_request_title", ".save-btn"); + disableButtonIfEmptyField("#merge_request_title", ".save-btn"); $('select#merge_request_assignee_id').chosen(); $('select#merge_request_source_branch').chosen(); $('select#merge_request_target_branch').chosen(); diff --git a/app/views/milestones/_form.html.haml b/app/views/milestones/_form.html.haml index ce4145ba..194eac77 100644 --- a/app/views/milestones/_form.html.haml +++ b/app/views/milestones/_form.html.haml @@ -41,7 +41,7 @@ :javascript $(function() { - disableButtonIfEmtpyField("#milestone_title", ".save-btn"); + disableButtonIfEmptyField("#milestone_title", ".save-btn"); $( ".datepicker" ).datepicker({ dateFormat: "yy-mm-dd", onSelect: function(dateText, inst) { $("#milestone_due_date").val(dateText) } From 93daa8c568cff8c59eb77c7a47b72e0266613d5a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sun, 9 Sep 2012 05:30:49 -0400 Subject: [PATCH 06/24] Move main.js to main.js.coffee --- app/assets/javascripts/{main.js => main.js.coffee} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/assets/javascripts/{main.js => main.js.coffee} (100%) diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js.coffee similarity index 100% rename from app/assets/javascripts/main.js rename to app/assets/javascripts/main.js.coffee From 3b89f140905dd1e929d5bf587fa2509866ba5d32 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sun, 9 Sep 2012 05:59:15 -0400 Subject: [PATCH 07/24] Convert main.js to coffee Remove duplicate 's' hotkey code --- app/assets/javascripts/main.js.coffee | 176 +++++++++--------------- app/views/layouts/_head_panel.html.haml | 8 -- 2 files changed, 65 insertions(+), 119 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 61af1dc3..a614cf5b 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -1,130 +1,84 @@ -$(document).ready(function(){ +window.updatePage = (data) -> + $.ajax({type: "GET", url: location.href, data: data, dataType: "script"}) - $(".one_click_select").live("click", function(){ - $(this).select(); - }); +window.slugify = (text) -> + text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase() - $('body').on('ajax:complete, ajax:beforeSend, submit', 'form', function(e){ - var buttons = $('[type="submit"]', this); - switch( e.type ){ - case 'ajax:beforeSend': - case 'submit': - buttons.attr('disabled', 'disabled'); - break; - case ' ajax:complete': - default: - buttons.removeAttr('disabled'); - break; - } - }) +window.ajaxGet = (url) -> + $.ajax({type: "GET", url: url, dataType: "script"}) - $(".account-box").mouseenter(showMenu); - $(".account-box").mouseleave(resetMenu); + # Disable button if text field is empty +window.disableButtonIfEmptyField = (field_selector, button_selector) -> + field = $(field_selector) + closest_submit = field.closest("form").find(button_selector) - $("#projects-list .project").live('click', function(e){ - if(e.target.nodeName != "A" && e.target.nodeName != "INPUT") { - location.href = $(this).attr("url"); - e.stopPropagation(); - return false; - } - }); + closest_submit.attr("disabled", "disabled").addClass("disabled") if field.val() is "" - /** - * Focus search field by pressing 's' key - */ - $(document).keypress(function(e) { - if( $(e.target).is(":input") ) return; - switch(e.which) { - case 115: focusSearch(); - e.preventDefault(); - } - }); + field.on "keyup", -> + if $(this).val() is "" + closest_submit.attr("disabled", "disabled").addClass "disabled" + else + closest_submit.removeAttr("disabled").removeClass "disabled" - /** - * Commit show suppressed diff - * - */ - $(".supp_diff_link").bind("click", function() { - showDiff(this); - }); +$ -> + $(".one_click_select").live 'click', -> + $(this).select() - /** - * Note markdown preview - * - */ - $(document).on('click', '#preview-link', function(e) { - $('#preview-note').text('Loading...'); + $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> + buttons = $('[type="submit"]', this) - var previewLinkText = ($(this).text() == 'Preview' ? 'Edit' : 'Preview'); - $(this).text(previewLinkText); + switch e.type + when 'ajax:beforeSend', 'submit' + buttons.attr('disabled', 'disabled') + else + buttons.removeAttr('disabled') - var note = $('#note_note').val(); - if (note.trim().length === 0) { note = 'Nothing to preview'; } - $.post($(this).attr('href'), {note: note}, function(data) { - $('#preview-note').html(data); - }); + # Show/Hide the profile menu when hovering the account box + $('.account-box').hover -> $(this).toggleClass('hover') - $('#preview-note, #note_note').toggle(); - e.preventDefault(); - }); -}); + $("#projects-list .project").live 'click', (e) -> + if e.target.nodeName isnt "A" and e.target.nodeName isnt "INPUT" + location.href = $(this).attr("url") + e.stopPropagation() + false -function focusSearch() { - $("#search").focus(); -} + # Focus search field by pressing 's' key + $(document).keypress (e) -> + # Don't do anything if typing in an input + return if $(e.target).is(":input") -function updatePage(data){ - $.ajax({type: "GET", url: location.href, data: data, dataType: "script"}); -} + switch e.which + when 115 + $("#search").focus() + e.preventDefault() -function showMenu() { - $(this).toggleClass('hover'); -} + # Commit show suppressed diff + $(".supp_diff_link").bind "click", -> + $(this).next('table').show() + $(this).remove() -function resetMenu() { - $(this).removeClass("hover"); -} + # Note markdown preview + $(document).on 'click', '#preview-link', (e) -> + $('#preview-note').text('Loading...') -function slugify(text) { - return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase(); -} + previewLinkText = if $(this).text() == 'Preview' then 'Edit' else 'Preview' + $(this).text(previewLinkText) -function showDiff(link) { - $(link).next('table').show(); - $(link).remove(); -} + note = $('#note_note').val() + note = 'Nothing to preview' if note.trim().length is 0 + $.post($(this).attr('href'), {note: note}, (data) -> + $('#preview-note').html(data) + ) -(function($){ - var _chosen = $.fn.chosen; - $.fn.extend({ - chosen: function(options) { - var default_options = {'search_contains' : 'true'}; - $.extend(default_options, options); - return _chosen.apply(this, [default_options]); - }}) -})(jQuery); + $('#preview-note, #note_note').toggle() + e.preventDefault() + false +(($) -> + _chosen = $.fn.chosen + $.fn.extend chosen: (options) -> + default_options = search_contains: "true" + $.extend default_options, options + _chosen.apply this, [default_options] -function ajaxGet(url) { - $.ajax({type: "GET", url: url, dataType: "script"}); -} - -/** - * Disable button if text field is empty - */ -function disableButtonIfEmtpyField(field_selector, button_selector) { - field = $(field_selector); - if(field.val() == "") { - field.closest("form").find(button_selector).attr("disabled", "disabled").addClass("disabled"); - } - - field.on('keyup', function(){ - var field = $(this); - var closest_submit = field.closest("form").find(button_selector); - if(field.val() == "") { - closest_submit.attr("disabled", "disabled").addClass("disabled"); - } else { - closest_submit.removeAttr("disabled").removeClass("disabled"); - } - }) -} +)(jQuery) diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index d6247d36..f5e423a5 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -34,12 +34,4 @@ source: #{raw search_autocomplete_source}, select: function(event, ui) { location.href = ui.item.url } }); - - $(document).keypress(function(e) { - if($(e.target).is(":input")) return; - switch(e.which) { - case 115: focusSearch(); - e.preventDefault(); - } - }); }); From ad1aa517c7052d26e7243f6574b3deacddd0b161 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sun, 9 Sep 2012 07:08:13 -0400 Subject: [PATCH 08/24] Add "enable" and "disable" jQuery functions Handles (un)setting the disabled attribute and adding/removing the 'disabled' class --- app/assets/javascripts/main.js.coffee | 19 ++++++++++++++----- app/assets/javascripts/note.js | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index a614cf5b..84129069 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -12,26 +12,27 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) -> field = $(field_selector) closest_submit = field.closest("form").find(button_selector) - closest_submit.attr("disabled", "disabled").addClass("disabled") if field.val() is "" + closest_submit.disable() if field.val() is "" field.on "keyup", -> if $(this).val() is "" - closest_submit.attr("disabled", "disabled").addClass "disabled" + closest_submit.disable() else - closest_submit.removeAttr("disabled").removeClass "disabled" + closest_submit.enable() $ -> $(".one_click_select").live 'click', -> $(this).select() + # Disable form buttons while a form is submitting $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> buttons = $('[type="submit"]', this) switch e.type when 'ajax:beforeSend', 'submit' - buttons.attr('disabled', 'disabled') + buttons.disable() else - buttons.removeAttr('disabled') + buttons.enable() # Show/Hide the profile menu when hovering the account box $('.account-box').hover -> $(this).toggleClass('hover') @@ -81,4 +82,12 @@ $ -> $.extend default_options, options _chosen.apply this, [default_options] + # Disable an element and add the 'disabled' Bootstrap class + $.fn.extend disable: -> + $(this).attr('disabled', 'disabled').addClass('disabled') + + # Enable an element and remove the 'disabled' Bootstrap class + $.fn.extend enable: -> + $(this).removeAttr('disabled').removeClass('disabled') + )(jQuery) diff --git a/app/assets/javascripts/note.js b/app/assets/javascripts/note.js index 160f75c9..79ab086b 100644 --- a/app/assets/javascripts/note.js +++ b/app/assets/javascripts/note.js @@ -25,11 +25,11 @@ var NoteList = { $(this).closest('li').fadeOut(); }); $(".note-form-holder").live("ajax:before", function(){ - $(".submit_note").attr("disabled", "disabled"); + $(".submit_note").disable() }) $(".note-form-holder").live("ajax:complete", function(){ - $(".submit_note").removeAttr("disabled"); + $(".submit_note").enable() }) disableButtonIfEmptyField(".note-text", ".submit_note"); From 3551df8eb1c1bfe3a4cef532ddab1cbdcdd96a11 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sun, 9 Sep 2012 07:17:01 -0400 Subject: [PATCH 09/24] Minor main.js refactor and docs --- app/assets/javascripts/main.js.coffee | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 84129069..6002f85d 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -21,8 +21,8 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) -> closest_submit.enable() $ -> - $(".one_click_select").live 'click', -> - $(this).select() + # Click a .one_click_select field, select the contents + $(".one_click_select").live 'click', -> $(this).select() # Disable form buttons while a form is submitting $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> @@ -66,10 +66,12 @@ $ -> $(this).text(previewLinkText) note = $('#note_note').val() - note = 'Nothing to preview' if note.trim().length is 0 - $.post($(this).attr('href'), {note: note}, (data) -> - $('#preview-note').html(data) - ) + + if note.trim().length == 0 + $('#preview-note').text("Nothing to preview.") + else + $.post $(this).attr('href'), {note: note}, (data) -> + $('#preview-note').html(data) $('#preview-note, #note_note').toggle() e.preventDefault() From 5dcca7e4806730d4d77eff711a9b91b5a3ca8314 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sun, 9 Sep 2012 07:17:43 -0400 Subject: [PATCH 10/24] Remove some JS that is no longer used --- app/assets/javascripts/main.js.coffee | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 6002f85d..a01b3932 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -37,12 +37,6 @@ $ -> # Show/Hide the profile menu when hovering the account box $('.account-box').hover -> $(this).toggleClass('hover') - $("#projects-list .project").live 'click', (e) -> - if e.target.nodeName isnt "A" and e.target.nodeName isnt "INPUT" - location.href = $(this).attr("url") - e.stopPropagation() - false - # Focus search field by pressing 's' key $(document).keypress (e) -> # Don't do anything if typing in an input From ad3a88cfd34aeed5ed69b4056e393580a686fb09 Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 29 Aug 2012 02:03:04 +0300 Subject: [PATCH 11/24] Prepared for gitolite v3 --- app/models/merge_request.rb | 2 +- app/roles/push_event.rb | 2 ++ config/gitlab.yml.example | 4 ++-- doc/installation.md | 15 +++++++++------ lib/gitlab/merge.rb | 3 +-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 542817b0..2e457f72 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -162,7 +162,7 @@ class MergeRequest < ActiveRecord::Base end def automerge!(current_user) - if Gitlab::Merge.new(self, current_user).merge + if Gitlab::Merge.new(self, current_user).merge && self.unmerged_commits.empty? self.merge!(current_user.id) true end diff --git a/app/roles/push_event.rb b/app/roles/push_event.rb index ff8e28a2..a607f212 100644 --- a/app/roles/push_event.rb +++ b/app/roles/push_event.rb @@ -90,6 +90,8 @@ module PushEvent def push_with_commits? md_ref? && commits.any? && parent_commit && last_commit + rescue Grit::NoSuchPathError + false end def last_push_to_non_root? diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index d05cc1be..77b818ba 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -33,11 +33,11 @@ app: git_host: admin_uri: git@localhost:gitolite-admin base_path: /home/git/repositories/ - # hooks_path: /var/lib/gitolite/.gitolite/hooks/ # only needed when gitolite is not installed according the manual - # host: localhost + hooks_path: /home/git/.gitolite/hooks/ git_user: git upload_pack: true receive_pack: true + # host: localhost # port: 22 # Git settings diff --git a/doc/installation.md b/doc/installation.md index e14ec711..af169d81 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -113,17 +113,20 @@ Generate key: Clone GitLab's fork of the Gitolite source code: cd /home/git - sudo -H -u git git clone https://github.com/gitlabhq/gitolite.git /home/git/gitolite + sudo -H -u git git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite Setup: + cd /home/git + sudo -u git -H mkdir bin sudo -u git sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" >> /home/git/.profile' - sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; /home/git/gitolite/src/gl-system-install" + sudo -u git sh -c 'gitolite/install -ln /home/git/bin' + sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub sudo chmod 0444 /home/git/gitlab.pub - sudo -u git -H sed -i 's/0077/0007/g' /home/git/share/gitolite/conf/example.gitolite.rc - sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gl-setup -q /home/git/gitlab.pub" + sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub" + sudo -u git -H sed -i 's/0077/0007/g' /home/git/.gitolite.rc Permissions: @@ -189,8 +192,8 @@ and ensure you have followed all of the above steps carefully. #### Setup GitLab hooks - sudo cp ./lib/hooks/post-receive /home/git/share/gitolite/hooks/common/post-receive - sudo chown git:git /home/git/share/gitolite/hooks/common/post-receive + sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive + sudo chown git:git /home/git/.gitolite/hooks/common/post-receive #### Check application status diff --git a/lib/gitlab/merge.rb b/lib/gitlab/merge.rb index 134695ce..18013574 100644 --- a/lib/gitlab/merge.rb +++ b/lib/gitlab/merge.rb @@ -21,8 +21,7 @@ module Gitlab if output =~ /CONFLICT/ false else - repo.git.push({}, "origin", merge_request.target_branch) - true + !!repo.git.push({}, "origin", merge_request.target_branch) end end end From a56cec113204130385e0fbc3f2223d81101357ef Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 29 Aug 2012 02:08:39 +0300 Subject: [PATCH 12/24] specify gitolite-admin owner in config --- config/gitlab.yml.example | 1 + config/initializers/1_settings.rb | 4 ++++ lib/gitlab/backend/gitolite_config.rb | 13 +------------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 77b818ba..08e3427f 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -34,6 +34,7 @@ git_host: admin_uri: git@localhost:gitolite-admin base_path: /home/git/repositories/ hooks_path: /home/git/.gitolite/hooks/ + gitolite_admin_key: gitlab git_user: git upload_pack: true receive_pack: true diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 27c5bc22..df9ccf32 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -102,6 +102,10 @@ class Settings < Settingslogic git_host['admin_uri'] || 'git@localhost:gitolite-admin' end + def gitolite_admin_key + git_host['gitolite_admin_key'] || 'gitlab' + end + def default_projects_limit app['default_projects_limit'] || 10 end diff --git a/lib/gitlab/backend/gitolite_config.rb b/lib/gitlab/backend/gitolite_config.rb index 61ec8c11..60eef8e8 100644 --- a/lib/gitlab/backend/gitolite_config.rb +++ b/lib/gitlab/backend/gitolite_config.rb @@ -148,18 +148,7 @@ module Gitlab # Enable access to all repos for gitolite admin. # We use it for accept merge request feature def admin_all_repo - owner_name = "" - - # Read gitolite-admin user - # - begin - repo = conf.get_repo("gitolite-admin") - owner_name = repo.permissions[0]["RW+"][""][0] - raise StandardError if owner_name.blank? - rescue => ex - puts "Can't determine gitolite-admin owner".red - raise StandardError - end + owner_name = Gitlab.settings.gitolite_admin_key # @ALL repos premission for gitolite owner repo_name = "@all" From a86bd87afcb8ba8221aa72562a6591139fa763c0 Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Sun, 9 Sep 2012 23:18:28 +0300 Subject: [PATCH 13/24] User joined project event added --- app/assets/stylesheets/common.scss | 8 ++++++++ app/decorators/event_decorator.rb | 5 ++++- app/models/event.rb | 9 ++++++++- app/observers/users_project_observer.rb | 6 ++++++ app/views/events/_event.html.haml | 4 ++++ app/views/events/_event_joined.html.haml | 8 ++++++++ features/dashboard/dashboard.feature | 7 ++++++- features/step_definitions/dashboard_steps.rb | 15 +++++++++++++++ spec/models/event_spec.rb | 11 +++++++++++ spec/observers/users_project_observer_spec.rb | 8 ++++++++ 10 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 app/views/events/_event_joined.html.haml diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index aa27a280..012aad03 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -179,6 +179,14 @@ span.update-author { &.merged { background-color: #2A2; } + + &.joined { + background-color: #1cb9ff; + } + + &.left { + background-color: #ff5057; + } } form { diff --git a/app/decorators/event_decorator.rb b/app/decorators/event_decorator.rb index 7df9081f..265dbe1a 100644 --- a/app/decorators/event_decorator.rb +++ b/app/decorators/event_decorator.rb @@ -8,7 +8,10 @@ class EventDecorator < ApplicationDecorator "#{self.author_name} #{self.action_name} MR ##{self.target_id}:" + self.merge_request_title elsif self.push? "#{self.author_name} #{self.push_action_name} #{self.ref_type} " + self.ref_name - else + elsif self.joined? + "#{self.author_name} #{self.action_name} #{self.project.name}" + + else "" end end diff --git a/app/models/event.rb b/app/models/event.rb index e20b79e2..15095d3b 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -10,6 +10,7 @@ class Event < ActiveRecord::Base Pushed = 5 Commented = 6 Merged = 7 + Joined = 8 # User joined project belongs_to :project belongs_to :target, polymorphic: true @@ -37,7 +38,7 @@ class Event < ActiveRecord::Base # - new issue # - merge request def allowed? - push? || issue? || merge_request? + push? || issue? || merge_request? || joined? end def push? @@ -84,6 +85,10 @@ class Event < ActiveRecord::Base [Closed, Reopened].include?(action) end + def joined? + action == self.class::Joined + end + def issue target if target_type == "Issue" end @@ -101,6 +106,8 @@ class Event < ActiveRecord::Base "closed" elsif merged? "merged" + elsif joined? + 'joined' else "opened" end diff --git a/app/observers/users_project_observer.rb b/app/observers/users_project_observer.rb index 763b2c87..2a98a194 100644 --- a/app/observers/users_project_observer.rb +++ b/app/observers/users_project_observer.rb @@ -1,6 +1,12 @@ class UsersProjectObserver < ActiveRecord::Observer def after_create(users_project) Notify.project_access_granted_email(users_project.id).deliver + + Event.create( + project_id: users_project.project.id, + action: Event::Joined, + author_id: users_project.user.id + ) end def after_update(users_project) diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml index d49f0382..7566c094 100644 --- a/app/views/events/_event.html.haml +++ b/app/views/events/_event.html.haml @@ -11,3 +11,7 @@ .event_feed = render "events/event_push", event: event + - elsif event.joined? + .event_feed + = render "events/event_joined", event: event + diff --git a/app/views/events/_event_joined.html.haml b/app/views/events/_event_joined.html.haml new file mode 100644 index 00000000..6195da81 --- /dev/null +++ b/app/views/events/_event_joined.html.haml @@ -0,0 +1,8 @@ += image_tag gravatar_icon(event.author_email), class: "avatar" +%strong #{event.author_name} +%span.event_label{class: event.action_name}= event.action_name +%strong= link_to event.project.name, event.project +%span.cgray + = time_ago_in_words(event.created_at) + ago. + diff --git a/features/dashboard/dashboard.feature b/features/dashboard/dashboard.feature index a8c2205c..8775e081 100644 --- a/features/dashboard/dashboard.feature +++ b/features/dashboard/dashboard.feature @@ -15,4 +15,9 @@ Feature: Dashboard And I click "Create Merge Request" link Then I see prefilled new Merge Request page - + @current + Scenario: I should see User joined Project event + Given user with name "John Doe" joined project "Shop" + When I visit dashboard page + Then I should see "John Doe joined Shop" event + diff --git a/features/step_definitions/dashboard_steps.rb b/features/step_definitions/dashboard_steps.rb index 867233c8..3771fb9c 100644 --- a/features/step_definitions/dashboard_steps.rb +++ b/features/step_definitions/dashboard_steps.rb @@ -109,3 +109,18 @@ Given /^I have authored merge requests$/ do :author => @user, :project => project2 end + +Given /^user with name "(.*?)" joined project "(.*?)"$/ do |user_name, project_name| + user = Factory.create(:user, {name: user_name}) + project = Project.find_by_name project_name + Event.create( + project: project, + author_id: user.id, + action: Event::Joined + ) +end + +Then /^I should see "(.*?)" event$/ do |event_text| + page.should have_content(event_text) +end + diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index aaffda31..81459233 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -49,4 +49,15 @@ describe Event do it { @event.branch_name.should == "master" } it { @event.author.should == @user } end + + describe "New team mamber" do + let(:project) {Factory.create :project} + let(:new_user) {Factory.create :user} + it "should create event" do + UsersProject.observers.enable :users_project_observer + expect{ + UsersProject.bulk_import(project, [new_user.id], UsersProject::DEVELOPER) + }.to change{Event.count}.by(1) + end + end end diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index 3e392040..99130aa5 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -23,6 +23,14 @@ describe UsersProjectObserver do Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true)) subject.after_create(users_project) end + it "should create new event" do + Event.should_receive(:create).with( + project_id: users_project.project.id, + action: Event::Joined, + author_id: users_project.user.id + ) + subject.after_create(users_project) + end end describe "#after_update" do From 1f240b09ed5f9f5476a863dd2f906398e5a9f0d4 Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Mon, 10 Sep 2012 00:27:47 +0300 Subject: [PATCH 14/24] User left project event added --- app/decorators/event_decorator.rb | 3 +-- app/models/event.rb | 15 +++++++++++++-- app/models/users_project.rb | 2 +- app/observers/users_project_observer.rb | 9 +++++++++ app/views/events/_event.html.haml | 4 ++-- ...ml => _event_membership_changed.html.haml} | 1 + features/dashboard/dashboard.feature | 9 +++++++-- features/step_definitions/dashboard_steps.rb | 10 ++++++++++ spec/models/event_spec.rb | 13 ++++++++++++- spec/observers/users_project_observer_spec.rb | 19 +++++++++++++++++++ 10 files changed, 75 insertions(+), 10 deletions(-) rename app/views/events/{_event_joined.html.haml => _event_membership_changed.html.haml} (97%) diff --git a/app/decorators/event_decorator.rb b/app/decorators/event_decorator.rb index 265dbe1a..ce0aaa03 100644 --- a/app/decorators/event_decorator.rb +++ b/app/decorators/event_decorator.rb @@ -8,9 +8,8 @@ class EventDecorator < ApplicationDecorator "#{self.author_name} #{self.action_name} MR ##{self.target_id}:" + self.merge_request_title elsif self.push? "#{self.author_name} #{self.push_action_name} #{self.ref_type} " + self.ref_name - elsif self.joined? + elsif self.membership_changed? "#{self.author_name} #{self.action_name} #{self.project.name}" - else "" end diff --git a/app/models/event.rb b/app/models/event.rb index 15095d3b..308ffd63 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -11,6 +11,7 @@ class Event < ActiveRecord::Base Commented = 6 Merged = 7 Joined = 8 # User joined project + Left = 9 # User left project belongs_to :project belongs_to :target, polymorphic: true @@ -38,7 +39,7 @@ class Event < ActiveRecord::Base # - new issue # - merge request def allowed? - push? || issue? || merge_request? || joined? + push? || issue? || merge_request? || membership_changed? end def push? @@ -86,7 +87,15 @@ class Event < ActiveRecord::Base end def joined? - action == self.class::Joined + action == Joined + end + + def left? + action == Left + end + + def membership_changed? + joined? || left? end def issue @@ -108,6 +117,8 @@ class Event < ActiveRecord::Base "merged" elsif joined? 'joined' + elsif left? + 'left' else "opened" end diff --git a/app/models/users_project.rb b/app/models/users_project.rb index 3b951f0d..ce64a10f 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -23,7 +23,7 @@ class UsersProject < ActiveRecord::Base def self.bulk_delete(project, user_ids) UsersProject.transaction do UsersProject.where(:user_id => user_ids, :project_id => project.id).each do |users_project| - users_project.delete + users_project.destroy end end end diff --git a/app/observers/users_project_observer.rb b/app/observers/users_project_observer.rb index 2a98a194..b2cea9f2 100644 --- a/app/observers/users_project_observer.rb +++ b/app/observers/users_project_observer.rb @@ -12,4 +12,13 @@ class UsersProjectObserver < ActiveRecord::Observer def after_update(users_project) Notify.project_access_granted_email(users_project.id).deliver end + + def after_destroy(users_project) + Event.create( + project_id: users_project.project.id, + action: Event::Left, + author_id: users_project.user.id + ) + end + end diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml index 7566c094..7bae8db1 100644 --- a/app/views/events/_event.html.haml +++ b/app/views/events/_event.html.haml @@ -11,7 +11,7 @@ .event_feed = render "events/event_push", event: event - - elsif event.joined? + - elsif event.membership_changed? .event_feed - = render "events/event_joined", event: event + = render "events/event_membership_changed", event: event diff --git a/app/views/events/_event_joined.html.haml b/app/views/events/_event_membership_changed.html.haml similarity index 97% rename from app/views/events/_event_joined.html.haml rename to app/views/events/_event_membership_changed.html.haml index 6195da81..b079c138 100644 --- a/app/views/events/_event_joined.html.haml +++ b/app/views/events/_event_membership_changed.html.haml @@ -1,6 +1,7 @@ = image_tag gravatar_icon(event.author_email), class: "avatar" %strong #{event.author_name} %span.event_label{class: event.action_name}= event.action_name +project %strong= link_to event.project.name, event.project %span.cgray = time_ago_in_words(event.created_at) diff --git a/features/dashboard/dashboard.feature b/features/dashboard/dashboard.feature index 8775e081..98bb4980 100644 --- a/features/dashboard/dashboard.feature +++ b/features/dashboard/dashboard.feature @@ -15,9 +15,14 @@ Feature: Dashboard And I click "Create Merge Request" link Then I see prefilled new Merge Request page - @current Scenario: I should see User joined Project event Given user with name "John Doe" joined project "Shop" When I visit dashboard page - Then I should see "John Doe joined Shop" event + Then I should see "John Doe joined project Shop" event + + Scenario: I should see User left Project event + Given user with name "John Doe" joined project "Shop" + And user with name "John Doe" left project "Shop" + When I visit dashboard page + Then I should see "John Doe left project Shop" event diff --git a/features/step_definitions/dashboard_steps.rb b/features/step_definitions/dashboard_steps.rb index 3771fb9c..3ddc68e9 100644 --- a/features/step_definitions/dashboard_steps.rb +++ b/features/step_definitions/dashboard_steps.rb @@ -120,6 +120,16 @@ Given /^user with name "(.*?)" joined project "(.*?)"$/ do |user_name, project_n ) end +Given /^user with name "(.*?)" left project "(.*?)"$/ do |user_name, project_name| + user = User.find_by_name user_name + project = Project.find_by_name project_name + Event.create( + project: project, + author_id: user.id, + action: Event::Left + ) +end + Then /^I should see "(.*?)" event$/ do |event_text| page.should have_content(event_text) end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 81459233..ee022e95 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -50,7 +50,7 @@ describe Event do it { @event.author.should == @user } end - describe "New team mamber" do + describe "Joined project team" do let(:project) {Factory.create :project} let(:new_user) {Factory.create :user} it "should create event" do @@ -60,4 +60,15 @@ describe Event do }.to change{Event.count}.by(1) end end + describe "Left project team" do + let(:project) {Factory.create :project} + let(:new_user) {Factory.create :user} + it "should create event" do + UsersProject.bulk_import(project, [new_user.id], UsersProject::DEVELOPER) + UsersProject.observers.enable :users_project_observer + expect{ + UsersProject.bulk_delete(project, [new_user.id]) + }.to change{Event.count}.by(1) + end + end end diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index 99130aa5..f38d9862 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -45,4 +45,23 @@ describe UsersProjectObserver do subject.after_update(users_project) end end + describe "#after_destroy" do + it "should called when UsersProject destroyed" do + subject.should_receive(:after_destroy) + UsersProject.observers.enable :users_project_observer do + UsersProject.bulk_delete( + users_project.project, + [users_project.user.id] + ) + end + end + it "should create new event" do + Event.should_receive(:create).with( + project_id: users_project.project.id, + action: Event::Left, + author_id: users_project.user.id + ) + subject.after_destroy(users_project) + end + end end From b565f33472d960e37ed41a8a0c09fbbc3ea65f1e Mon Sep 17 00:00:00 2001 From: randx Date: Mon, 10 Sep 2012 09:06:11 +0300 Subject: [PATCH 15/24] Auth for API --- lib/api/helpers.rb | 16 ++++++++++++++++ lib/api/issues.rb | 2 ++ lib/api/milestones.rb | 2 ++ lib/api/projects.rb | 7 +++++++ 4 files changed, 27 insertions(+) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index ce7b7b49..c0ba8747 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -21,5 +21,21 @@ module Gitlab def authenticate! error!({'message' => '401 Unauthorized'}, 401) unless current_user end + + def authorize! action, subject + unless abilities.allowed?(current_user, action, subject) + error!({'message' => '403 Forbidden'}, 403) + end + end + + private + + def abilities + @abilities ||= begin + abilities = Six.new + abilities << Ability + abilities + end + end end end diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 68cb7e05..4cfa7500 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -79,6 +79,8 @@ module Gitlab # PUT /projects/:id/issues/:issue_id put ":id/issues/:issue_id" do @issue = user_project.issues.find(params[:issue_id]) + authorize! :modify_issue, @issue + parameters = { title: (params[:title] || @issue.title), description: (params[:description] || @issue.description), diff --git a/lib/api/milestones.rb b/lib/api/milestones.rb index 29f5efa4..7c684667 100644 --- a/lib/api/milestones.rb +++ b/lib/api/milestones.rb @@ -61,6 +61,8 @@ module Gitlab # Example Request: # PUT /projects/:id/milestones/:milestone_id put ":id/milestones/:milestone_id" do + authorize! :admin_milestone, user_project + @milestone = user_project.milestones.find(params[:milestone_id]) parameters = { title: (params[:title] || @milestone.title), diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 7da83429..05b07e8d 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -74,6 +74,7 @@ module Gitlab # Example Request: # POST /projects/:id/users post ":id/users" do + authorize! :admin_project, user_project user_project.add_users_ids_to_team(params[:user_ids].values, params[:project_access]) nil end @@ -87,6 +88,7 @@ module Gitlab # Example Request: # PUT /projects/:id/add_users put ":id/users" do + authorize! :admin_project, user_project user_project.update_users_ids_to_role(params[:user_ids].values, params[:project_access]) nil end @@ -99,6 +101,7 @@ module Gitlab # Example Request: # DELETE /projects/:id/users delete ":id/users" do + authorize! :admin_project, user_project user_project.delete_users_ids_from_team(params[:user_ids].values) nil end @@ -186,6 +189,8 @@ module Gitlab # PUT /projects/:id/snippets/:snippet_id put ":id/snippets/:snippet_id" do @snippet = user_project.snippets.find(params[:snippet_id]) + authorize! :modify_snippet, @snippet + parameters = { title: (params[:title] || @snippet.title), file_name: (params[:file_name] || @snippet.file_name), @@ -209,6 +214,8 @@ module Gitlab # DELETE /projects/:id/snippets/:snippet_id delete ":id/snippets/:snippet_id" do @snippet = user_project.snippets.find(params[:snippet_id]) + authorize! :modify_snippet, @snippet + @snippet.destroy end From d6c384c20f3798fffd0481cd758700a27bebd44f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 10 Sep 2012 02:09:55 -0400 Subject: [PATCH 16/24] Reduce the amount of JavaScript written in views Seeing `:javascript` all over Views feels like a code smell. This goes a long way towards reducing the amount of JS in views, but there's still plenty to be done on that front. --- app/assets/javascripts/main.js.coffee | 3 +++ app/views/admin/projects/_form.html.haml | 3 +-- app/views/admin/projects/show.html.haml | 18 ++---------------- app/views/admin/team_members/_form.html.haml | 13 +------------ app/views/admin/users/show.html.haml | 18 ++---------------- app/views/commits/_head.html.haml | 7 +------ app/views/issues/_form.html.haml | 4 ++-- app/views/issues/edit.html.haml | 7 ------- app/views/issues/new.html.haml | 7 ------- app/views/merge_requests/_form.html.haml | 13 +++---------- app/views/milestones/edit.html.haml | 6 ------ app/views/projects/_refs.html.haml | 7 +------ app/views/protected_branches/index.html.haml | 5 +---- app/views/refs/_head.html.haml | 2 +- app/views/refs/_tree.html.haml | 3 --- app/views/refs/blame.html.haml | 5 ----- app/views/snippets/_form.html.haml | 10 +--------- app/views/team_members/_form.html.haml | 13 +++---------- 18 files changed, 22 insertions(+), 122 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index a01b3932..86b19162 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -24,6 +24,9 @@ $ -> # Click a .one_click_select field, select the contents $(".one_click_select").live 'click', -> $(this).select() + # Initialize chosen selects + $('select.chosen').chosen() + # Disable form buttons while a form is submitting $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> buttons = $('[type="submit"]', this) diff --git a/app/views/admin/projects/_form.html.haml b/app/views/admin/projects/_form.html.haml index 87d212e5..4848e739 100644 --- a/app/views/admin/projects/_form.html.haml +++ b/app/views/admin/projects/_form.html.haml @@ -32,7 +32,7 @@ - unless project.new_record? .clearfix = f.label :owner_id - .input= f.select :owner_id, User.all.map { |user| [user.name, user.id] } + .input= f.select :owner_id, User.all.map { |user| [user.name, user.id] }, {}, {class: 'chosen'} - if project.repo_exists? .clearfix @@ -69,7 +69,6 @@ :javascript $(function(){ - $('#project_owner_id').chosen(); new Projects(); }) diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 65d888f5..63987410 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -71,25 +71,11 @@ %th Project Access: %tr - %td= select_tag :user_ids, options_from_collection_for_select(@users , :id, :name), multiple: true - %td= select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select" + %td= select_tag :user_ids, options_from_collection_for_select(@users , :id, :name), multiple: true, data: {placeholder: 'Select users'}, class: 'chosen span5' + %td= select_tag :project_access, options_for_select(Project.access_options), {class: "project-access-select chosen span3"} %tr %td= submit_tag 'Add', class: "btn primary" %td Read more about project permissions %strong= link_to "here", help_permissions_path, class: "vlink" - -:css - form select { - width:150px; - } - - #user_ids { - width:300px; - } - -:javascript - $('select#user_ids').chosen(); - $('select#repo_access').chosen(); - $('select#project_access').chosen(); diff --git a/app/views/admin/team_members/_form.html.haml b/app/views/admin/team_members/_form.html.haml index 6a128de9..9cd94fdd 100644 --- a/app/views/admin/team_members/_form.html.haml +++ b/app/views/admin/team_members/_form.html.haml @@ -8,20 +8,9 @@ .clearfix %label Project Access: .input - = f.select :project_access, options_for_select(Project.access_options, @admin_team_member.project_access), {}, class: "project-access-select" + = f.select :project_access, options_for_select(Project.access_options, @admin_team_member.project_access), {}, class: "project-access-select chosen span3" %br .actions = f.submit 'Save', class: "btn primary" = link_to 'Cancel', :back, class: "btn" - -:css - form select { - width:300px; - } - -:javascript - $('select#team_member_user_id').chosen(); - $('select#team_member_project_id').chosen(); - $('select#team_member_repo_access').chosen(); - $('select#team_member_project_access').chosen(); diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index 4d2b9832..731916e9 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -68,8 +68,8 @@ %th Project Access: %tr - %td= select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name), multiple: true - %td= select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select" + %td= select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5' + %td= select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select chosen span3" %tr %td= submit_tag 'Add', class: "btn primary" @@ -97,17 +97,3 @@ %td= select_tag :tm_project_access, options_for_select(Project.access_options, tm.project_access), class: "medium project-access-select", disabled: :disabled %td= link_to 'Edit Access', edit_admin_team_member_path(tm), class: "btn small" %td= link_to 'Remove from team', admin_team_member_path(tm), confirm: 'Are you sure?', method: :delete, class: "btn small danger" - -:css - form select { - width:150px; - } - - #project_ids { - width:300px; - } - -:javascript - $('select#project_ids').chosen(); - $('select#repo_access').chosen(); - $('select#project_access').chosen(); diff --git a/app/views/commits/_head.html.haml b/app/views/commits/_head.html.haml index a211329f..5a09d82a 100644 --- a/app/views/commits/_head.html.haml +++ b/app/views/commits/_head.html.haml @@ -1,7 +1,7 @@ %ul.nav.nav-tabs %li = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do - = select_tag "ref", grouped_options_refs, onchange: "$(this.form).trigger('submit');", class: "project-refs-select" + = select_tag "ref", grouped_options_refs, onchange: "$(this.form).trigger('submit');", class: "project-refs-select chosen" = hidden_field_tag :destination, "commits" %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} @@ -26,8 +26,3 @@ %span.rss-icon = link_to project_commits_path(@project, :atom, { private_token: current_user.private_token, ref: @ref }), title: "Feed" do = image_tag "rss_ui.png", title: "feed" - -:javascript - $(function(){ - $('.project-refs-select').chosen(); - }); diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml index 23de7e8e..813ecab2 100644 --- a/app/views/issues/_form.html.haml +++ b/app/views/issues/_form.html.haml @@ -18,12 +18,12 @@ = f.label :assignee_id do %i.icon-user Assign to - .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }) + .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'}) .issue_milestone = f.label :milestone_id do %i.icon-time Milestone - .input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }) + .input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) .issue_description .clearfix diff --git a/app/views/issues/edit.html.haml b/app/views/issues/edit.html.haml index 3c9877f8..b1bc3ba0 100644 --- a/app/views/issues/edit.html.haml +++ b/app/views/issues/edit.html.haml @@ -1,8 +1 @@ = render "form" - -:javascript - $(function(){ - $('select#issue_assignee_id').chosen(); - $('select#issue_milestone_id').chosen(); - }); - diff --git a/app/views/issues/new.html.haml b/app/views/issues/new.html.haml index 3c9877f8..b1bc3ba0 100644 --- a/app/views/issues/new.html.haml +++ b/app/views/issues/new.html.haml @@ -1,8 +1 @@ = render "form" - -:javascript - $(function(){ - $('select#issue_assignee_id').chosen(); - $('select#issue_milestone_id').chosen(); - }); - diff --git a/app/views/merge_requests/_form.html.haml b/app/views/merge_requests/_form.html.haml index d5271ed0..96692c0f 100644 --- a/app/views/merge_requests/_form.html.haml +++ b/app/views/merge_requests/_form.html.haml @@ -16,7 +16,7 @@ .padded = f.label :source_branch, "From", class: "control-label" .controls - = f.select(:source_branch, @project.heads.map(&:name), { include_blank: "Select branch" }, style: "width:250px") + = f.select(:source_branch, @project.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span3'}) .mr_source_commit .span2 @@ -28,7 +28,7 @@ .padded = f.label :target_branch, "To", class: "control-label" .controls - = f.select(:target_branch, @project.heads.map(&:name), { include_blank: "Select branch" }, style: "width:250px") + = f.select(:target_branch, @project.heads.map(&:name), { include_blank: "Select branch" }, {class: 'chosen span3'}) .mr_target_commit %h4.cdark 2. Fill info @@ -43,7 +43,7 @@ = f.label :assignee_id do %i.icon-user Assign to - .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, style: "width:250px") + .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) .control-group @@ -56,18 +56,12 @@ = link_to project_merge_request_path(@project, @merge_request), class: "btn cancel-btn" do Cancel - - :javascript $(function(){ disableButtonIfEmptyField("#merge_request_title", ".save-btn"); - $('select#merge_request_assignee_id').chosen(); - $('select#merge_request_source_branch').chosen(); - $('select#merge_request_target_branch').chosen(); var source_branch = $("#merge_request_source_branch"); var target_branch = $("#merge_request_target_branch"); - $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: source_branch.val() }); $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: target_branch.val() }); @@ -79,4 +73,3 @@ $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() }); }); }); - diff --git a/app/views/milestones/edit.html.haml b/app/views/milestones/edit.html.haml index af975a84..b1bc3ba0 100644 --- a/app/views/milestones/edit.html.haml +++ b/app/views/milestones/edit.html.haml @@ -1,7 +1 @@ = render "form" - -:javascript - $(function(){ - $('select#issue_assignee_id').chosen(); - }); - diff --git a/app/views/projects/_refs.html.haml b/app/views/projects/_refs.html.haml index 804b8523..dc1f3a28 100644 --- a/app/views/projects/_refs.html.haml +++ b/app/views/projects/_refs.html.haml @@ -1,8 +1,3 @@ = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do - = select_tag "ref", grouped_options_refs, onchange: "this.form.submit();", class: "project-refs-select" + = select_tag "ref", grouped_options_refs, onchange: "this.form.submit();", class: "project-refs-select chosen" = hidden_field_tag :destination, destination - -:javascript - $(function(){ - $('.project-refs-select').chosen(); - }) diff --git a/app/views/protected_branches/index.html.haml b/app/views/protected_branches/index.html.haml index 33bb448a..43884de1 100644 --- a/app/views/protected_branches/index.html.haml +++ b/app/views/protected_branches/index.html.haml @@ -19,7 +19,7 @@ .entry.clearfix = f.label :name, "Branch" .span3 - = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , { include_blank: "-- Select branch" }, { class: "span3" }) + = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "chosen span3"})   = f.submit 'Protect', class: "primary btn" @@ -46,6 +46,3 @@ %td - if can? current_user, :admin_project, @project = link_to 'Unprotect', [@project, branch], confirm: 'Are you sure?', method: :delete, class: "danger btn small" - -:javascript - $('select#protected_branch_name').chosen(); diff --git a/app/views/refs/_head.html.haml b/app/views/refs/_head.html.haml index d51602de..94603f0a 100644 --- a/app/views/refs/_head.html.haml +++ b/app/views/refs/_head.html.haml @@ -1,7 +1,7 @@ %ul.nav.nav-tabs %li = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form", remote: true do - = select_tag "ref", grouped_options_refs, onchange: "$(this.form).trigger('submit');", class: "project-refs-select" + = select_tag "ref", grouped_options_refs, onchange: "$(this.form).trigger('submit');", class: "project-refs-select chosen" = hidden_field_tag :destination, "tree" = hidden_field_tag :path, params[:path] %li{class: "#{'active' if (controller.controller_name == "refs") }"} diff --git a/app/views/refs/_tree.html.haml b/app/views/refs/_tree.html.haml index 297a3b5f..83e73280 100644 --- a/app/views/refs/_tree.html.haml +++ b/app/views/refs/_tree.html.haml @@ -47,10 +47,7 @@ :javascript $(function(){ - $('.project-refs-select').chosen(); - history.pushState({ path: this.path }, '', "#{@history_path}"); - }); // Load last commit log for each file in tree diff --git a/app/views/refs/blame.html.haml b/app/views/refs/blame.html.haml index 34478d4b..eb66f597 100644 --- a/app/views/refs/blame.html.haml +++ b/app/views/refs/blame.html.haml @@ -38,8 +38,3 @@ = preserve do %pre = Gitlab::Encode.utf8 lines.join("\n") - -:javascript - $(function(){ - $('.project-refs-select').chosen(); - }); diff --git a/app/views/snippets/_form.html.haml b/app/views/snippets/_form.html.haml index b8d8c098..e61e61a7 100644 --- a/app/views/snippets/_form.html.haml +++ b/app/views/snippets/_form.html.haml @@ -16,7 +16,7 @@ .input= f.text_field :file_name, placeholder: "example.rb" .clearfix = f.label "Lifetime" - .input= f.select :expires_at, lifetime_select_options, {}, style: "width:200px;" + .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'} .clearfix = f.label :content, "Code" .input= f.text_area :content, class: "span8" @@ -26,11 +26,3 @@ = link_to "Cancel", project_snippets_path(@project), class: " btn" - unless @snippet.new_record? .right= link_to 'Destroy', [@project, @snippet], confirm: 'Are you sure?', method: :delete, class: "btn right danger delete-snippet", id: "destroy_snippet_#{@snippet.id}" - - - -:javascript - $(function(){ - $('select#snippet_expires_at').chosen(); - }); - diff --git a/app/views/team_members/_form.html.haml b/app/views/team_members/_form.html.haml index 192f2735..3736bfea 100644 --- a/app/views/team_members/_form.html.haml +++ b/app/views/team_members/_form.html.haml @@ -10,21 +10,14 @@ %h6 1. Choose people you want in the team .clearfix - = f.label :user_ids, "Peolpe" - .input= select_tag(:user_ids, options_from_collection_for_select(User.not_in_project(@project).all, :id, :name), { class: "xxlarge", multiple: true }) - + = f.label :user_ids, "People" + .input= select_tag(:user_ids, options_from_collection_for_select(User.not_in_project(@project).all, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) %h6 2. Set access level for them .clearfix = f.label :project_access, "Project Access" - .input= select_tag :project_access, options_for_select(Project.access_options, @team_member.project_access), class: "project-access-select" - + .input= select_tag :project_access, options_for_select(Project.access_options, @team_member.project_access), class: "project-access-select chosen" .actions = f.submit 'Save', class: "btn save-btn" = link_to "Cancel", team_project_path(@project), class: "btn cancel-btn" - - -:javascript - $('select#user_ids').chosen(); - $('select#project_access').chosen(); From e7f483f9f4dffbd675b7fc41b5c2cfd8c7309e0d Mon Sep 17 00:00:00 2001 From: Cyril Date: Mon, 10 Sep 2012 10:50:07 +0200 Subject: [PATCH 17/24] fix typo --- lib/gitlab/backend/gitolite_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/backend/gitolite_config.rb b/lib/gitlab/backend/gitolite_config.rb index 60eef8e8..0d636d2d 100644 --- a/lib/gitlab/backend/gitolite_config.rb +++ b/lib/gitlab/backend/gitolite_config.rb @@ -148,7 +148,7 @@ module Gitlab # Enable access to all repos for gitolite admin. # We use it for accept merge request feature def admin_all_repo - owner_name = Gitlab.settings.gitolite_admin_key + owner_name = Gitlab.config.gitolite_admin_key # @ALL repos premission for gitolite owner repo_name = "@all" From 52d29f5d5996fd5e5bcd203b5e352afee00f74aa Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 10 Sep 2012 09:13:45 +0300 Subject: [PATCH 18/24] Project team page improved --- app/assets/stylesheets/common.scss | 5 +++-- app/helpers/projects_helper.rb | 4 ++++ app/views/team_members/_show.html.haml | 20 +++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 012aad03..6f69ba5a 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -181,11 +181,12 @@ span.update-author { } &.joined { - background-color: #1cb9ff; + background-color: #1ca9dd; } &.left { - background-color: #ff5057; + background-color: #888; + float:none; } } diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 34dbb06c..c7dc54ee 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -2,5 +2,9 @@ module ProjectsHelper def grouper_project_members(project) @project.users_projects.sort_by(&:project_access).reverse.group_by(&:project_access) end + + def remove_from_team_message(project, member) + "You are going to remove #{member.user_name} from #{project.name}. Are you sure?" + end end diff --git a/app/views/team_members/_show.html.haml b/app/views/team_members/_show.html.haml index d9a72494..f68f8eb4 100644 --- a/app/views/team_members/_show.html.haml +++ b/app/views/team_members/_show.html.haml @@ -1,20 +1,26 @@ - user = member.user - allow_admin = can? current_user, :admin_project, @project %tr{id: dom_id(member), class: "team_member_row user_#{user.id}"} - %td + %td.span6 = link_to project_team_member_path(@project, member), title: user.name, class: "dark" do = image_tag gravatar_icon(user.email, 40), class: "avatar s32" = link_to project_team_member_path(@project, member), title: user.name, class: "dark" do %strong= truncate(user.name, lenght: 40) - %br - %div.cgray= user.email + %br + %small.cgray= user.email - %td + %td.span5 .right + - if current_user == user + %span.btn.disabled This is you! - if @project.owner == user - %span.btn.disabled.success Project Owner - - if user.blocked + %span.btn.disabled.success Owner + - elsif user.blocked %span.btn.disabled.blocked Blocked + - elsif allow_admin + = link_to project_team_member_path(project_id: @project, id: member.id), confirm: remove_from_team_message(@project, member), method: :delete, class: "very_small btn danger" do + %i.icon-minus.icon-white + - if allow_admin = form_for(member, as: :team_member, url: project_team_member_path(@project, member)) do |f| - = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select" + = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2" From a1ba470e4e0ec5ebbcd47755122878df6d19ad0b Mon Sep 17 00:00:00 2001 From: randx Date: Mon, 10 Sep 2012 09:26:35 +0300 Subject: [PATCH 19/24] Added guard --- Gemfile | 3 +++ Gemfile.lock | 11 +++++++++++ Guardfile | 30 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 Guardfile diff --git a/Gemfile b/Gemfile index c8d3821f..d104cbb6 100644 --- a/Gemfile +++ b/Gemfile @@ -109,6 +109,9 @@ group :development, :test do gem "database_cleaner" gem "launchy" gem 'factory_girl_rails' + + gem 'guard-rspec' + gem 'guard-cucumber' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 83fd94db..00ece601 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -186,6 +186,14 @@ GEM multi_xml rack rack-mount + guard (1.3.2) + listen (>= 0.4.2) + thor (>= 0.14.6) + guard-cucumber (1.2.0) + cucumber (>= 1.2.0) + guard (>= 1.1.0) + guard-rspec (1.2.1) + guard (>= 1.1) haml (3.1.6) haml-rails (0.3.4) actionpack (~> 3.0) @@ -219,6 +227,7 @@ GEM libv8 (3.3.10.4) libwebsocket (0.1.3) addressable + listen (0.5.0) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -403,6 +412,8 @@ DEPENDENCIES grack! grape (~> 0.2.1) grit! + guard-cucumber + guard-rspec haml-rails headless httparty diff --git a/Guardfile b/Guardfile new file mode 100644 index 00000000..ed38f548 --- /dev/null +++ b/Guardfile @@ -0,0 +1,30 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +guard 'rspec', :version => 2 do + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { "spec" } + + # Rails example + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch('config/routes.rb') { "spec/routing" } + watch('app/controllers/application_controller.rb') { "spec/controllers" } + + # Capybara request specs + watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } +end + + +guard 'cucumber' do + watch(%r{^features/.+\.feature$}) + watch(%r{^features/support/.+$}) { 'features' } + watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' } +end From 8795f67f47880f4ac4c88b627c22f1861cda2bc0 Mon Sep 17 00:00:00 2001 From: randx Date: Mon, 10 Sep 2012 09:41:51 +0300 Subject: [PATCH 20/24] REmoved autotest, added notify libs for growl --- Gemfile | 16 ++++++++++++++-- Gemfile.lock | 14 +++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index d104cbb6..660bef40 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,13 @@ source "http://rubygems.org" +def darwin_only(require_as) + RUBY_PLATFORM.include?('darwin') && require_as +end + +def linux_only(require_as) + RUBY_PLATFORM.include?('linux') && require_as +end + gem "rails", "3.2.8" # Supported DBs @@ -102,16 +110,20 @@ group :development, :test do gem "capybara" gem "capybara-webkit" gem "headless" - gem "autotest" - gem "autotest-rails" gem "pry" gem "awesome_print" gem "database_cleaner" gem "launchy" gem 'factory_girl_rails' + # Guard gem 'guard-rspec' gem 'guard-cucumber' + + # Notification + gem 'rb-fsevent', :require => darwin_only('growl') + gem 'growl', :require => darwin_only('growl') + gem 'rb-inotify', :require => linux_only('rb-fsevent') end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 00ece601..94b16281 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,7 +68,6 @@ GIT GEM remote: http://rubygems.org/ specs: - ZenTest (4.8.1) actionmailer (3.2.8) actionpack (= 3.2.8) mail (~> 2.4.4) @@ -100,10 +99,6 @@ GEM rails (~> 3.0) addressable (2.2.8) arel (3.0.2) - autotest (4.4.6) - ZenTest (>= 4.4.1) - autotest-rails (4.1.2) - ZenTest (~> 4.5) awesome_print (1.0.2) bcrypt-ruby (3.0.1) blankslate (2.1.2.4) @@ -186,6 +181,7 @@ GEM multi_xml rack rack-mount + growl (1.0.3) guard (1.3.2) listen (>= 0.4.2) thor (>= 0.14.6) @@ -283,6 +279,9 @@ GEM raindrops (0.9.0) rake (0.9.2.2) raphael-rails (1.5.2) + rb-fsevent (0.9.1) + rb-inotify (0.8.8) + ffi (>= 0.5.0) rdoc (3.12) json (~> 1.4) redcarpet (2.1.1) @@ -386,8 +385,6 @@ PLATFORMS DEPENDENCIES acts-as-taggable-on (= 2.3.1) annotate! - autotest - autotest-rails awesome_print bootstrap-sass (= 2.0.4) capybara @@ -412,6 +409,7 @@ DEPENDENCIES grack! grape (~> 0.2.1) grit! + growl guard-cucumber guard-rspec haml-rails @@ -431,6 +429,8 @@ DEPENDENCIES rack-mini-profiler rails (= 3.2.8) raphael-rails (= 1.5.2) + rb-fsevent + rb-inotify redcarpet (~> 2.1.1) resque (~> 1.20.0) resque_mailer From a839cb427cc158330297fd89fbf40321d41349a4 Mon Sep 17 00:00:00 2001 From: randx Date: Mon, 10 Sep 2012 09:43:30 +0300 Subject: [PATCH 21/24] Fix require calls in gemfile --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 660bef40..6205594a 100644 --- a/Gemfile +++ b/Gemfile @@ -121,9 +121,9 @@ group :development, :test do gem 'guard-cucumber' # Notification - gem 'rb-fsevent', :require => darwin_only('growl') + gem 'rb-fsevent', :require => darwin_only('rb-fsevent') gem 'growl', :require => darwin_only('growl') - gem 'rb-inotify', :require => linux_only('rb-fsevent') + gem 'rb-inotify', :require => linux_only('rb-inotify') end group :test do From 915dac0055cd801c080ebcd37749f4fc6d2d12c4 Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Mon, 10 Sep 2012 10:41:46 +0300 Subject: [PATCH 22/24] Error throwing moved to api_helper --- lib/api/helpers.rb | 27 ++++++++++++++++++++++++--- lib/api/issues.rb | 6 +++--- lib/api/milestones.rb | 4 ++-- lib/api/projects.rb | 10 +++++----- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index c0ba8747..3a385f15 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -8,7 +8,7 @@ module Gitlab 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) + not_found! end @project @@ -19,15 +19,36 @@ module Gitlab end def authenticate! - error!({'message' => '401 Unauthorized'}, 401) unless current_user + unauthorized! unless current_user end def authorize! action, subject unless abilities.allowed?(current_user, action, subject) - error!({'message' => '403 Forbidden'}, 403) + forbidden! end end + # error helpers + + def forbidden! + error!({'message' => '403 Forbidden'}, 403) + end + + def not_found!(resource = nil) + message = ["404"] + message << resource if resource + message << "Not Found" + error!({'message' => message.join(' ')}, 404) + end + + def unauthorized! + error!({'message' => '401 Unauthorized'}, 401) + end + + def not_allowed! + error!({'message' => 'method not allowed'}, 405) + end + private def abilities diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 4cfa7500..659f065e 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -60,7 +60,7 @@ module Gitlab if @issue.save present @issue, with: Entities::Issue else - error!({'message' => '404 Not found'}, 404) + not_found! end end @@ -93,7 +93,7 @@ module Gitlab if @issue.update_attributes(parameters) present @issue, with: Entities::Issue else - error!({'message' => '404 Not found'}, 404) + not_found! end end @@ -105,7 +105,7 @@ module Gitlab # Example Request: # DELETE /projects/:id/issues/:issue_id delete ":id/issues/:issue_id" do - error!({'message' => 'method not allowed'}, 405) + not_allowed! end end end diff --git a/lib/api/milestones.rb b/lib/api/milestones.rb index 7c684667..4b0424ba 100644 --- a/lib/api/milestones.rb +++ b/lib/api/milestones.rb @@ -45,7 +45,7 @@ module Gitlab if @milestone.save present @milestone, with: Entities::Milestone else - error!({'message' => '404 Not found'}, 404) + not_found! end end @@ -74,7 +74,7 @@ module Gitlab if @milestone.update_attributes(parameters) present @milestone, with: Entities::Milestone else - error!({'message' => '404 Not found'}, 404) + not_found! end end end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 05b07e8d..9d33323e 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -50,7 +50,7 @@ module Gitlab if @project.saved? present @project, with: Entities::Project else - error!({'message' => '404 Not found'}, 404) + not_found! end end @@ -172,7 +172,7 @@ module Gitlab if @snippet.save present @snippet, with: Entities::ProjectSnippet else - error!({'message' => '404 Not found'}, 404) + not_found! end end @@ -201,7 +201,7 @@ module Gitlab if @snippet.update_attributes(parameters) present @snippet, with: Entities::ProjectSnippet else - error!({'message' => '404 Not found'}, 404) + not_found! end end @@ -244,10 +244,10 @@ module Gitlab ref = params[:sha] commit = user_project.commit ref - error!('404 Commit Not Found', 404) unless commit + not_found! "Commit" unless commit tree = Tree.new commit.tree, user_project, ref, params[:filepath] - error!('404 File Not Found', 404) unless tree.try(:tree) + not_found! "File" unless tree.try(:tree) if tree.text? encoding = Gitlab::Encode.detect_encoding(tree.data) From a065557208d6076ec869144346e06c7de714389c Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Mon, 10 Sep 2012 13:49:00 +0300 Subject: [PATCH 23/24] Common errors method added --- lib/api/helpers.rb | 12 ++++++++---- spec/requests/api/projects_spec.rb | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 3a385f15..054eb2d3 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -31,22 +31,26 @@ module Gitlab # error helpers def forbidden! - error!({'message' => '403 Forbidden'}, 403) + render_api_error!('403 Forbidden', 403) end def not_found!(resource = nil) message = ["404"] message << resource if resource message << "Not Found" - error!({'message' => message.join(' ')}, 404) + render_api_error!(message.join(' '), 404) end def unauthorized! - error!({'message' => '401 Unauthorized'}, 401) + render_api_error!('401 Unauthorized', 401) end def not_allowed! - error!({'message' => 'method not allowed'}, 405) + render_api_error!('Method Not Allowed', 405) + end + + def render_api_error!(message, status) + error!({'message' => message}, status) end private diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 439aecce..9388403f 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -85,7 +85,7 @@ describe Gitlab::API do it "should return a 404 error if not found" do get api("/projects/42", user) response.status.should == 404 - json_response['message'].should == '404 Not found' + json_response['message'].should == '404 Not Found' end end From a3d22297dcd7b547412cf0284a27ef11f90c20ad Mon Sep 17 00:00:00 2001 From: Minoru NAKATA Date: Mon, 10 Sep 2012 20:35:09 +0900 Subject: [PATCH 24/24] fix haml template error for ldap login. --- app/views/devise/sessions/_new_ldap.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/sessions/_new_ldap.html.haml b/app/views/devise/sessions/_new_ldap.html.haml index 85010df7..4233aa61 100644 --- a/app/views/devise/sessions/_new_ldap.html.haml +++ b/app/views/devise/sessions/_new_ldap.html.haml @@ -15,7 +15,7 @@ $(function() { $('#new_user').toggle(); }); - = form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => "login-box" }) do |f| += form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => "login-box" }) do |f| = f.text_field :email, :class => "text top", :placeholder => "Email" = f.password_field :password, :class => "text bottom", :placeholder => "Password" - if devise_mapping.rememberable?