summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG8
-rw-r--r--Gemfile.lock4
-rw-r--r--app/assets/javascripts/diff.js.coffee2
-rw-r--r--app/assets/javascripts/merge_request.js.coffee9
-rw-r--r--app/assets/javascripts/project_users_select.js.coffee7
-rw-r--r--app/assets/stylesheets/pages/diff.scss10
-rw-r--r--app/assets/stylesheets/pages/merge_requests.scss21
-rw-r--r--app/assets/stylesheets/themes/ui_blue.scss2
-rw-r--r--app/helpers/issues_helper.rb13
-rw-r--r--app/helpers/projects_helper.rb2
-rw-r--r--app/mailers/emails/projects.rb10
-rw-r--r--app/models/concerns/taskable.rb2
-rw-r--r--app/models/merge_request.rb9
-rw-r--r--app/models/note.rb1
-rw-r--r--app/models/user.rb1
-rw-r--r--app/services/issues/bulk_update_service.rb6
-rw-r--r--app/services/issues/update_service.rb3
-rw-r--r--app/services/merge_requests/refresh_service.rb12
-rw-r--r--app/services/merge_requests/update_service.rb3
-rw-r--r--app/views/admin/broadcast_messages/index.html.haml6
-rw-r--r--app/views/projects/commits/_commit.html.haml2
-rw-r--r--app/views/projects/diffs/_diffs.html.haml12
-rw-r--r--app/views/projects/diffs/_file.html.haml13
-rw-r--r--app/views/projects/issues/_issue.html.haml5
-rw-r--r--app/views/projects/labels/_form.html.haml4
-rw-r--r--app/views/projects/merge_requests/_merge_request.html.haml5
-rw-r--r--app/views/projects/merge_requests/_show.html.haml2
-rw-r--r--app/views/projects/milestones/show.html.haml11
-rw-r--r--app/views/projects/notes/_discussion.html.haml3
-rw-r--r--app/views/projects/notes/_note.html.haml6
-rw-r--r--app/views/projects/notes/discussions/_diff.html.haml14
-rw-r--r--config/gitlab.yml.example3
-rw-r--r--config/initializers/1_settings.rb1
-rw-r--r--db/migrate/20150324155957_set_incorrect_assignee_id_to_null.rb6
-rw-r--r--db/schema.rb2
-rw-r--r--lib/api/branches.rb3
-rw-r--r--lib/gitlab/backend/grack_auth.rb45
-rw-r--r--lib/gitlab/backend/rack_attack_helpers.rb31
-rw-r--r--lib/gitlab/markdown.rb5
-rw-r--r--lib/gitlab/project_search_results.rb2
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb11
-rw-r--r--spec/lib/gitlab/backend/grack_auth_spec.rb52
-rw-r--r--spec/lib/gitlab/backend/rack_attack_helpers_spec.rb35
43 files changed, 282 insertions, 122 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 4dfa831b4ec..7b24fb00c6d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@ v 7.10.0 (unreleased)
- Update poltergeist to version 1.6.0 to support PhantomJS 2.0 (Zeger-Jan van de Weg)
- Fix cross references when usernames, milestones, or project names contain underscores (Stan Hu)
- Disable reference creation for comments surrounded by code/preformatted blocks (Stan Hu)
+ - Reduce Rack Attack false positives causing 403 errors during HTTP authentication (Stan Hu)
- enable line wrapping per default and remove the checkbox to toggle it (Hannes Rosenögger)
- extend the commit calendar to show the actual commits made on a date (Hannes Rosenögger)
- Fix a link in the patch update guide
@@ -17,6 +18,7 @@ v 7.10.0 (unreleased)
- Add changelog, license and contribution guide links to project sidebar.
- Improve diff UI
- Fix alignment of navbar toggle button (Cody Mize)
+ - Fix checkbox rendering for nested task lists
- Identical look of selectboxes in UI
- Move "Import existing repository by URL" option to button.
- Improve error message when save profile has error.
@@ -31,6 +33,9 @@ v 7.10.0 (unreleased)
- Replace commits calendar with faster contribution calendar that includes issues and merge requests
- Add inifinite scroll to user page activity
- Don't show commit comment button when user is not signed in.
+ - Don't include system notes in issue/MR comment count.
+ - Don't mark merge request as updated when merge status relative to target branch changes.
+ - Link note avatar to user.
- Make Git-over-SSH errors more descriptive.
v 7.9.0
@@ -153,7 +158,6 @@ v 7.8.0
- Add API endpoint to fetch all changes on a MergeRequest (Jeroen van Baarsen)
- View note image attachments in new tab when clicked instead of downloading them
- Improve sorting logic in UI and API. Explicitly define what sorting method is used by default
- - Allow more variations for commit messages closing issues (Julien Bianchi and Hannes Rosenögger)
- Fix overflow at sidebar when have several items
- Add notes for label changes in issue and merge requests
- Show tags in commit view (Hannes Rosenögger)
@@ -175,7 +179,7 @@ v 7.8.0
- Add a commit calendar to the user profile (Hannes Rosenögger)
- Submit comment on command-enter
- Notify all members of a group when that group is mentioned in a comment, for example: `@gitlab-org` or `@sales`.
- - Extend issue clossing pattern to include "Resolve", "Resolves", "Resolved", "Resolving" and "Close"
+ - Extend issue clossing pattern to include "Resolve", "Resolves", "Resolved", "Resolving" and "Close" (Julien Bianchi and Hannes Rosenögger)
- Fix long broadcast message cut-off on left sidebar (Visay Keo)
- Add Project Avatars (Steven Thonus and Hannes Rosenögger)
- Password reset token validity increased from 2 hours to 2 days since it is also send on account creation.
diff --git a/Gemfile.lock b/Gemfile.lock
index 4f1cab43dd5..7da4d3c3583 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -188,7 +188,7 @@ GEM
dotenv (>= 0.7)
thor (>= 0.13.6)
formatador (0.2.4)
- gemnasium-gitlab-service (0.2.5)
+ gemnasium-gitlab-service (0.2.4)
rugged (~> 0.21)
gemojione (2.0.0)
json
@@ -516,7 +516,7 @@ GEM
rubyntlm (0.5.0)
rubypants (0.2.0)
rugged (0.21.4)
- rugments (1.0.0.beta5)
+ rugments (1.0.0.beta6)
safe_yaml (0.9.7)
sanitize (2.1.0)
nokogiri (>= 1.4.4)
diff --git a/app/assets/javascripts/diff.js.coffee b/app/assets/javascripts/diff.js.coffee
index 05f5af42571..069f91c30e1 100644
--- a/app/assets/javascripts/diff.js.coffee
+++ b/app/assets/javascripts/diff.js.coffee
@@ -37,8 +37,6 @@ class @Diff
)
)
- $('.diff-header').stick_in_parent(recalc_every: 1, offset_top: $('.navbar').height())
-
lineNumbers: (line) ->
return ([0, 0]) unless line.children().length
lines = line.children().slice(0, 2)
diff --git a/app/assets/javascripts/merge_request.js.coffee b/app/assets/javascripts/merge_request.js.coffee
index 09c202e42a5..6127d2bb480 100644
--- a/app/assets/javascripts/merge_request.js.coffee
+++ b/app/assets/javascripts/merge_request.js.coffee
@@ -113,8 +113,14 @@ class @MergeRequest
allowed_states = ["failed", "canceled", "running", "pending", "success"]
if state in allowed_states
$('.ci_widget.ci-' + state).show()
+ switch state
+ when "failed", "canceled"
+ @setMergeButtonClass('btn-danger')
+ when "running", "pending"
+ @setMergeButtonClass('btn-warning')
else
$('.ci_widget.ci-error').show()
+ @setMergeButtonClass('btn-danger')
showCiCoverage: (coverage) ->
cov_html = $('<span>')
@@ -144,6 +150,9 @@ class @MergeRequest
this.$('.merge-in-progress').hide()
this.$('.automerge_widget.already_cannot_be_merged').show()
+ setMergeButtonClass: (css_class) ->
+ $('.accept_merge_request').removeClass("btn-create").addClass(css_class)
+
mergeInProgress: ->
$.ajax
type: 'GET'
diff --git a/app/assets/javascripts/project_users_select.js.coffee b/app/assets/javascripts/project_users_select.js.coffee
index e22c7c11f1c..80ab1a61ab9 100644
--- a/app/assets/javascripts/project_users_select.js.coffee
+++ b/app/assets/javascripts/project_users_select.js.coffee
@@ -25,7 +25,7 @@ class @ProjectUsersSelect
initSelection: (element, callback) ->
id = $(element).val()
- if id isnt ""
+ if id != "" && id != "-1"
Api.user(id, callback)
@@ -44,10 +44,7 @@ class @ProjectUsersSelect
else
avatar = gon.default_avatar_url
- if user.id == ''
- avatarMarkup = ''
- else
- avatarMarkup = "<div class='user-image'><img class='avatar s24' src='#{avatar}'></div>"
+ avatarMarkup = "<div class='user-image'><img class='avatar s24' src='#{avatar}'></div>"
"<div class='user-result'>
#{avatarMarkup}
diff --git a/app/assets/stylesheets/pages/diff.scss b/app/assets/stylesheets/pages/diff.scss
index 7b7bb88bc20..af6ea58382f 100644
--- a/app/assets/stylesheets/pages/diff.scss
+++ b/app/assets/stylesheets/pages/diff.scss
@@ -15,6 +15,11 @@
word-break: break-all;
margin-right: 200px;
display: block;
+
+ .file-mode {
+ margin-left: 10px;
+ color: #777;
+ }
}
.diff-btn-group {
@@ -34,11 +39,6 @@
font-family: $monospace_font;
font-size: smaller;
}
-
- .file-mode {
- font-family: $monospace_font;
- margin-left: 10px;
- }
}
.diff-content {
overflow: auto;
diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss
index d8fe339b7b3..8abd4207beb 100644
--- a/app/assets/stylesheets/pages/merge_requests.scss
+++ b/app/assets/stylesheets/pages/merge_requests.scss
@@ -137,30 +137,15 @@
background-color: #F1FAF1;
}
- &.ci-pending {
- color: #548;
- border-color: #548;
- background-color: #F4F1FA;
- }
-
+ &.ci-pending,
&.ci-running {
color: $gl-warning;
border-color: $gl-warning;
background-color: #FAF5F1;
}
- &.ci-failed {
- color: $gl-danger;
- border-color: $gl-danger;
- background-color: #FAF1F1;
- }
-
- &.ci-canceled {
- color: $gl-warning;
- border-color: $gl-danger;
- background-color: #FAF5F1;
- }
-
+ &.ci-failed,
+ &.ci-canceled,
&.ci-error {
color: $gl-danger;
border-color: $gl-danger;
diff --git a/app/assets/stylesheets/themes/ui_blue.scss b/app/assets/stylesheets/themes/ui_blue.scss
index cb7980b5a07..e223058be8b 100644
--- a/app/assets/stylesheets/themes/ui_blue.scss
+++ b/app/assets/stylesheets/themes/ui_blue.scss
@@ -1,5 +1,5 @@
/**
- * Modern GitLab UI theme
+ * Blue GitLab UI theme
*/
.ui_blue {
@include dark-theme(#BECDE9, #2980b9, #1970a9, #096099);
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 15c5dcb6a25..a4bd4d30215 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -58,22 +58,11 @@ module IssuesHelper
end
def bulk_update_milestone_options
- options_for_select(['None (backlog)']) +
+ options_for_select([['None (backlog)', -1]]) +
options_from_collection_for_select(project_active_milestones, 'id',
'title', params[:milestone_id])
end
- def bulk_update_assignee_options(project = @project)
- options_for_select(['None (unassigned)']) +
- options_from_collection_for_select(project.team.members, 'id',
- 'name', params[:assignee_id])
- end
-
- def assignee_options(object, project = @project)
- options_from_collection_for_select(project.team.members.sort_by(&:name),
- 'id', 'name', object.assignee_id)
- end
-
def milestone_options(object)
options_from_collection_for_select(object.project.milestones.active,
'id', 'title', object.milestone_id)
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 77ad7a40fab..7bf51b5b8e8 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -146,7 +146,7 @@ module ProjectsHelper
nav_tabs << feature if project.send :"#{feature}_enabled"
end
- if project.issues_enabled
+ if project.issues_enabled || project.merge_requests_enabled
nav_tabs << [:milestones, :labels]
end
diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb
index 48458baa674..3cd812825e2 100644
--- a/app/mailers/emails/projects.rb
+++ b/app/mailers/emails/projects.rb
@@ -16,13 +16,17 @@ module Emails
subject: subject("Project was moved"))
end
- def repository_push_email(project_id, recipient, author_id:,
- ref:,
- action:,
+ def repository_push_email(project_id, recipient, author_id: nil,
+ ref: nil,
+ action: nil,
compare: nil,
reverse_compare: false,
send_from_committer_email: false,
disable_diffs: false)
+ unless author_id && ref && action
+ raise ArgumentError, "missing keywords: author_id, ref, action"
+ end
+
@project = Project.find(project_id)
@author = User.find(author_id)
@reverse_compare = reverse_compare
diff --git a/app/models/concerns/taskable.rb b/app/models/concerns/taskable.rb
index 410e8dc820b..bbb3b301a9f 100644
--- a/app/models/concerns/taskable.rb
+++ b/app/models/concerns/taskable.rb
@@ -5,7 +5,7 @@
# Used by MergeRequest and Issue
module Taskable
TASK_PATTERN_MD = /^(?<bullet> *[*-] *)\[(?<checked>[ xX])\]/.freeze
- TASK_PATTERN_HTML = /^<li>\[(?<checked>[ xX])\]/.freeze
+ TASK_PATTERN_HTML = /^<li>(?<p_tag>\s*<p>)?\[(?<checked>[ xX])\]/.freeze
# Change the state of a task list item for this Taskable. Edit the object's
# description by finding the nth task item and changing its checkbox
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 798306f6dcc..5634f9a686e 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -105,6 +105,15 @@ class MergeRequest < ActiveRecord::Base
state :unchecked
state :can_be_merged
state :cannot_be_merged
+
+ around_transition do |merge_request, transition, block|
+ merge_request.record_timestamps = false
+ begin
+ block.call
+ ensure
+ merge_request.record_timestamps = true
+ end
+ end
end
validates :source_project, presence: true, unless: :allow_broken
diff --git a/app/models/note.rb b/app/models/note.rb
index 27b583a869a..e86160e7cd9 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -48,6 +48,7 @@ class Note < ActiveRecord::Base
scope :inline, ->{ where("line_code IS NOT NULL") }
scope :not_inline, ->{ where(line_code: [nil, '']) }
scope :system, ->{ where(system: true) }
+ scope :user, ->{ where(system: false) }
scope :common, ->{ where(noteable_type: ["", nil]) }
scope :fresh, ->{ order(created_at: :asc, id: :asc) }
scope :inc_author_project, ->{ includes(:project, :author) }
diff --git a/app/models/user.rb b/app/models/user.rb
index 50f664a09a3..979150b4d68 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -110,6 +110,7 @@ class User < ActiveRecord::Base
has_many :notes, dependent: :destroy, foreign_key: :author_id
has_many :merge_requests, dependent: :destroy, foreign_key: :author_id
has_many :events, dependent: :destroy, foreign_key: :author_id, class_name: "Event"
+ has_many :subscriptions, dependent: :destroy
has_many :recent_events, -> { order "id DESC" }, foreign_key: :author_id, class_name: "Event"
has_many :assigned_issues, dependent: :destroy, foreign_key: :assignee_id, class_name: "Issue"
has_many :assigned_merge_requests, dependent: :destroy, foreign_key: :assignee_id, class_name: "MergeRequest"
diff --git a/app/services/issues/bulk_update_service.rb b/app/services/issues/bulk_update_service.rb
index c7cd20b6b60..eb07413ee94 100644
--- a/app/services/issues/bulk_update_service.rb
+++ b/app/services/issues/bulk_update_service.rb
@@ -4,9 +4,9 @@ module Issues
issues_ids = params.delete(:issues_ids).split(",")
issue_params = params
- issue_params.delete(:state_event) unless issue_params[:state_event].present?
- issue_params.delete(:milestone_id) unless issue_params[:milestone_id].present?
- issue_params.delete(:assignee_id) unless issue_params[:assignee_id].present?
+ issue_params.delete(:state_event) unless issue_params[:state_event].present?
+ issue_params.delete(:milestone_id) unless issue_params[:milestone_id].present?
+ issue_params.delete(:assignee_id) unless issue_params[:assignee_id].present?
issues = Issue.where(id: issues_ids)
issues.each do |issue|
diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb
index c61d67a7893..3371fe7d5ef 100644
--- a/app/services/issues/update_service.rb
+++ b/app/services/issues/update_service.rb
@@ -14,6 +14,9 @@ module Issues
issue.update_nth_task(params[:task_num].to_i, false)
end
+ params[:assignee_id] = "" if params[:assignee_id] == "-1"
+ params[:milestone_id] = "" if params[:milestone_id] == "-1"
+
old_labels = issue.labels.to_a
if params.present? && issue.update_attributes(params.except(:state_event,
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb
index 7eef2c2d6a5..e9b526d1fb7 100644
--- a/app/services/merge_requests/refresh_service.rb
+++ b/app/services/merge_requests/refresh_service.rb
@@ -53,7 +53,7 @@ module MergeRequests
if merge_request.source_branch == @branch_name || force_push?
merge_request.reload_code
- update_merge_request(merge_request)
+ merge_request.mark_as_unchecked
else
mr_commit_ids = merge_request.commits.map(&:id)
push_commit_ids = @commits.map(&:id)
@@ -61,20 +61,14 @@ module MergeRequests
if matches.any?
merge_request.reload_code
- update_merge_request(merge_request)
+ merge_request.mark_as_unchecked
else
- update_merge_request(merge_request)
+ merge_request.mark_as_unchecked
end
end
end
end
- def update_merge_request(merge_request)
- MergeRequests::UpdateService.new(
- merge_request.target_project,
- @current_user, merge_status: 'unchecked').execute(merge_request)
- end
-
# Add comment about pushing new commits to merge requests
def comment_mr_with_commits
merge_requests = @project.origin_merge_requests.opened.where(source_branch: @branch_name).to_a
diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb
index 870b50bb60d..0ac6dfea6fd 100644
--- a/app/services/merge_requests/update_service.rb
+++ b/app/services/merge_requests/update_service.rb
@@ -23,6 +23,9 @@ module MergeRequests
merge_request.update_nth_task(params[:task_num].to_i, false)
end
+ params[:assignee_id] = "" if params[:assignee_id] == "-1"
+ params[:milestone_id] = "" if params[:milestone_id] == "-1"
+
old_labels = merge_request.labels.to_a
if params.present? && merge_request.update_attributes(
diff --git a/app/views/admin/broadcast_messages/index.html.haml b/app/views/admin/broadcast_messages/index.html.haml
index c0afaf16d8f..7e29311bf42 100644
--- a/app/views/admin/broadcast_messages/index.html.haml
+++ b/app/views/admin/broadcast_messages/index.html.haml
@@ -21,13 +21,11 @@
.form-group.js-toggle-colors-container.hide
= f.label :color, "Background Color", class: 'control-label'
.col-sm-10
- = f.text_field :color, placeholder: "#AA33EE", class: "form-control"
- .light 6 character hex values starting with a # sign.
+ = f.color_field :color, value: "#AA33EE", class: "form-control"
.form-group.js-toggle-colors-container.hide
= f.label :font, "Font Color", class: 'control-label'
.col-sm-10
- = f.text_field :font, placeholder: "#224466", class: "form-control"
- .light 6 character hex values starting with a # sign.
+ = f.color_field :font, value: "#224466", class: "form-control"
.form-group
= f.label :starts_at, class: 'control-label'
.col-sm-10.datetime-controls
diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml
index 4c853f577e9..c6026f96804 100644
--- a/app/views/projects/commits/_commit.html.haml
+++ b/app/views/projects/commits/_commit.html.haml
@@ -13,7 +13,7 @@
- note_count = @note_counts.fetch(commit.id, 0)
- else
- notes = project.notes.for_commit_id(commit.id)
- - note_count = notes.count
+ - note_count = notes.user.count
- if note_count > 0
%span.light
diff --git a/app/views/projects/diffs/_diffs.html.haml b/app/views/projects/diffs/_diffs.html.haml
index 1747f36dcf3..2b9b6599a7d 100644
--- a/app/views/projects/diffs/_diffs.html.haml
+++ b/app/views/projects/diffs/_diffs.html.haml
@@ -1,10 +1,9 @@
-.row.prepend-top-20.append-bottom-10
- .col-md-8
- = render 'projects/diffs/stats', diffs: diffs
- .col-md-4
- .btn-group.pull-right
+.prepend-top-20.append-bottom-20
+ .pull-right
+ .btn-group
= inline_diff_btn
= parallel_diff_btn
+ = render 'projects/diffs/stats', diffs: diffs
- if show_diff_size_warning?(diffs)
= render 'projects/diffs/warning', diffs: diffs
@@ -19,3 +18,6 @@
Failed to collect changes
%p
Maybe diff is really big and operation failed with timeout. Try to get diff locally
+
+:coffeescript
+ $('.files .diff-header').stick_in_parent(recalc_every: 1, offset_top: $('.navbar').height())
diff --git a/app/views/projects/diffs/_file.html.haml b/app/views/projects/diffs/_file.html.haml
index 860ab096341..672a6635321 100644
--- a/app/views/projects/diffs/_file.html.haml
+++ b/app/views/projects/diffs/_file.html.haml
@@ -13,12 +13,13 @@
- submodule_item = project.repository.blob_at(@commit.id, diff_file.file_path)
= submodule_link(submodule_item, @commit.id)
- else
- - if diff_file.renamed_file
- %span= "#{diff_file.old_path} renamed to #{diff_file.new_path}"
- - else
- %span= diff_file.new_path
- - if diff_file.mode_changed?
- %span.file-mode= "#{diff_file.diff.a_mode} → #{diff_file.diff.b_mode}"
+ %span
+ - if diff_file.renamed_file
+ = "#{diff_file.old_path} renamed to #{diff_file.new_path}"
+ - else
+ = diff_file.new_path
+ - if diff_file.mode_changed?
+ %span.file-mode= "#{diff_file.diff.a_mode} → #{diff_file.diff.b_mode}"
.diff-btn-group
- if blob.text?
diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml
index 7b06fe72882..998e74d12cf 100644
--- a/app/views/projects/issues/_issue.html.haml
+++ b/app/views/projects/issues/_issue.html.haml
@@ -10,11 +10,12 @@
- if issue.closed?
%span
CLOSED
- - if issue.notes.any?
+ - note_count = issue.notes.user.count
+ - if note_count > 0
&nbsp;
%span
%i.fa.fa-comments
- = issue.notes.count
+ = note_count
.issue-info
= link_to "##{issue.iid}", issue_path(issue), class: "light"
diff --git a/app/views/projects/labels/_form.html.haml b/app/views/projects/labels/_form.html.haml
index 2305fce112e..ad993db6c0b 100644
--- a/app/views/projects/labels/_form.html.haml
+++ b/app/views/projects/labels/_form.html.haml
@@ -16,9 +16,9 @@
.col-sm-10
.input-group
.input-group-addon.label-color-preview &nbsp;
- = f.color_field :color, placeholder: "#AA33EE", class: "form-control"
+ = f.color_field :color, value: "#AA33EE", class: "form-control"
.help-block
- 6 character hex values starting with a # sign.
+ Choose any color.
%br
Or you can choose one of suggested colors below
diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml
index ecbff722b42..4f30d1e69f7 100644
--- a/app/views/projects/merge_requests/_merge_request.html.haml
+++ b/app/views/projects/merge_requests/_merge_request.html.haml
@@ -16,11 +16,12 @@
%span.label-branch<
%i.fa.fa-code-fork
%span= merge_request.target_branch
- - if merge_request.notes.any?
+ - note_count = merge_request.mr_and_commit_notes.user.count
+ - if note_count > 0
&nbsp;
%span
%i.fa.fa-comments
- = merge_request.mr_and_commit_notes.count
+ = note_count
.merge-request-info
= link_to "##{merge_request.iid}", merge_request_path(merge_request), class: "light"
- if merge_request.assignee
diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml
index ca4ceecb225..a74aede4e6b 100644
--- a/app/views/projects/merge_requests/_show.html.haml
+++ b/app/views/projects/merge_requests/_show.html.haml
@@ -40,7 +40,7 @@
= link_to merge_request_path(@merge_request) do
%i.fa.fa-comments
Discussion
- %span.badge= @merge_request.mr_and_commit_notes.count
+ %span.badge= @merge_request.mr_and_commit_notes.user.count
%li.commits-tab{data: {action: 'commits'}}
= link_to merge_request_path(@merge_request), title: 'Commits' do
%i.fa.fa-history
diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml
index 110d8967342..25cc0030965 100644
--- a/app/views/projects/milestones/show.html.haml
+++ b/app/views/projects/milestones/show.html.haml
@@ -60,11 +60,12 @@
Participants
%span.badge= @users.count
- .pull-right
- = link_to new_namespace_project_issue_path(@project.namespace, @project, issue: { milestone_id: @milestone.id }), class: "btn btn-grouped", title: "New Issue" do
- %i.fa.fa-plus
- New Issue
- = link_to 'Browse Issues', namespace_project_issues_path(@milestone.project.namespace, @milestone.project, milestone_id: @milestone.id), class: "btn edit-milestone-link btn-grouped"
+ - if @project.issues_enabled
+ .pull-right
+ = link_to new_namespace_project_issue_path(@project.namespace, @project, issue: { milestone_id: @milestone.id }), class: "btn btn-grouped", title: "New Issue" do
+ %i.fa.fa-plus
+ New Issue
+ = link_to 'Browse Issues', namespace_project_issues_path(@milestone.project.namespace, @milestone.project, milestone_id: @milestone.id), class: "btn edit-milestone-link btn-grouped"
.tab-content
.tab-pane.active#tab-issues
diff --git a/app/views/projects/notes/_discussion.html.haml b/app/views/projects/notes/_discussion.html.haml
index f4c6fad2fed..3561ca49f81 100644
--- a/app/views/projects/notes/_discussion.html.haml
+++ b/app/views/projects/notes/_discussion.html.haml
@@ -2,7 +2,8 @@
.timeline-entry
.timeline-entry-inner
.timeline-icon
- = image_tag avatar_icon(note.author_email), class: "avatar s40"
+ = link_to user_path(note.author) do
+ = image_tag avatar_icon(note.author_email), class: "avatar s40"
.timeline-content
- if note.for_merge_request?
- if note.outdated?
diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml
index f3d00a6f06d..71bdf5c8f2a 100644
--- a/app/views/projects/notes/_note.html.haml
+++ b/app/views/projects/notes/_note.html.haml
@@ -4,7 +4,8 @@
- if note.system
%span.fa.fa-circle
- else
- = image_tag avatar_icon(note.author_email), class: "avatar s40"
+ = link_to user_path(note.author) do
+ = image_tag avatar_icon(note.author_email), class: "avatar s40"
.timeline-content
.note-header
.note-actions
@@ -21,7 +22,8 @@
%i.fa.fa-trash-o.cred
Remove
- if note.system
- = image_tag avatar_icon(note.author_email), class: "avatar s16"
+ = link_to user_path(note.author) do
+ = image_tag avatar_icon(note.author_email), class: "avatar s16"
= link_to_member(@project, note.author, avatar: false)
%span.author-username
= '@' + note.author.username
diff --git a/app/views/projects/notes/discussions/_diff.html.haml b/app/views/projects/notes/discussions/_diff.html.haml
index f717c77a898..711aa39101b 100644
--- a/app/views/projects/notes/discussions/_diff.html.haml
+++ b/app/views/projects/notes/discussions/_diff.html.haml
@@ -2,13 +2,13 @@
- if diff
.diff-file
.diff-header
- - if diff.deleted_file
- %span= diff.old_path
- - else
- %span= diff.new_path
- - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode
- %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}"
- %br/
+ %span
+ - if diff.deleted_file
+ = diff.old_path
+ - else
+ = diff.new_path
+ - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode
+ %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}"
.diff-content
%table
- note.truncated_diff_lines.each do |line|
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index a85db10e019..c4a0fefb7ab 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -285,6 +285,9 @@ production: &base
rack_attack:
git_basic_auth:
+ # Rack Attack IP banning enabled
+ # enabled: true
+ #
# Whitelist requests from 127.0.0.1 for web proxies (NGINX/Apache) with incorrect headers
# ip_whitelist: ["127.0.0.1"]
#
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 70af7a829c4..15c1ae9466f 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -183,6 +183,7 @@ Settings['extra'] ||= Settingslogic.new({})
#
Settings['rack_attack'] ||= Settingslogic.new({})
Settings.rack_attack['git_basic_auth'] ||= Settingslogic.new({})
+Settings.rack_attack.git_basic_auth['enabled'] = true if Settings.rack_attack.git_basic_auth['enabled'].nil?
Settings.rack_attack.git_basic_auth['ip_whitelist'] ||= %w{127.0.0.1}
Settings.rack_attack.git_basic_auth['maxretry'] ||= 10
Settings.rack_attack.git_basic_auth['findtime'] ||= 1.minute
diff --git a/db/migrate/20150324155957_set_incorrect_assignee_id_to_null.rb b/db/migrate/20150324155957_set_incorrect_assignee_id_to_null.rb
new file mode 100644
index 00000000000..42dc8173e46
--- /dev/null
+++ b/db/migrate/20150324155957_set_incorrect_assignee_id_to_null.rb
@@ -0,0 +1,6 @@
+class SetIncorrectAssigneeIdToNull < ActiveRecord::Migration
+ def up
+ execute "UPDATE issues SET assignee_id = NULL WHERE assignee_id = -1"
+ execute "UPDATE merge_requests SET assignee_id = NULL WHERE assignee_id = -1"
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e1a5b70532a..4a445ae5832 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150320234437) do
+ActiveRecord::Schema.define(version: 20150324155957) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index b52d786e020..edfdf842f85 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -1,4 +1,5 @@
require 'mime/types'
+require 'uri'
module API
# Projects API
@@ -103,7 +104,7 @@ module API
delete ":id/repository/branches/:branch" do
authorize_push_project
result = DeleteBranchService.new(user_project, current_user).
- execute(params[:branch])
+ execute(URI.unescape(params[:branch]))
if result[:status] == :success
{
diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb
index b051ae4c842..050b5ba29dd 100644
--- a/lib/gitlab/backend/grack_auth.rb
+++ b/lib/gitlab/backend/grack_auth.rb
@@ -1,3 +1,4 @@
+require_relative 'rack_attack_helpers'
require_relative 'shell_env'
module Grack
@@ -85,25 +86,41 @@ module Grack
user = oauth_access_token_check(login, password)
end
- return user if user.present?
-
- # At this point, we know the credentials were wrong. We let Rack::Attack
- # know there was a failed authentication attempt from this IP. This
- # information is stored in the Rails cache (Redis) and will be used by
- # the Rack::Attack middleware to decide whether to block requests from
- # this IP.
+ # If the user authenticated successfully, we reset the auth failure count
+ # from Rack::Attack for that IP. A client may attempt to authenticate
+ # with a username and blank password first, and only after it receives
+ # a 401 error does it present a password. Resetting the count prevents
+ # false positives from occurring.
+ #
+ # Otherwise, we let Rack::Attack know there was a failed authentication
+ # attempt from this IP. This information is stored in the Rails cache
+ # (Redis) and will be used by the Rack::Attack middleware to decide
+ # whether to block requests from this IP.
config = Gitlab.config.rack_attack.git_basic_auth
- Rack::Attack::Allow2Ban.filter(@request.ip, config) do
- # Unless the IP is whitelisted, return true so that Allow2Ban
- # increments the counter (stored in Rails.cache) for the IP
- if config.ip_whitelist.include?(@request.ip)
- false
+
+ if config.enabled
+ if user
+ # A successful login will reset the auth failure count from this IP
+ Rack::Attack::Allow2Ban.reset(@request.ip, config)
else
- true
+ banned = Rack::Attack::Allow2Ban.filter(@request.ip, config) do
+ # Unless the IP is whitelisted, return true so that Allow2Ban
+ # increments the counter (stored in Rails.cache) for the IP
+ if config.ip_whitelist.include?(@request.ip)
+ false
+ else
+ true
+ end
+ end
+
+ if banned
+ Rails.logger.info "IP #{@request.ip} failed to login " \
+ "as #{login} but has been temporarily banned from Git auth"
+ end
end
end
- nil # No user was found
+ user
end
def authorized_request?
diff --git a/lib/gitlab/backend/rack_attack_helpers.rb b/lib/gitlab/backend/rack_attack_helpers.rb
new file mode 100644
index 00000000000..8538f3f6eca
--- /dev/null
+++ b/lib/gitlab/backend/rack_attack_helpers.rb
@@ -0,0 +1,31 @@
+# rack-attack v4.2.0 doesn't yet support clearing of keys.
+# Taken from https://github.com/kickstarter/rack-attack/issues/113
+class Rack::Attack::Allow2Ban
+ def self.reset(discriminator, options)
+ findtime = options[:findtime] or raise ArgumentError, "Must pass findtime option"
+
+ cache.reset_count("#{key_prefix}:count:#{discriminator}", findtime)
+ cache.delete("#{key_prefix}:ban:#{discriminator}")
+ end
+end
+
+class Rack::Attack::Cache
+ def reset_count(unprefixed_key, period)
+ epoch_time = Time.now.to_i
+ # Add 1 to expires_in to avoid timing error: http://git.io/i1PHXA
+ expires_in = period - (epoch_time % period) + 1
+ key = "#{(epoch_time / period).to_i}:#{unprefixed_key}"
+ delete(key)
+ end
+
+ def delete(unprefixed_key)
+ store.delete("#{prefix}:#{unprefixed_key}")
+ end
+end
+
+class Rack::Attack::StoreProxy::RedisStoreProxy
+ def delete(key, options={})
+ self.del(key)
+ rescue Redis::BaseError
+ end
+end
diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb
index e02e5b9fc3d..f5e8267031c 100644
--- a/lib/gitlab/markdown.rb
+++ b/lib/gitlab/markdown.rb
@@ -352,11 +352,12 @@ module Gitlab
# ActiveSupport::SafeBuffer, hence the `String.new`
String.new(text).gsub(Taskable::TASK_PATTERN_HTML) do
checked = $LAST_MATCH_INFO[:checked].downcase == 'x'
+ p_tag = $LAST_MATCH_INFO[:p_tag]
if checked
- "#{li_tag}#{checked_box}"
+ "#{li_tag}#{p_tag}#{checked_box}"
else
- "#{li_tag}#{unchecked_box}"
+ "#{li_tag}#{p_tag}#{unchecked_box}"
end
end
end
diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb
index 8b85f3da83f..0dab7bcfa4d 100644
--- a/lib/gitlab/project_search_results.rb
+++ b/lib/gitlab/project_search_results.rb
@@ -67,7 +67,7 @@ module Gitlab
end
def notes
- Note.where(project_id: limit_project_ids).search(query).order('updated_at DESC')
+ Note.where(project_id: limit_project_ids).user.search(query).order('updated_at DESC')
end
def limit_project_ids
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 6ba27b536e4..ddbb4467f10 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -817,6 +817,17 @@ EOT
)
end
+ it 'should render checkboxes for nested tasks' do
+ rendered_text = markdown(@source_text_asterisk, parse_tasks: true)
+
+ expect(rendered_text).to match(
+ /<input.*checkbox.*valid unchecked nested task/
+ )
+ expect(rendered_text).to match(
+ /<input.*checkbox.*valid checked nested task/
+ )
+ end
+
it 'should not be confused by whitespace before bullets' do
rendered_text_asterisk = markdown(@source_text_asterisk,
parse_tasks: true)
diff --git a/spec/lib/gitlab/backend/grack_auth_spec.rb b/spec/lib/gitlab/backend/grack_auth_spec.rb
index 768312f0028..d0aad54f677 100644
--- a/spec/lib/gitlab/backend/grack_auth_spec.rb
+++ b/spec/lib/gitlab/backend/grack_auth_spec.rb
@@ -6,7 +6,7 @@ describe Grack::Auth do
let(:app) { lambda { |env| [200, {}, "Success!"] } }
let!(:auth) { Grack::Auth.new(app) }
- let(:env) {
+ let(:env) {
{
"rack.input" => "",
"REQUEST_METHOD" => "GET",
@@ -85,6 +85,17 @@ describe Grack::Auth do
it "responds with status 401" do
expect(status).to eq(401)
end
+
+ context "when the user is IP banned" do
+ before do
+ expect(Rack::Attack::Allow2Ban).to receive(:filter).and_return(true)
+ allow_any_instance_of(Rack::Request).to receive(:ip).and_return('1.2.3.4')
+ end
+
+ it "responds with status 401" do
+ expect(status).to eq(401)
+ end
+ end
end
context "when authentication succeeds" do
@@ -109,10 +120,49 @@ describe Grack::Auth do
end
context "when the user isn't blocked" do
+ before do
+ expect(Rack::Attack::Allow2Ban).to receive(:reset)
+ end
+
it "responds with status 200" do
expect(status).to eq(200)
end
end
+
+ context "when blank password attempts follow a valid login" do
+ let(:options) { Gitlab.config.rack_attack.git_basic_auth }
+ let(:maxretry) { options[:maxretry] - 1 }
+ let(:ip) { '1.2.3.4' }
+
+ before do
+ allow_any_instance_of(Rack::Request).to receive(:ip).and_return(ip)
+ Rack::Attack::Allow2Ban.reset(ip, options)
+ end
+
+ after do
+ Rack::Attack::Allow2Ban.reset(ip, options)
+ end
+
+ def attempt_login(include_password)
+ password = include_password ? user.password : ""
+ env["HTTP_AUTHORIZATION"] = ActionController::HttpAuthentication::Basic.encode_credentials(user.username, password)
+ Grack::Auth.new(app)
+ auth.call(env).first
+ end
+
+ it "repeated attempts followed by successful attempt" do
+ for n in 0..maxretry do
+ expect(attempt_login(false)).to eq(401)
+ end
+
+ expect(attempt_login(true)).to eq(200)
+ expect(Rack::Attack::Allow2Ban.send(:banned?, ip)).to eq(nil)
+
+ for n in 0..maxretry do
+ expect(attempt_login(false)).to eq(401)
+ end
+ end
+ end
end
context "when the user doesn't have access to the project" do
diff --git a/spec/lib/gitlab/backend/rack_attack_helpers_spec.rb b/spec/lib/gitlab/backend/rack_attack_helpers_spec.rb
new file mode 100644
index 00000000000..2ac496fd669
--- /dev/null
+++ b/spec/lib/gitlab/backend/rack_attack_helpers_spec.rb
@@ -0,0 +1,35 @@
+require "spec_helper"
+
+describe 'RackAttackHelpers' do
+ describe 'reset' do
+ let(:discriminator) { 'test-key'}
+ let(:maxretry) { 5 }
+ let(:period) { 1.minute }
+ let(:options) { { findtime: period, bantime: 60, maxretry: maxretry } }
+
+ def do_filter
+ for i in 1..maxretry - 1 do
+ status = Rack::Attack::Allow2Ban.filter(discriminator, options) { true }
+ expect(status).to eq(false)
+ end
+ end
+
+ def do_reset
+ Rack::Attack::Allow2Ban.reset(discriminator, options)
+ end
+
+ before do
+ do_reset
+ end
+
+ after do
+ do_reset
+ end
+
+ it 'user is not banned after n - 1 retries' do
+ do_filter
+ do_reset
+ do_filter
+ end
+ end
+end