Commit 590ba33e authored by Rémy Coutable's avatar Rémy Coutable

Merge remote-tracking branch 'origin/master' into 8-13-stable

parents fb390c57 24b73bc9
...@@ -124,15 +124,20 @@ ...@@ -124,15 +124,20 @@
display: -webkit-flex; display: -webkit-flex;
display: flex; display: flex;
box-shadow: 0 0 0 1px $border-color; box-shadow: 0 0 0 1px $border-color;
border-top-right-radius: 2px; border-top-right-radius: $border-radius-default;
border-top-left-radius: 2px; border-top-left-radius: $border-radius-default;
li { li {
flex: 1; flex: 1;
text-align: center; text-align: center;
&:first-of-type {
border-top-left-radius: $border-radius-default;
}
&:last-of-type { &:last-of-type {
border-left: 1px solid $border-color; border-left: 1px solid $border-color;
border-top-right-radius: $border-radius-default;
} }
&:not(.active) { &:not(.active) {
......
= form_tag(omniauth_authorize_path(:user, :crowd), id: 'new_crowd_user', class: 'show-gl-field-errors') do = form_tag(omniauth_authorize_path(:user, :crowd), id: 'new_crowd_user', class: 'show-gl-field-errors') do
.form-group .form-group
= label_tag 'Username or email', for: :username = label_tag :username, 'Username or email'
= text_field_tag :username, nil, {class: "form-control top", title: "This field is required", autofocus: "autofocus", required: true } = text_field_tag :username, nil, {class: "form-control top", title: "This field is required", autofocus: "autofocus", required: true }
.form-group .form-group
= label_tag :password = label_tag :password
...@@ -10,4 +10,4 @@ ...@@ -10,4 +10,4 @@
%label{for: "remember_me"} %label{for: "remember_me"}
= check_box_tag :remember_me, '1', false, id: 'remember_me' = check_box_tag :remember_me, '1', false, id: 'remember_me'
%span Remember me %span Remember me
= button_tag "Sign in", class: "btn-save btn" = submit_tag "Sign in", class: "btn-save btn"
= form_tag(omniauth_callback_path(:user, server['provider_name']), id: 'new_ldap_user', class: "show-gl-field-errors") do = form_tag(omniauth_callback_path(:user, server['provider_name']), id: 'new_ldap_user', class: "show-gl-field-errors") do
.form-group .form-group
= label_tag "#{server['label']} Login", for: :username = label_tag :username, "#{server['label']} Username"
= text_field_tag :username, nil, {class: "form-control top", title: "This field is required.", autofocus: "autofocus", required: true } = text_field_tag :username, nil, {class: "form-control top", title: "This field is required.", autofocus: "autofocus", required: true }
.form-group .form-group
= label_tag :password = label_tag :password
...@@ -10,4 +10,4 @@ ...@@ -10,4 +10,4 @@
%label{for: "remember_me"} %label{for: "remember_me"}
= check_box_tag :remember_me, '1', false, id: 'remember_me' = check_box_tag :remember_me, '1', false, id: 'remember_me'
%span Remember me %span Remember me
= button_tag "Sign in", class: "btn-save btn" = submit_tag "Sign in", class: "btn-save btn"
#login-pane.login-box{ role: 'tabpanel', class: 'tab-pane active' } - if form_based_providers.any?
.login-body - if crowd_enabled?
- if form_based_providers.any? .login-box.tab-pane.active{id: "crowd", role: 'tabpanel', class: 'tab-pane'}
- if crowd_enabled? .login-body
%div.tab-pane.active{id: "tab-crowd"} = render 'devise/sessions/new_crowd'
= render 'devise/sessions/new_crowd' - @ldap_servers.each_with_index do |server, i|
- @ldap_servers.each_with_index do |server, i| .login-box.tab-pane{id: "#{server['provider_name']}", role: 'tabpanel', class: (:active if i.zero? && !crowd_enabled?)}
%div.tab-pane{id: "tab-#{server['provider_name']}", class: (:active if i.zero? && !crowd_enabled?)} .login-body
= render 'devise/sessions/new_ldap', server: server = render 'devise/sessions/new_ldap', server: server
- if signin_enabled? - if signin_enabled?
%div#tab-signin.tab-pane .login-box.tab-pane{id: 'ldap-standard', role: 'tabpanel'}
= render 'devise/sessions/new_base' .login-body
= render 'devise/sessions/new_base'
- elsif signin_enabled? - elsif signin_enabled?
.login-box.tab-pane.active{id: 'login-pane', role: 'tabpanel'}
.login-body
= render 'devise/sessions/new_base' = render 'devise/sessions/new_base'
%ul.new-session-tabs.nav-links.nav-tabs %ul.new-session-tabs.nav-links.nav-tabs
- if crowd_enabled? - if crowd_enabled?
%li.active %li.active
= link_to "Crowd", "#tab-crowd", 'data-toggle' => 'tab' = link_to "Crowd", "#crowd", 'data-toggle' => 'tab'
- @ldap_servers.each_with_index do |server, i| - @ldap_servers.each_with_index do |server, i|
%li{class: (:active if i.zero? && !crowd_enabled?)} %li{class: (:active if i.zero? && !crowd_enabled?)}
= link_to server['label'], "#tab-#{server['provider_name']}", 'data-toggle' => 'tab' = link_to server['label'], "##{server['provider_name']}", 'data-toggle' => 'tab'
- if signin_enabled? - if signin_enabled?
%li %li
= link_to 'Standard', '#tab-signin', 'data-toggle' => 'tab' = link_to 'Standard', '#ldap-standard', 'data-toggle' => 'tab'
...@@ -6,33 +6,40 @@ module API ...@@ -6,33 +6,40 @@ module API
before { authenticate! } before { authenticate! }
before { authorize! :download_code, user_project } before { authorize! :download_code, user_project }
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects do resource :projects do
# Get a project repository commits desc 'Get a project repository commits' do
# success Entities::RepoCommit
# Parameters: end
# id (required) - The ID of a project params do
# ref_name (optional) - The name of a repository branch or tag, if not given the default branch is used optional :ref_name, type: String, desc: 'The name of a repository branch or tag, if not given the default branch is used'
# since (optional) - Only commits after or in this date will be returned optional :since, type: String, desc: 'Only commits after or in this date will be returned'
# until (optional) - Only commits before or in this date will be returned optional :until, type: String, desc: 'Only commits before or in this date will be returned'
# Example Request: optional :page, type: Integer, default: 0, desc: 'The page for pagination'
# GET /projects/:id/repository/commits optional :per_page, type: Integer, default: 20, desc: 'The number of results per page'
end
get ":id/repository/commits" do get ":id/repository/commits" do
# TODO remove the next line for 9.0, use DateTime type in the params block
datetime_attributes! :since, :until datetime_attributes! :since, :until
page = (params[:page] || 0).to_i
per_page = (params[:per_page] || 20).to_i
ref = params[:ref_name] || user_project.try(:default_branch) || 'master' ref = params[:ref_name] || user_project.try(:default_branch) || 'master'
after = params[:since] offset = params[:page] * params[:per_page]
before = params[:until]
commits = user_project.repository.commits(ref,
limit: params[:per_page],
offset: offset,
after: params[:since],
before: params[:until])
commits = user_project.repository.commits(ref, limit: per_page, offset: page * per_page, after: after, before: before)
present commits, with: Entities::RepoCommit present commits, with: Entities::RepoCommit
end end
desc 'Commit multiple file changes as one commit' do desc 'Commit multiple file changes as one commit' do
success Entities::RepoCommitDetail
detail 'This feature was introduced in GitLab 8.13' detail 'This feature was introduced in GitLab 8.13'
end end
params do params do
requires :id, type: Integer, desc: 'The project ID' requires :id, type: Integer, desc: 'The project ID'
requires :branch_name, type: String, desc: 'The name of branch' requires :branch_name, type: String, desc: 'The name of branch'
...@@ -41,7 +48,6 @@ module API ...@@ -41,7 +48,6 @@ module API
optional :author_email, type: String, desc: 'Author email for commit' optional :author_email, type: String, desc: 'Author email for commit'
optional :author_name, type: String, desc: 'Author name for commit' optional :author_name, type: String, desc: 'Author name for commit'
end end
post ":id/repository/commits" do post ":id/repository/commits" do
authorize! :push_code, user_project authorize! :push_code, user_project
...@@ -65,79 +71,82 @@ module API ...@@ -65,79 +71,82 @@ module API
end end
end end
# Get a specific commit of a project desc 'Get a specific commit of a project' do
# success Entities::RepoCommitDetail
# Parameters: failure [[404, 'Not Found']]
# id (required) - The ID of a project end
# sha (required) - The commit hash or name of a repository branch or tag params do
# Example Request: requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
# GET /projects/:id/repository/commits/:sha end
get ":id/repository/commits/:sha" do get ":id/repository/commits/:sha" do
sha = params[:sha] commit = user_project.commit(params[:sha])
commit = user_project.commit(sha)
not_found! "Commit" unless commit not_found! "Commit" unless commit
present commit, with: Entities::RepoCommitDetail present commit, with: Entities::RepoCommitDetail
end end
# Get the diff for a specific commit of a project desc 'Get the diff for a specific commit of a project' do
# failure [[404, 'Not Found']]
# Parameters: end
# id (required) - The ID of a project params do
# sha (required) - The commit or branch name requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
# Example Request: end
# GET /projects/:id/repository/commits/:sha/diff
get ":id/repository/commits/:sha/diff" do get ":id/repository/commits/:sha/diff" do
sha = params[:sha] commit = user_project.commit(params[:sha])
commit = user_project.commit(sha)
not_found! "Commit" unless commit not_found! "Commit" unless commit
commit.raw_diffs.to_a commit.raw_diffs.to_a
end end
# Get a commit's comments desc "Get a commit's comments" do
# success Entities::CommitNote
# Parameters: failure [[404, 'Not Found']]
# id (required) - The ID of a project end
# sha (required) - The commit hash params do
# Examples: requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
# GET /projects/:id/repository/commits/:sha/comments optional :per_page, type: Integer, desc: 'The amount of items per page for paginaion'
optional :page, type: Integer, desc: 'The page number for pagination'
end
get ':id/repository/commits/:sha/comments' do get ':id/repository/commits/:sha/comments' do
sha = params[:sha] commit = user_project.commit(params[:sha])
commit = user_project.commit(sha)
not_found! 'Commit' unless commit not_found! 'Commit' unless commit
notes = Note.where(commit_id: commit.id).order(:created_at) notes = Note.where(commit_id: commit.id).order(:created_at)
present paginate(notes), with: Entities::CommitNote present paginate(notes), with: Entities::CommitNote
end end
# Post comment to commit desc 'Post comment to commit' do
# success Entities::CommitNote
# Parameters: end
# id (required) - The ID of a project params do
# sha (required) - The commit hash requires :sha, type: String, regexp: /\A\h{6,40}\z/, desc: "The commit's SHA"
# note (required) - Text of comment requires :note, type: String, desc: 'The text of the comment'
# path (optional) - The file path optional :path, type: String, desc: 'The file path'
# line (optional) - The line number given :path do
# line_type (optional) - The type of line (new or old) requires :line, type: Integer, desc: 'The line number'
# Examples: requires :line_type, type: String, values: ['new', 'old'], default: 'new', desc: 'The type of the line'
# POST /projects/:id/repository/commits/:sha/comments end
end
post ':id/repository/commits/:sha/comments' do post ':id/repository/commits/:sha/comments' do
required_attributes! [:note] commit = user_project.commit(params[:sha])
sha = params[:sha]
commit = user_project.commit(sha)
not_found! 'Commit' unless commit not_found! 'Commit' unless commit
opts = { opts = {
note: params[:note], note: params[:note],
noteable_type: 'Commit', noteable_type: 'Commit',
commit_id: commit.id commit_id: commit.id
} }
if params[:path] && params[:line] && params[:line_type] if params[:path]
commit.raw_diffs(all_diffs: true).each do |diff| commit.raw_diffs(all_diffs: true).each do |diff|
next unless diff.new_path == params[:path] next unless diff.new_path == params[:path]
lines = Gitlab::Diff::Parser.new.parse(diff.diff.each_line) lines = Gitlab::Diff::Parser.new.parse(diff.diff.each_line)
lines.each do |line| lines.each do |line|
next unless line.new_pos == params[:line].to_i && line.type == params[:line_type] next unless line.new_pos == params[:line] && line.type == params[:line_type]
break opts[:line_code] = Gitlab::Diff::LineCode.generate(diff.new_path, line.new_pos, line.old_pos) break opts[:line_code] = Gitlab::Diff::LineCode.generate(diff.new_path, line.new_pos, line.old_pos)
end end
......
...@@ -12,13 +12,13 @@ describe 'devise/shared/_signin_box' do ...@@ -12,13 +12,13 @@ describe 'devise/shared/_signin_box' do
render render
expect(rendered).to have_selector('#tab-crowd form') expect(rendered).to have_selector('#crowd form')
end end
it 'is not shown when Crowd is disabled' do it 'is not shown when Crowd is disabled' do
render render
expect(rendered).not_to have_selector('#tab-crowd') expect(rendered).not_to have_selector('#crowd')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment