BigW Consortium Gitlab

Commit 1eabd9df by Marin Jankovski

Merge branch 'master' into relative_links_in_documentation

parents 3682a082 358426d6
...@@ -12,6 +12,7 @@ v 6.2.0 ...@@ -12,6 +12,7 @@ v 6.2.0
- Update logic for validates_merge_request for tree of MR (Andrew Kumanyaev) - Update logic for validates_merge_request for tree of MR (Andrew Kumanyaev)
- Rake tasks for web hooks management (Jonhnny Weslley) - Rake tasks for web hooks management (Jonhnny Weslley)
- Extended User API to expose admin and can_create_group for user creation/updating (Boyan Tabakov) - Extended User API to expose admin and can_create_group for user creation/updating (Boyan Tabakov)
- API: Remove group
v 6.1.0 v 6.1.0
- Project specific IDs for issues, mr, milestones - Project specific IDs for issues, mr, milestones
......
...@@ -65,11 +65,6 @@ ...@@ -65,11 +65,6 @@
.tree_author { .tree_author {
padding-right: 8px; padding-right: 8px;
img.avatar {
margin-top: 0;
width: 16px;
}
} }
.tree_commit { .tree_commit {
......
...@@ -14,7 +14,7 @@ class Projects::MilestonesController < Projects::ApplicationController ...@@ -14,7 +14,7 @@ class Projects::MilestonesController < Projects::ApplicationController
@milestones = case params[:f] @milestones = case params[:f]
when 'all'; @project.milestones.order("state, due_date DESC") when 'all'; @project.milestones.order("state, due_date DESC")
when 'closed'; @project.milestones.closed.order("due_date DESC") when 'closed'; @project.milestones.closed.order("due_date DESC")
else @project.milestones.active.order("due_date DESC") else @project.milestones.active.order("due_date ASC")
end end
@milestones = @milestones.includes(:project) @milestones = @milestones.includes(:project)
......
...@@ -222,7 +222,11 @@ class MergeRequest < ActiveRecord::Base ...@@ -222,7 +222,11 @@ class MergeRequest < ActiveRecord::Base
def mr_and_commit_notes def mr_and_commit_notes
commit_ids = commits.map(&:id) commit_ids = commits.map(&:id)
Note.where("(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))", mr_id: id, commit_ids: commit_ids) project.notes.where(
"(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))",
mr_id: id,
commit_ids: commit_ids
)
end end
# Returns the raw diff for this merge request # Returns the raw diff for this merge request
......
...@@ -53,6 +53,7 @@ class Project < ActiveRecord::Base ...@@ -53,6 +53,7 @@ class Project < ActiveRecord::Base
has_many :services, dependent: :destroy has_many :services, dependent: :destroy
has_many :events, dependent: :destroy has_many :events, dependent: :destroy
has_many :merge_requests, dependent: :destroy, foreign_key: "target_project_id" has_many :merge_requests, dependent: :destroy, foreign_key: "target_project_id"
has_many :fork_merge_requests,dependent: :destroy, foreign_key: "source_project_id", class_name: MergeRequest
has_many :issues, dependent: :destroy, order: "state DESC, created_at DESC" has_many :issues, dependent: :destroy, order: "state DESC, created_at DESC"
has_many :milestones, dependent: :destroy has_many :milestones, dependent: :destroy
has_many :notes, dependent: :destroy has_many :notes, dependent: :destroy
...@@ -312,8 +313,11 @@ class Project < ActiveRecord::Base ...@@ -312,8 +313,11 @@ class Project < ActiveRecord::Base
branch_name = ref.gsub("refs/heads/", "") branch_name = ref.gsub("refs/heads/", "")
c_ids = self.repository.commits_between(oldrev, newrev).map(&:id) c_ids = self.repository.commits_between(oldrev, newrev).map(&:id)
# Update code for merge requests # Update code for merge requests into project between project branches
mrs = self.merge_requests.opened.by_branch(branch_name).all mrs = self.merge_requests.opened.by_branch(branch_name).all
# Update code for merge requests between project and project fork
mrs += self.fork_merge_requests.opened.by_branch(branch_name).all
mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked } mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked }
# Close merge requests # Close merge requests
......
...@@ -36,7 +36,8 @@ class SystemHooksService ...@@ -36,7 +36,8 @@ class SystemHooksService
when User when User
data.merge!({ data.merge!({
name: model.name, name: model.name,
email: model.email email: model.email,
user_id: model.id
}) })
when UsersProject when UsersProject
data.merge!({ data.merge!({
......
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
"created_at": "2012-07-21T07:44:07Z", "created_at": "2012-07-21T07:44:07Z",
"email": "js@gitlabhq.com", "email": "js@gitlabhq.com",
"event_name": "user_create", "event_name": "user_create",
"name": "John Smith" "name": "John Smith",
"user_id": 41
} }
6. User removed: 6. User removed:
...@@ -60,7 +61,8 @@ ...@@ -60,7 +61,8 @@
"created_at": "2012-07-21T07:44:07Z", "created_at": "2012-07-21T07:44:07Z",
"email": "js@gitlabhq.com", "email": "js@gitlabhq.com",
"event_name": "user_destroy", "event_name": "user_destroy",
"name": "John Smith" "name": "John Smith",
"user_id": 41
} }
eos eos
......
.alert.alert-info %h3.page-title
%span System Hooks
Post-receive hooks for binding events.
%br %p.light
Read more about system hooks #{link_to "System hooks ", help_system_hooks_path, class: "vlink"} can be
%strong #{link_to "here", help_system_hooks_path, class: "vlink"} used for binding events when GitLab creates a User or Project.
%hr
= form_for @hook, as: :hook, url: admin_hooks_path, html: { class: 'form-inline' } do |f| = form_for @hook, as: :hook, url: admin_hooks_path, html: { class: 'form-inline' } do |f|
-if @hook.errors.any? -if @hook.errors.any?
......
%span.tree_author= commit_author_link(commit, avatar: true) %span.tree_author= commit_author_link(commit, avatar: true, size: 16)
= link_to_gfm truncate(commit.title, length: 80), project_commit_path(@project, commit.id), class: "tree-commit-link" = link_to_gfm truncate(commit.title, length: 80), project_commit_path(@project, commit.id), class: "tree-commit-link"
...@@ -57,6 +57,19 @@ Parameters: ...@@ -57,6 +57,19 @@ Parameters:
+ `project_id` (required) - The ID of a project + `project_id` (required) - The ID of a project
## Remove group
Removes group with all projects inside.
```
DELETE /groups/:id
```
Parameters:
+ `id` (required) - The ID of a user group
## Group members ## Group members
......
...@@ -20,6 +20,8 @@ Parameters: ...@@ -20,6 +20,8 @@ Parameters:
"project_id":3, "project_id":3,
"title":"test1", "title":"test1",
"state":"opened", "state":"opened",
"upvotes":0,
"downvotes":0,
"author":{ "author":{
"id":1, "id":1,
"username": "admin", "username": "admin",
...@@ -62,6 +64,8 @@ Parameters: ...@@ -62,6 +64,8 @@ Parameters:
"project_id":3, "project_id":3,
"title":"test1", "title":"test1",
"state":"merged", "state":"merged",
"upvotes":0,
"downvotes":0,
"author":{ "author":{
"id":1, "id":1,
"username": "admin", "username": "admin",
...@@ -106,6 +110,8 @@ Parameters: ...@@ -106,6 +110,8 @@ Parameters:
"project_id":3, "project_id":3,
"title":"test1", "title":"test1",
"state":"opened", "state":"opened",
"upvotes":0,
"downvotes":0,
"author":{ "author":{
"id":1, "id":1,
"username": "admin", "username": "admin",
...@@ -152,6 +158,8 @@ Parameters: ...@@ -152,6 +158,8 @@ Parameters:
"project_id":3, "project_id":3,
"title":"test1", "title":"test1",
"state":"opened", "state":"opened",
"upvotes":0,
"downvotes":0,
"author":{ "author":{
"id":1, "id":1,
"username": "admin", "username": "admin",
......
...@@ -7,7 +7,7 @@ It's useful to make a backup just in case things go south: ...@@ -7,7 +7,7 @@ It's useful to make a backup just in case things go south:
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
``` ```
### 1. Stop server ### 1. Stop server
...@@ -95,5 +95,5 @@ Follow the [`upgrade guide from 5.0 to 5.1`](5.0-to-5.1.md), except for the data ...@@ -95,5 +95,5 @@ Follow the [`upgrade guide from 5.0 to 5.1`](5.0-to-5.1.md), except for the data
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:restore sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
``` ```
...@@ -7,7 +7,7 @@ It's useful to make a backup just in case things go south: ...@@ -7,7 +7,7 @@ It's useful to make a backup just in case things go south:
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
``` ```
### 1. Stop server ### 1. Stop server
...@@ -78,5 +78,5 @@ Follow the [`upgrade guide from 5.1 to 5.2`](5.1-to-5.2.md), except for the data ...@@ -78,5 +78,5 @@ Follow the [`upgrade guide from 5.1 to 5.2`](5.1-to-5.2.md), except for the data
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:restore sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
``` ```
...@@ -7,7 +7,7 @@ It's useful to make a backup just in case things go south: ...@@ -7,7 +7,7 @@ It's useful to make a backup just in case things go south:
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
``` ```
### 1. Stop server ### 1. Stop server
...@@ -86,5 +86,5 @@ Follow the [`upgrade guide from 5.2 to 5.3`](5.2-to-5.3.md), except for the data ...@@ -86,5 +86,5 @@ Follow the [`upgrade guide from 5.2 to 5.3`](5.2-to-5.3.md), except for the data
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:restore sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
``` ```
...@@ -24,7 +24,7 @@ It's useful to make a backup just in case things go south: ...@@ -24,7 +24,7 @@ It's useful to make a backup just in case things go south:
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
``` ```
### 1. Stop server ### 1. Stop server
......
...@@ -16,7 +16,7 @@ It's useful to make a backup just in case things go south: ...@@ -16,7 +16,7 @@ It's useful to make a backup just in case things go south:
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
``` ```
### 1. Stop server ### 1. Stop server
...@@ -99,5 +99,5 @@ Follow the [`upgrade guide from 5.4 to 6.0`](5.4-to-6.0.md), except for the data ...@@ -99,5 +99,5 @@ Follow the [`upgrade guide from 5.4 to 6.0`](5.4-to-6.0.md), except for the data
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:restore sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
``` ```
...@@ -9,7 +9,7 @@ It's useful to make a backup just in case things go south: ...@@ -9,7 +9,7 @@ It's useful to make a backup just in case things go south:
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
``` ```
### 1. Stop server ### 1. Stop server
...@@ -96,5 +96,5 @@ Follow the [`upgrade guide from 6.0 to 6.1`](6.0-to-6.1.md), except for the data ...@@ -96,5 +96,5 @@ Follow the [`upgrade guide from 6.0 to 6.1`](6.0-to-6.1.md), except for the data
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:restore sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
``` ```
...@@ -112,7 +112,7 @@ module API ...@@ -112,7 +112,7 @@ module API
end end
class MergeRequest < Grape::Entity class MergeRequest < Grape::Entity
expose :id, :target_branch, :source_branch, :title, :state expose :id, :target_branch, :source_branch, :title, :state, :upvotes, :downvotes
expose :target_project_id, as: :project_id expose :target_project_id, as: :project_id
expose :author, :assignee, using: Entities::UserBasic expose :author, :assignee, using: Entities::UserBasic
end end
......
...@@ -7,12 +7,14 @@ module API ...@@ -7,12 +7,14 @@ module API
helpers do helpers do
def find_group(id) def find_group(id)
group = Group.find(id) group = Group.find(id)
if current_user.admin or current_user.groups.include? group
if can?(current_user, :read_group, group)
group group
else else
render_api_error!("403 Forbidden - #{current_user.username} lacks sufficient access to #{group.name}", 403) render_api_error!("403 Forbidden - #{current_user.username} lacks sufficient access to #{group.name}", 403)
end end
end end
def validate_access_level?(level) def validate_access_level?(level)
Gitlab::Access.options_with_owner.values.include? level.to_i Gitlab::Access.options_with_owner.values.include? level.to_i
end end
...@@ -64,6 +66,19 @@ module API ...@@ -64,6 +66,19 @@ module API
present group, with: Entities::GroupDetail present group, with: Entities::GroupDetail
end end
# Remove group
#
# Parameters:
# id (required) - The ID of a group
# Example Request:
# DELETE /groups/:id
delete ":id" do
group = find_group(params[:id])
authorize! :manage_group, group
group.destroy
end
# Transfer a project to the Group namespace # Transfer a project to the Group namespace
# #
# Parameters: # Parameters:
...@@ -132,7 +147,6 @@ module API ...@@ -132,7 +147,6 @@ module API
member.destroy member.destroy
end end
end end
end end
end end
end end
...@@ -35,6 +35,7 @@ module API ...@@ -35,6 +35,7 @@ module API
user = key.user user = key.user
return false if user.blocked? return false if user.blocked?
return false if user.ldap_user? && Gitlab::LDAP::User.blocked?(user.extern_uid)
action = case git_cmd action = case git_cmd
when *DOWNLOAD_COMMANDS when *DOWNLOAD_COMMANDS
......
...@@ -71,6 +71,16 @@ module Gitlab ...@@ -71,6 +71,16 @@ module Gitlab
find_by_uid(ldap_user.dn) if ldap_user find_by_uid(ldap_user.dn) if ldap_user
end end
# Check LDAP user existance by dn. User in git over ssh check
#
# It covers 2 cases:
# * when ldap account was removed
# * when ldap account was deactivated by change of OU membership in 'dn'
def blocked?(dn)
ldap = OmniAuth::LDAP::Adaptor.new(ldap_conf)
ldap.connection.search(base: dn, size: 1).blank?
end
private private
def find_by_uid(uid) def find_by_uid(uid)
......
...@@ -151,7 +151,7 @@ stop() { ...@@ -151,7 +151,7 @@ stop() {
exit_if_not_running exit_if_not_running
# If the Unicorn web server is running, tell it to stop; # If the Unicorn web server is running, tell it to stop;
if [ "$web_status" = "0" ]; then if [ "$web_status" = "0" ]; then
kill -QUIT "$wpid" & kill -QUIT "$wpid"
echo "Stopping the GitLab Unicorn web server..." echo "Stopping the GitLab Unicorn web server..."
stopping=true stopping=true
else else
...@@ -160,7 +160,7 @@ stop() { ...@@ -160,7 +160,7 @@ stop() {
# And do the same thing for the Sidekiq. # And do the same thing for the Sidekiq.
if [ "$sidekiq_status" = "0" ]; then if [ "$sidekiq_status" = "0" ]; then
printf "Stopping Sidekiq job dispatcher." printf "Stopping Sidekiq job dispatcher."
RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:stop & RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:stop
stopping=true stopping=true
else else
echo "The Sidekiq was not running, must have run out of breath." echo "The Sidekiq was not running, must have run out of breath."
......
...@@ -392,14 +392,20 @@ namespace :gitlab do ...@@ -392,14 +392,20 @@ namespace :gitlab do
hook_file = "update" hook_file = "update"
gitlab_shell_hooks_path = Gitlab.config.gitlab_shell.hooks_path gitlab_shell_hooks_path = Gitlab.config.gitlab_shell.hooks_path
gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file) gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
unless File.exists?(gitlab_shell_hook_file) if File.exists?(gitlab_shell_hook_file)
puts "can't check because of previous errors".magenta puts "yes".green
return else
puts "no".red
puts "Could not find #{gitlab_shell_hook_file}"
try_fixing_it(
'Check the hooks_path in config/gitlab.yml',
'Check your gitlab-shell installation'
)
for_more_information(
see_installation_guide_section "GitLab Shell"
)
end end
puts "yes".green
end end
def check_repo_base_exists def check_repo_base_exists
......
...@@ -49,8 +49,8 @@ describe MergeRequest do ...@@ -49,8 +49,8 @@ describe MergeRequest do
before do before do
merge_request.stub(:commits) { [merge_request.source_project.repository.commit] } merge_request.stub(:commits) { [merge_request.source_project.repository.commit] }
create(:note, commit_id: merge_request.commits.first.id, noteable_type: 'Commit') create(:note, commit_id: merge_request.commits.first.id, noteable_type: 'Commit', project: merge_request.project)
create(:note, noteable: merge_request) create(:note, noteable: merge_request, project: merge_request.project)
end end
it "should include notes for commits" do it "should include notes for commits" do
......
...@@ -106,6 +106,44 @@ describe API::API do ...@@ -106,6 +106,44 @@ describe API::API do
end end
end end
describe "DELETE /groups/:id" do
context "when authenticated as user" do
it "should remove group" do
delete api("/groups/#{group1.id}", user1)
response.status.should == 200
end
it "should not remove a group if not an owner" do
user3 = create(:user)
group1.add_user(user3, Gitlab::Access::MASTER)
delete api("/groups/#{group1.id}", user3)
response.status.should == 403
end
it "should not remove a non existing group" do
delete api("/groups/1328", user1)
response.status.should == 404
end
it "should not remove a group not attached to user1" do
delete api("/groups/#{group2.id}", user1)
response.status.should == 403
end
end
context "when authenticated as admin" do
it "should remove any existing group" do
delete api("/groups/#{group2.id}", admin)
response.status.should == 200
end
it "should not remove a non existing group" do
delete api("/groups/1328", admin)
response.status.should == 404
end
end
end
describe "POST /groups/:id/projects/:project_id" do describe "POST /groups/:id/projects/:project_id" do
let(:project) { create(:project) } let(:project) { create(:project) }
before(:each) do before(:each) do
......
...@@ -5,37 +5,29 @@ describe SystemHooksService do ...@@ -5,37 +5,29 @@ describe SystemHooksService do
let (:project) { create :project } let (:project) { create :project }
let (:users_project) { create :users_project } let (:users_project) { create :users_project }
context 'it should build event data' do context 'event data' do
it 'should build event data for user' do it { event_data(user, :create).should include(:event_name, :name, :created_at, :email, :user_id) }
SystemHooksService.build_event_data(user, :create).should include(:event_name, :name, :created_at, :email) it { event_data(user, :destroy).should include(:event_name, :name, :created_at, :email, :user_id) }
end it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) }
it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) }
it 'should build event data for project' do it { event_data(users_project, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) }
SystemHooksService.build_event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) it { event_data(users_project, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) }
end
it 'should build event data for users project' do
SystemHooksService.build_event_data(users_project, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access)
end
end end
context 'it should build event names' do context 'event names' do
it 'should build event names for user' do it { event_name(user, :create).should eq "user_create" }
SystemHooksService.build_event_name(user, :create).should eq "user_create" it { event_name(user, :destroy).should eq "user_destroy" }
it { event_name(project, :create).should eq "project_create" }
SystemHooksService.build_event_name(user, :destroy).should eq "user_destroy" it { event_name(project, :destroy).should eq "project_destroy" }
end it { event_name(users_project, :create).should eq "user_add_to_team" }
it { event_name(users_project, :destroy).should eq "user_remove_from_team" }
it 'should build event names for project' do end
SystemHooksService.build_event_name(project, :create).should eq "project_create"
SystemHooksService.build_event_name(project, :destroy).should eq "project_destroy"
end
it 'should build event names for users project' do def event_data(*args)
SystemHooksService.build_event_name(users_project, :create).should eq "user_add_to_team" SystemHooksService.build_event_data(*args)
end
SystemHooksService.build_event_name(users_project, :destroy).should eq "user_remove_from_team" def event_name(*args)
end SystemHooksService.build_event_name(*args)
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