Commit e1c48f14 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' into jastkand/gitlab-ce-fix-api-auth

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Conflicts:
	CHANGELOG
parents bafd30f9 d7c50b4a
...@@ -6,6 +6,9 @@ v 7.5.0 ...@@ -6,6 +6,9 @@ v 7.5.0
- Add Atlassian Bamboo CI service (Drew Blessing) - Add Atlassian Bamboo CI service (Drew Blessing)
- Mentioned @user will receive email even if he is not participating in issue or commit - Mentioned @user will receive email even if he is not participating in issue or commit
- Session API: Use case-insensitive authentication like in UI (Andrey Krivko) - Session API: Use case-insensitive authentication like in UI (Andrey Krivko)
- Tie up loose ends with annotated tags: API & UI (Sean Edge)
- Return valid json for deleting branch via API (sponsored by O'Reilly Media)
- Expose username in project events API (sponsored by O'Reilly Media)
v 7.4.2 v 7.4.2
- Fix internal snippet exposing for unauthenticated users - Fix internal snippet exposing for unauthenticated users
......
...@@ -54,6 +54,8 @@ We welcome merge requests with fixes and improvements to GitLab code, tests, and ...@@ -54,6 +54,8 @@ We welcome merge requests with fixes and improvements to GitLab code, tests, and
Merge requests can be filed either at [gitlab.com](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests) or [github.com](https://github.com/gitlabhq/gitlabhq/pulls). Merge requests can be filed either at [gitlab.com](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests) or [github.com](https://github.com/gitlabhq/gitlabhq/pulls).
If you are new to GitLab development (or web development in general), search for the label `easyfix` ([gitlab.com](https://gitlab.com/gitlab-org/gitlab-ce/issues?label_name=easyfix), [github](https://github.com/gitlabhq/gitlabhq/labels/easyfix)). Those are issues easy to fix, marked by the GitLab core-team. If you are unsure how to proceed but want to help, mention one of the core-team members to give you a hint.
### Merge request guidelines ### Merge request guidelines
If you can, please submit a merge request with the fix or improvements including tests. If you don't know how to fix the issue but can write a test that exposes the issue we will accept that as well. In general bug fixes that include a regression test are merged quickly while new features without proper tests are least likely to receive timely feedback. The workflow to make a merge request is as follows: If you can, please submit a merge request with the fix or improvements including tests. If you don't know how to fix the issue but can write a test that exposes the issue we will accept that as well. In general bug fixes that include a regression test are merged quickly while new features without proper tests are least likely to receive timely feedback. The workflow to make a merge request is as follows:
......
...@@ -143,7 +143,7 @@ gem "gitlab-flowdock-git-hook", "~> 0.4.2" ...@@ -143,7 +143,7 @@ gem "gitlab-flowdock-git-hook", "~> 0.4.2"
gem "gemnasium-gitlab-service", "~> 0.2" gem "gemnasium-gitlab-service", "~> 0.2"
# Slack integration # Slack integration
gem "slack-notifier", "~> 0.3.2" gem "slack-notifier", "~> 1.0.0"
# d3 # d3
gem "d3_rails", "~> 3.1.4" gem "d3_rails", "~> 3.1.4"
......
...@@ -488,7 +488,7 @@ GEM ...@@ -488,7 +488,7 @@ GEM
rack-protection (~> 1.4) rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4) tilt (~> 1.3, >= 1.3.4)
six (0.2.0) six (0.2.0)
slack-notifier (0.3.2) slack-notifier (1.0.0)
slim (2.0.2) slim (2.0.2)
temple (~> 0.6.6) temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1) tilt (>= 1.3.3, < 2.1)
...@@ -689,7 +689,7 @@ DEPENDENCIES ...@@ -689,7 +689,7 @@ DEPENDENCIES
simplecov simplecov
sinatra sinatra
six six
slack-notifier (~> 0.3.2) slack-notifier (~> 1.0.0)
slim slim
spinach-rails spinach-rails
spring (= 1.1.3) spring (= 1.1.3)
......
...@@ -19,6 +19,7 @@ class Projects::BranchesController < Projects::ApplicationController ...@@ -19,6 +19,7 @@ class Projects::BranchesController < Projects::ApplicationController
def create def create
result = CreateBranchService.new(project, current_user). result = CreateBranchService.new(project, current_user).
execute(params[:branch_name], params[:ref]) execute(params[:branch_name], params[:ref])
if result[:status] == :success if result[:status] == :success
@branch = result[:branch] @branch = result[:branch]
redirect_to project_tree_path(@project, @branch.name) redirect_to project_tree_path(@project, @branch.name)
......
...@@ -30,24 +30,20 @@ class SlackService < Service ...@@ -30,24 +30,20 @@ class SlackService < Service
def fields def fields
[ [
{ type: 'text', name: 'webhook', placeholder: '' } { type: 'text', name: 'webhook', placeholder: 'https://hooks.slack.com/services/...' }
] ]
end end
def execute(push_data) def execute(push_data)
return unless webhook.present?
message = SlackMessage.new(push_data.merge( message = SlackMessage.new(push_data.merge(
project_url: project_url, project_url: project_url,
project_name: project_name project_name: project_name
)) ))
credentials = webhook.match(/([\w-]*).slack.com.*services\/(.*)/) notifier = Slack::Notifier.new(webhook)
notifier.ping(message.pretext, attachments: message.attachments)
if credentials.present?
subdomain = credentials[1]
token = credentials[2].split("token=").last
notifier = Slack::Notifier.new(subdomain, token)
notifier.ping(message.pretext, attachments: message.attachments)
end
end end
private private
......
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
- if @commit.parent_ids.present? - if @commit.parent_ids.present?
= view_file_btn(@commit.parent_id, diff_file, project) = view_file_btn(@commit.parent_id, diff_file, project)
- else - else
%span= diff_file.new_path - 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? - if diff_file.mode_changed?
%span.file-mode= "#{diff_file.diff.a_mode}#{diff_file.diff.b_mode}" %span.file-mode= "#{diff_file.diff.a_mode}#{diff_file.diff.b_mode}"
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
= link_to project_commits_path(@project, tag.name), class: "" do = link_to project_commits_path(@project, tag.name), class: "" do
%i.fa.fa-tag %i.fa.fa-tag
= tag.name = tag.name
- if tag.message.present?
&nbsp;
= tag.message
.pull-right .pull-right
- if can? current_user, :download_code, @project - if can? current_user, :download_code, @project
= render 'projects/repositories/download_archive', ref: tag.name, btn_class: 'btn-grouped btn-group-small' = render 'projects/repositories/download_archive', ref: tag.name, btn_class: 'btn-grouped btn-group-small'
......
...@@ -22,11 +22,6 @@ module Gitlab ...@@ -22,11 +22,6 @@ module Gitlab
# :all can be used as a placeholder for all plugins not explicitly named. # :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ] # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# NOTE: Please prefer set time zone on config/gitlab.yml configuration file.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de # config.i18n.default_locale = :de
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
# Use at least one worker per core if you're on a dedicated server, # Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches. # more will usually help for _short_ waits on databases/caches.
# The minimum is 2
worker_processes 2 worker_processes 2
# Since Unicorn is never exposed to outside clients, it does not need to # Since Unicorn is never exposed to outside clients, it does not need to
......
...@@ -23,7 +23,7 @@ class SerializeServiceProperties < ActiveRecord::Migration ...@@ -23,7 +23,7 @@ class SerializeServiceProperties < ActiveRecord::Migration
associations[service.type.to_sym].each do |attribute| associations[service.type.to_sym].each do |attribute|
service.send("#{attribute}=", service.attributes[attribute.to_s]) service.send("#{attribute}=", service.attributes[attribute.to_s])
end end
service.save! service.save
end end
remove_column :services, :project_url, :string remove_column :services, :project_url, :string
......
...@@ -10,7 +10,7 @@ class MoveSlackServiceToWebhook < ActiveRecord::Migration ...@@ -10,7 +10,7 @@ class MoveSlackServiceToWebhook < ActiveRecord::Migration
slack_service.properties.delete('subdomain') slack_service.properties.delete('subdomain')
# Room is configured on the Slack side # Room is configured on the Slack side
slack_service.properties.delete('room') slack_service.properties.delete('room')
slack_service.save! slack_service.save
end end
end end
end end
......
...@@ -211,3 +211,11 @@ Parameters: ...@@ -211,3 +211,11 @@ Parameters:
It return 200 if succeed, 404 if the branch to be deleted does not exist It return 200 if succeed, 404 if the branch to be deleted does not exist
or 400 for other reasons. In case of an error, an explaining message is provided. or 400 for other reasons. In case of an error, an explaining message is provided.
Success response:
```json
{
"branch_name": "my-removed-branch"
}
```
...@@ -186,6 +186,7 @@ Parameters: ...@@ -186,6 +186,7 @@ Parameters:
"target_id": 830, "target_id": 830,
"target_type": "Issue", "target_type": "Issue",
"author_id": 1, "author_id": 1,
"author_username": "john",
"data": null, "data": null,
"target_title": "Public project search field" "target_title": "Public project search field"
}, },
...@@ -196,6 +197,7 @@ Parameters: ...@@ -196,6 +197,7 @@ Parameters:
"target_id": null, "target_id": null,
"target_type": null, "target_type": null,
"author_id": 1, "author_id": 1,
"author_username": "john",
"data": { "data": {
"before": "50d4420237a9de7be1304607147aec22e4a14af7", "before": "50d4420237a9de7be1304607147aec22e4a14af7",
"after": "c5feabde2d8cd023215af4d2ceeb7a64839fc428", "after": "c5feabde2d8cd023215af4d2ceeb7a64839fc428",
...@@ -231,6 +233,7 @@ Parameters: ...@@ -231,6 +233,7 @@ Parameters:
"target_id": 840, "target_id": 840,
"target_type": "Issue", "target_type": "Issue",
"author_id": 1, "author_id": 1,
"author_username": "john",
"data": null, "data": null,
"target_title": "Finish & merge Code search PR" "target_title": "Finish & merge Code search PR"
} }
......
...@@ -56,6 +56,7 @@ Parameters: ...@@ -56,6 +56,7 @@ Parameters:
[ [
{ {
"name": "v1.0.0", "name": "v1.0.0",
"message": "Release 1.0.0",
"commit": { "commit": {
"id": "2695effb5807a22ff3d138d593fd856244e155e7", "id": "2695effb5807a22ff3d138d593fd856244e155e7",
"parents": [], "parents": [],
...@@ -67,10 +68,11 @@ Parameters: ...@@ -67,10 +68,11 @@ Parameters:
"committed_date": "2012-05-28T04:42:42-07:00", "committed_date": "2012-05-28T04:42:42-07:00",
"committer_email": "jack@example.com" "committer_email": "jack@example.com"
}, },
"protected": false
} }
] ]
``` ```
The message will be `nil` when creating a lightweight tag otherwise
it will contain the annotation.
It returns 200 if the operation succeed. In case of an error, It returns 200 if the operation succeed. In case of an error,
405 with an explaining error message is returned. 405 with an explaining error message is returned.
......
...@@ -76,6 +76,7 @@ Is the system packaged Git too old? Remove it and compile from source. ...@@ -76,6 +76,7 @@ Is the system packaged Git too old? Remove it and compile from source.
cd /tmp cd /tmp
curl -L --progress https://www.kernel.org/pub/software/scm/git/git-2.1.2.tar.gz | tar xz curl -L --progress https://www.kernel.org/pub/software/scm/git/git-2.1.2.tar.gz | tar xz
cd git-2.1.2/ cd git-2.1.2/
./configure
make prefix=/usr/local all make prefix=/usr/local all
# Install into /usr/local/bin # Install into /usr/local/bin
...@@ -91,7 +92,7 @@ Then select 'Internet Site' and press enter to confirm the hostname. ...@@ -91,7 +92,7 @@ Then select 'Internet Site' and press enter to confirm the hostname.
## 2. Ruby ## 2. Ruby
The use of ruby version managers such as [RVM](http://rvm.io/), [rbenv](https://github.com/sstephenson/rbenv) or [chruby](https://github.com/postmodern/chruby) with GitLab in production frequently leads to hard to diagnose problems. For example, GitLab Shell is called from OpenSSH and having a version manager can prevent pushing and pulling over SSH. Version managers are not supported and we strongly advise everyone to follow the instructions below to use a system ruby. The use of Ruby version managers such as [RVM](http://rvm.io/), [rbenv](https://github.com/sstephenson/rbenv) or [chruby](https://github.com/postmodern/chruby) with GitLab in production frequently leads to hard to diagnose problems. For example, GitLab Shell is called from OpenSSH and having a version manager can prevent pushing and pulling over SSH. Version managers are not supported and we strongly advise everyone to follow the instructions below to use a system Ruby.
Remove the old Ruby 1.8 if present Remove the old Ruby 1.8 if present
......
...@@ -4,15 +4,23 @@ ...@@ -4,15 +4,23 @@
To enable Slack integration you must create an Incoming WebHooks integration on Slack; To enable Slack integration you must create an Incoming WebHooks integration on Slack;
1. Sign in to [Slack](https://slack.com) (https://YOURSUBDOMAIN.slack.com/services) 1. [Sign in to Slack](https://slack.com/signin)
1. Click on the Integrations menu at the top of the page.
1. Add a new Integration. 1. Select **Configure Integrations** from the dropdown next to your team name.
1. Select the **All Services** tab
1. Click **Add** next to Incoming Webhooks
1. Pick Incoming WebHooks 1. Pick Incoming WebHooks
1. Choose the channel name you want to send notifications to, in the Settings section
1. Add Integrations.
- Optional step; You can change bot's name and avatar by clicking "change the name of your bot", and "change the icon" after that you have to click "Save settings".
Now, Slack is ready to get external hooks. Before you leave this page don't forget to get the Token that you'll need on GitLab. You can find it by clicking Expand button, located in the "Instructions for creating Incoming WebHooks" section. It's a random alpha-numeric text 24 characters long. 1. Choose the channel name you want to send notifications to
1. Click **Add Incoming WebHooks Integration**Add Integrations.
- Optional step; You can change bot's name and avatar by clicking modifying the bot name or avatar under **Integration Settings**.
1. Copy the **Webhook URL**, we'll need this later for GitLab.
## On GitLab ## On GitLab
...@@ -26,10 +34,8 @@ After Slack is ready we need to setup GitLab. Here are the steps to achieve this ...@@ -26,10 +34,8 @@ After Slack is ready we need to setup GitLab. Here are the steps to achieve this
1. Fill in your Slack details 1. Fill in your Slack details
- Mark as active it - Mark it as active
- Type your subdomain's prefix (If your subdomain is https://somedomain.slack.com you only have to type the somedomain) - Paste in the webhook url you got from Slack
- Type in the token you got from Slack
- Type in the channel name you want to use (eg. #announcements)
Have fun :) Have fun :)
......
# Import # Import bare repositories into your GitLab instance
## Import bare repositories into GitLab project instance ## Notes
Notes: - The owner of the project will be the first admin
- The groups will be created as needed
- The owner of the group will be the first admin
- Existing projects will be skipped
- project owner will be a first admin ## How to use
- groups will be created as needed
- group owner will be the first admin
- existing projects will be skipped
How to use: ### Create a new folder inside the git repositories path. This will be the name of the new group.
1. copy your bare repos under git repos_path (see `config/gitlab.yml` gitlab_shell -> repos_path) - For omnibus-gitlab, it is located at: `/var/opt/gitlab/git-data/repositories` by default, unless you changed
1. run the command below it in the `/etc/gitlab/gitlab.rb` file.
- For manual installations, it is usually located at: `/home/git/repositories` or you can see where
your repositories are located by looking at `config/gitlab.yml` under the `gitlab_shell => repos_path` entry.
### Copy your bare repositories inside this newly created folder:
```
$ cp -r /old/git/foo.git/ /home/git/repositories/new_group/
```
### Run the command below depending on your type of installation:
#### Omnibus Installation
```
$ sudo gitlab-rake gitlab:import:repos
``` ```
# omnibus-gitlab
sudo gitlab-rake gitlab:import:repos
# installation from source or cookbook #### Manual Installation
bundle exec rake gitlab:import:repos RAILS_ENV=production
Before running this command you need to change the directory to where your GitLab installation is located:
```
$ cd /home/git/gitlab
$ sudo -u git -H bundle exec rake gitlab:import:repos RAILS_ENV=production
``` ```
Example output: #### Example output
``` ```
Processing abcd.git Processing abcd.git
......
# From 6.x or 7.x to 7.3 # From 6.x or 7.x to 7.4
This allows you to upgrade any version of GitLab from 6.0 and up (including 7.0 and up) to 7.3. This allows you to upgrade any version of GitLab from 6.0 and up (including 7.0 and up) to 7.4.
## Global issue numbers ## Global issue numbers
...@@ -70,7 +70,7 @@ sudo -u git -H git checkout -- db/schema.rb # local changes will be restored aut ...@@ -70,7 +70,7 @@ sudo -u git -H git checkout -- db/schema.rb # local changes will be restored aut
For GitLab Community Edition: For GitLab Community Edition:
```bash ```bash
sudo -u git -H git checkout 7-3-stable sudo -u git -H git checkout 7-4-stable
``` ```
OR OR
...@@ -78,7 +78,7 @@ OR ...@@ -78,7 +78,7 @@ OR
For GitLab Enterprise Edition: For GitLab Enterprise Edition:
```bash ```bash
sudo -u git -H git checkout 7-3-stable-ee sudo -u git -H git checkout 7-4-stable-ee
``` ```
## 4. Install additional packages ## 4. Install additional packages
...@@ -154,14 +154,14 @@ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab ...@@ -154,14 +154,14 @@ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
TIP: to see what changed in `gitlab.yml.example` in this release use next command: TIP: to see what changed in `gitlab.yml.example` in this release use next command:
``` ```
git diff 6-0-stable:config/gitlab.yml.example 7-3-stable:config/gitlab.yml.example git diff 6-0-stable:config/gitlab.yml.example 7-4-stable:config/gitlab.yml.example
``` ```
* Make `/home/git/gitlab/config/gitlab.yml` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-3-stable/config/gitlab.yml.example but with your settings. * Make `/home/git/gitlab/config/gitlab.yml` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/config/gitlab.yml.example but with your settings.
* Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-3-stable/config/unicorn.rb.example but with your settings. * Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/config/unicorn.rb.example but with your settings.
* Make `/home/git/gitlab-shell/config.yml` the same as https://gitlab.com/gitlab-org/gitlab-shell/blob/v2.0.1/config.yml.example but with your settings. * Make `/home/git/gitlab-shell/config.yml` the same as https://gitlab.com/gitlab-org/gitlab-shell/blob/v2.0.1/config.yml.example but with your settings.
* HTTP setups: Make `/etc/nginx/sites-available/gitlab` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-3-stable/lib/support/nginx/gitlab but with your settings. * HTTP setups: Make `/etc/nginx/sites-available/gitlab` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab but with your settings.
* HTTPS setups: Make `/etc/nginx/sites-available/gitlab-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-3-stable/lib/support/nginx/gitlab-ssl but with your settings. * HTTPS setups: Make `/etc/nginx/sites-available/gitlab-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your settings.
* Copy rack attack middleware config * Copy rack attack middleware config
```bash ```bash
...@@ -267,6 +267,7 @@ mysql> \q ...@@ -267,6 +267,7 @@ mysql> \q
# Set production -> username: git # Set production -> username: git
# Set production -> password: the password your replaced $password with earlier # Set production -> password: the password your replaced $password with earlier
sudo -u git -H editor /home/git/gitlab/config/database.yml sudo -u git -H editor /home/git/gitlab/config/database.yml
```
## Things went south? Revert to previous version (6.0) ## Things went south? Revert to previous version (6.0)
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
```
### 2. Get latest code ### 2. Get latest code
......
...@@ -26,16 +26,14 @@ sudo -u git -H git checkout LATEST_TAG ...@@ -26,16 +26,14 @@ sudo -u git -H git checkout LATEST_TAG
Replace LATEST_TAG with the latest GitLab tag you want to upgrade to, for example `v6.6.3`. Replace LATEST_TAG with the latest GitLab tag you want to upgrade to, for example `v6.6.3`.
### 3. Update gitlab-shell if it is not the latest version ### 3. Update gitlab-shell to the corresponding version
```bash ```bash
cd /home/git/gitlab-shell cd /home/git/gitlab-shell
sudo -u git -H git fetch sudo -u git -H git fetch
sudo -u git -H git checkout LATEST_TAG sudo -u git -H git checkout v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`
``` ```
Replace LATEST_TAG with the latest GitLab Shell tag you want to upgrade to, for example `v1.7.9`.
### 4. Install libs, migrations, etc. ### 4. Install libs, migrations, etc.
```bash ```bash
......
...@@ -109,12 +109,12 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps ...@@ -109,12 +109,12 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
step 'I fill Slack settings' do step 'I fill Slack settings' do
check 'Active' check 'Active'
fill_in 'Webhook', with: 'https://gitlabhq.slack.com/services/hooks?token=cdIj4r4LfXUOySDUjp0tk3OI' fill_in 'Webhook', with: 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685'
click_button 'Save' click_button 'Save'
end end
step 'I should see Slack service settings saved' do step 'I should see Slack service settings saved' do
find_field('Webhook').value.should == 'https://gitlabhq.slack.com/services/hooks?token=cdIj4r4LfXUOySDUjp0tk3OI' find_field('Webhook').value.should == 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685'
end end
step 'I click Pushover service link' do step 'I click Pushover service link' do
......
...@@ -82,6 +82,7 @@ module API ...@@ -82,6 +82,7 @@ module API
authorize_push_project authorize_push_project
result = CreateBranchService.new(user_project, current_user). result = CreateBranchService.new(user_project, current_user).
execute(params[:branch_name], params[:ref]) execute(params[:branch_name], params[:ref])
if result[:status] == :success if result[:status] == :success
present result[:branch], present result[:branch],
with: Entities::RepoObject, with: Entities::RepoObject,
...@@ -104,7 +105,9 @@ module API ...@@ -104,7 +105,9 @@ module API
execute(params[:branch]) execute(params[:branch])
if result[:status] == :success if result[:status] == :success
true {
branch_name: params[:branch]
}
else else
render_api_error!(result[:message], result[:return_code]) render_api_error!(result[:message], result[:return_code])
end end
......
...@@ -73,6 +73,25 @@ module API ...@@ -73,6 +73,25 @@ module API
end end
end end
class RepoTag < Grape::Entity
expose :name
expose :message do |repo_obj, _options|
if repo_obj.respond_to?(:message)
repo_obj.message
else
nil
end
end
expose :commit do |repo_obj, options|
if repo_obj.respond_to?(:commit)
repo_obj.commit
elsif options[:project]
options[:project].repository.commit(repo_obj.target)
end
end
end
class RepoObject < Grape::Entity class RepoObject < Grape::Entity
expose :name expose :name
...@@ -164,6 +183,12 @@ module API ...@@ -164,6 +183,12 @@ module API
expose :target_id, :target_type, :author_id expose :target_id, :target_type, :author_id
expose :data, :target_title expose :data, :target_title
expose :created_at expose :created_at
expose :author_username do |event, options|
if event.author
event.author.username
end
end
end end
class Namespace < Grape::Entity class Namespace < Grape::Entity
......
...@@ -23,7 +23,8 @@ module API ...@@ -23,7 +23,8 @@ module API
# Example Request: # Example Request:
# GET /projects/:id/repository/tags # GET /projects/:id/repository/tags
get ":id/repository/tags" do get ":id/repository/tags" do
present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject, project: user_project present user_project.repo.tags.sort_by(&:name).reverse,
with: Entities::RepoTag, project: user_project
end end
# Create tag # Create tag
...@@ -43,7 +44,7 @@ module API ...@@ -43,7 +44,7 @@ module API
if result[:status] == :success if result[:status] == :success
present result[:tag], present result[:tag],
with: Entities::RepoObject, with: Entities::RepoTag,
project: user_project project: user_project
else else
render_api_error!(result[:message], 400) render_api_error!(result[:message], 400)
......
...@@ -16,7 +16,7 @@ module Gitlab ...@@ -16,7 +16,7 @@ module Gitlab
# add_repository("gitlab/gitlab-ci") # add_repository("gitlab/gitlab-ci")
# #
def add_repository(name) def add_repository(name)
system "#{gitlab_shell_path}/bin/gitlab-projects", "add-project", "#{name}.git" system gitlab_shell_projects_path, 'add-project', "#{name}.git"
end end
# Import repository # Import repository
...@@ -27,7 +27,7 @@ module Gitlab ...@@ -27,7 +27,7 @@ module Gitlab
# import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git") # import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git")
# #
def import_repository(name, url) def import_repository(name, url)
system "#{gitlab_shell_path}/bin/gitlab-projects", "import-project", "#{name}.git", url, '240' system gitlab_shell_projects_path, 'import-project', "#{name}.git", url, '240'
end end
# Move repository # Move repository
...@@ -39,7 +39,7 @@ module Gitlab ...@@ -39,7 +39,7 @@ module Gitlab
# mv_repository("gitlab/gitlab-ci", "randx/gitlab-ci-new.git") # mv_repository("gitlab/gitlab-ci", "randx/gitlab-ci-new.git")
# #
def mv_repository(path, new_path) def mv_repository(path, new_path)
system "#{gitlab_shell_path}/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git" system gitlab_shell_projects_path, 'mv-project', "#{path}.git", "#{new_path}.git"
end end
# Update HEAD for repository # Update HEAD for repository
...@@ -51,7 +51,7 @@ module Gitlab ...@@ -51,7 +51,7 @@ module Gitlab
# update_repository_head("gitlab/gitlab-ci", "3-1-stable") # update_repository_head("gitlab/gitlab-ci", "3-1-stable")
# #
def update_repository_head(path, branch) def update_repository_head(path, branch)
system "#{gitlab_shell_path}/bin/gitlab-projects", "update-head", "#{path}.git", branch system gitlab_shell_projects_path, 'update-head', "#{path}.git", branch
end end
# Fork repository to new namespace # Fork repository to new namespace
...@@ -63,7 +63,7 @@ module Gitlab ...@@ -63,7 +63,7 @@ module Gitlab
# fork_repository("gitlab/gitlab-ci", "randx") # fork_repository("gitlab/gitlab-ci", "randx")
# #
def fork_repository(path, fork_namespace) def fork_repository(path, fork_namespace)
system "#{gitlab_shell_path}/bin/gitlab-projects", "fork-project", "#{path}.git", fork_namespace system gitlab_shell_projects_path, 'fork-project', "#{path}.git", fork_namespace
end end
# Remove repository from file system # Remove repository from file system
...@@ -74,7 +74,7 @@ module Gitlab ...@@ -74,7 +74,7 @@ module Gitlab
# remove_repository("gitlab/gitlab-ci") # remove_repository("gitlab/gitlab-ci")
# #
def remove_repository(name) def remove_repository(name)
system "#{gitlab_shell_path}/bin/gitlab-projects", "rm-project", "#{name}.git" system gitlab_shell_projects_path, 'rm-project', "#{name}.git"
end end
# Add repository branch from passed ref # Add repository branch from passed ref
...@@ -87,7 +87,7 @@ module Gitlab ...@@ -87,7 +87,7 @@ module Gitlab
# add_branch("gitlab/gitlab-ci", "4-0-stable", "master") # add_branch("gitlab/gitlab-ci", "4-0-stable", "master")
# #
def add_branch(path, branch_name, ref) def add_branch(path, branch_name, ref)
system "#{gitlab_shell_path}/bin/gitlab-projects", "create-branch", "#{path}.git", branch_name, ref system gitlab_shell_projects_path, 'create-branch', "#{path}.git", branch_name, ref
end end
# Remove repository branch # Remove repository branch
...@@ -99,7 +99,7 @@ module Gitlab ...@@ -99,7 +99,7 @@ module Gitlab
# rm_branch("gitlab/gitlab-ci", "4-0-stable") # rm_branch("gitlab/gitlab-ci", "4-0-stable")
# #
def rm_branch(path, branch_name) def rm_branch(path, branch_name)
system "#{gitlab_shell_path}/bin/gitlab-projects", "rm-branch", "#{path}.git", branch_name system gitlab_shell_projects_path, 'rm-branch', "#{path}.git", branch_name
end end
# Add repository tag from passed ref # Add repository tag from passed ref
...@@ -129,7 +129,7 @@ module Gitlab ...@@ -129,7 +129,7 @@ module Gitlab
# rm_tag("gitlab/gitlab-ci", "v4.0") # rm_tag("gitlab/gitlab-ci", "v4.0")
# #
def rm_tag(path, tag_name) def rm_tag(path, tag_name)
system "#{gitlab_shell_path}/bin/gitlab-projects", "rm-tag", "#{path}.git", tag_name system gitlab_shell_projects_path, 'rm-tag', "#{path}.git", tag_name
end end
# Add new key to gitlab-shell # Add new key to gitlab-shell
...@@ -138,7 +138,7 @@ module Gitlab ...@@ -138,7 +138,7 @@ module Gitlab
# add_key("key-42", "sha-rsa ...") # add_key("key-42", "sha-rsa ...")
# #
def add_key(key_id, key_content) def add_key(key_id, key_content)
system "#{gitlab_shell_path}/bin/gitlab-keys", "add-key", key_id, key_content system gitlab_shell_keys_path, 'add-key', key_id, key_content
end end
# Batch-add keys to authorized_keys # Batch-add keys to authorized_keys
...@@ -157,7 +157,7 @@ module Gitlab ...@@ -157,7 +157,7 @@ module Gitlab
# remove_key("key-342", "sha-rsa ...") # remove_key("key-342", "sha-rsa ...")
# #
def remove_key(key_id, key_content) def remove_key(key_id, key_content)
system "#{gitlab_shell_path}/bin/gitlab-keys", "rm-key", key_id, key_content system gitlab_shell_keys_path, 'rm-key', key_id, key_content
end end
# Remove all ssh keys from gitlab shell # Remove all ssh keys from gitlab shell
...@@ -166,7 +166,7 @@ module Gitlab ...@@ -166,7 +166,7 @@ module Gitlab
# remove_all_keys # remove_all_keys
# #
def remove_all_keys def remove_all_keys
system "#{gitlab_shell_path}/bin/gitlab-keys", "clear" system gitlab_shell_keys_path, 'clear'
end end
# Add empty directory for storing repositories # Add empty directory for storing repositories
...@@ -249,5 +249,13 @@ module Gitlab ...@@ -249,5 +249,13 @@ module Gitlab
def exists?(dir_name) def exists?(dir_name)
File.exists?(full_path(dir_name)) File.exists?(full_path(dir_name))
end end
def gitlab_shell_projects_path
File.join(gitlab_shell_path, 'bin', 'gitlab-projects')
end
def gitlab_shell_keys_path
File.join(gitlab_shell_path, 'bin', 'gitlab-keys')
end
end end
end end
...@@ -15,7 +15,6 @@ module Gitlab ...@@ -15,7 +15,6 @@ module Gitlab
{ title: "support", color: yellow }, { title: "support", color: yellow },
{ title: "discussion", color: blue }, { title: "discussion", color: blue },
{ title: "suggestion", color: blue }, { title: "suggestion", color: blue },
{ title: "feature", color: green },
{ title: "enhancement", color: green } { title: "enhancement", color: green }
] ]
......
require_relative '../../app/models/project_services/slack_message' require 'spec_helper'
describe SlackMessage do describe SlackMessage do
subject { SlackMessage.new(args) } subject { SlackMessage.new(args) }
......
...@@ -31,71 +31,27 @@ describe SlackService do ...@@ -31,71 +31,27 @@ describe SlackService do
end end
describe "Execute" do describe "Execute" do
let(:slack) { SlackService.new } let(:slack) { SlackService.new }
let(:slack_service) { SlackService.new } let(:user) { create(:user) }
let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:sample_data) { GitPushService.new.sample_data(project, user) } let(:sample_data) { GitPushService.new.sample_data(project, user) }
let(:webhook) { 'https://gitlabhq.slack.com/services/hooks?token=cdIj4r4LfXUOySDUjp0tk3OI' } let(:webhook_url) { 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' }
let(:new_webhook) { 'https://hooks.gitlabhq.slack.com/services/cdIj4r4LfXUOySDUjp0tk3OI' }
let(:api_url) {
'https://gitlabhq.slack.com/services/hooks/incoming-webhook?token=cdIj4r4LfXUOySDUjp0tk3OI'
}
before do before do
slack.stub( slack.stub(
project: project, project: project,
project_id: project.id, project_id: project.id,
service_hook: true, service_hook: true,
webhook: webhook webhook: webhook_url
) )
WebMock.stub_request(:post, api_url) WebMock.stub_request(:post, webhook_url)
end end
it "should call Slack API" do it "should call Slack API" do
slack.execute(sample_data) slack.execute(sample_data)
WebMock.should have_requested(:post, api_url).once WebMock.should have_requested(:post, webhook_url).once
end
context 'with new webhook syntax' do
before do
slack_service.stub(
project: project,
project_id: project.id,
service_hook: true,
webhook: new_webhook
)
WebMock.stub_request(:post, api_url)
end
it "should call Slack API" do
slack_service.execute(sample_data)
WebMock.should have_requested(:post, api_url).once
end
end
context 'with new webhook syntax with slack allowed team name' do
before do
@allowed_webhook = 'https://gitlab-hq-123.slack.com/services/hooks/incoming-webhook?token=cdIj4r4LfXUOySDUjp0tk3OI'
slack_service.stub(
project: project,
project_id: project.id,
service_hook: true,
webhook: @allowed_webhook
)
WebMock.stub_request(:post, @allowed_webhook)
end
it "should call Slack API" do
slack_service.execute(sample_data)
WebMock.should have_requested(:post, @allowed_webhook).once
end
end end
end end
end end
...@@ -146,6 +146,7 @@ describe API::API, api: true do ...@@ -146,6 +146,7 @@ describe API::API, api: true do
it "should remove branch" do it "should remove branch" do
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user) delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
response.status.should == 200 response.status.should == 200
json_response['branch_name'].should == branch_name
end end
it 'should return 404 if branch not exists' do it 'should return 404 if branch not exists' do
......
...@@ -339,6 +339,7 @@ describe API::API, api: true do ...@@ -339,6 +339,7 @@ describe API::API, api: true do
json_event['action_name'].should == 'joined' json_event['action_name'].should == 'joined'
json_event['project_id'].to_i.should == project.id json_event['project_id'].to_i.should == project.id
json_event['author_username'].should == user.username
end end
it "should return a 404 error if not found" do it "should return a 404 error if not found" do
......
...@@ -34,21 +34,24 @@ describe API::API, api: true do ...@@ -34,21 +34,24 @@ describe API::API, api: true do
end end
end end
# TODO: fix this test for CI context 'annotated tag' do
#context 'annotated tag' do it 'should create a new annotated tag' do
#it 'should create a new annotated tag' do # Identity must be set in .gitconfig to create annotated tag.
#post api("/projects/#{project.id}/repository/tags", user), repo_path = File.join(Gitlab.config.gitlab_shell.repos_path,
#tag_name: 'v7.1.0', project.path_with_namespace + '.git')
#ref: 'master', system(*%W(git --git-dir=#{repo_path} config user.name #{user.name}))
#message: 'tag message' system(*%W(git --git-dir=#{repo_path} config user.email #{user.email}))
#response.status.should == 201 post api("/projects/#{project.id}/repository/tags", user),
#json_response['name'].should == 'v7.1.0' tag_name: 'v7.1.0',
# The message is not part of the JSON response. ref: 'master',
# Additional changes to the gitlab_git gem may be required. message: 'Release 7.1.0'
# json_response['message'].should == 'tag message'
#end response.status.should == 201
#end json_response['name'].should == 'v7.1.0'
json_response['message'].should == 'Release 7.1.0'
end
end
it 'should deny for user without push access' do it 'should deny for user without push access' do
post api("/projects/#{project.id}/repository/tags", user2), post api("/projects/#{project.id}/repository/tags", user2),
......
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