Commit 2674a14b authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into spread-runner-last-updated-at

parents 63cafdb8 86c0d8d2
...@@ -13,9 +13,13 @@ v 8.2.0 (unreleased) ...@@ -13,9 +13,13 @@ v 8.2.0 (unreleased)
- Fix: Inability to reply to code comments in the MR view, if the MR comes from a fork - Fix: Inability to reply to code comments in the MR view, if the MR comes from a fork
- Use git follow flag for commits page when retrieve history for file or directory - Use git follow flag for commits page when retrieve history for file or directory
- Show merge request CI status on merge requests index page - Show merge request CI status on merge requests index page
- Extend yml syntax for only and except to support specifying repository path
- Fix: 500 error returned if destroy request without HTTP referer (Kazuki Shimizu) - Fix: 500 error returned if destroy request without HTTP referer (Kazuki Shimizu)
- Remove deprecated CI events from project settings page - Remove deprecated CI events from project settings page
- Use issue editor as cross reference comment author when issue is edited with a new mention. - Use issue editor as cross reference comment author when issue is edited with a new mention.
- [API] Add ability to fetch the commit ID of the last commit that actually touched a file
- Add "New file" link to dropdown on project page
- Include commit logs in project search
v 8.1.3 v 8.1.3
- Spread out runner contacted_at updates - Spread out runner contacted_at updates
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
} }
li.commit { li.commit {
list-style: none;
.commit-row-title { .commit-row-title {
font-size: $list-font-size; font-size: $list-font-size;
line-height: 20px; line-height: 20px;
......
class ProjectsController < ApplicationController class ProjectsController < ApplicationController
include ExtractsPath include ExtractsPath
prepend_before_filter :render_go_import, only: [:show] prepend_before_action :render_go_import, only: [:show]
skip_before_action :authenticate_user!, only: [:show, :activity] skip_before_action :authenticate_user!, only: [:show, :activity]
before_action :project, except: [:new, :create] before_action :project, except: [:new, :create]
before_action :repository, except: [:new, :create] before_action :repository, except: [:new, :create]
......
...@@ -23,8 +23,8 @@ class SearchController < ApplicationController ...@@ -23,8 +23,8 @@ class SearchController < ApplicationController
@search_results = @search_results =
if @project if @project
unless %w(blobs notes issues merge_requests milestones wiki_blobs). unless %w(blobs notes issues merge_requests milestones wiki_blobs
include?(@scope) commits).include?(@scope)
@scope = 'blobs' @scope = 'blobs'
end end
......
...@@ -187,7 +187,7 @@ module Ci ...@@ -187,7 +187,7 @@ module Ci
end end
def config_processor def config_processor
@config_processor ||= Ci::GitlabCiYamlProcessor.new(ci_yaml_file) @config_processor ||= Ci::GitlabCiYamlProcessor.new(ci_yaml_file, gl_project.path_with_namespace)
rescue Ci::GitlabCiYamlProcessor::ValidationError => e rescue Ci::GitlabCiYamlProcessor::ValidationError => e
save_yaml_error(e.message) save_yaml_error(e.message)
nil nil
......
...@@ -87,6 +87,15 @@ class Repository ...@@ -87,6 +87,15 @@ class Repository
commits commits
end end
def find_commits_by_message(query)
# Limited to 1000 commits for now, could be parameterized?
args = %W(git log --pretty=%H --max-count 1000 --grep=#{query})
git_log_results = Gitlab::Popen.popen(args, path_to_repo).first.lines.map(&:chomp)
commits = git_log_results.map { |c| commit(c) }
commits
end
def find_branch(name) def find_branch(name)
branches.find { |branch| branch.name == name } branches.find { |branch| branch.name == name }
end end
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
= hidden_field_tag :scope, 'merge_requests' = hidden_field_tag :scope, 'merge_requests'
- elsif current_controller?(:wikis) - elsif current_controller?(:wikis)
= hidden_field_tag :scope, 'wiki_blobs' = hidden_field_tag :scope, 'wiki_blobs'
- elsif current_controller?(:commits)
= hidden_field_tag :scope, 'commits'
- else - else
= hidden_field_tag :search_code, true = hidden_field_tag :search_code, true
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
New snippet New snippet
- if can?(current_user, :push_code, @project) - if can?(current_user, :push_code, @project)
%li.divider %li.divider
%li
= link_to namespace_project_new_blob_path(@project.namespace, @project, @project.default_branch || 'master'), title: 'New file' do
= icon('file fw')
New file
%li %li
= link_to new_namespace_project_branch_path(@project.namespace, @project) do = link_to new_namespace_project_branch_path(@project.namespace, @project) do
= icon('code-fork fw') = icon('code-fork fw')
......
...@@ -42,6 +42,13 @@ ...@@ -42,6 +42,13 @@
Wiki Wiki
%span.badge %span.badge
= @search_results.wiki_blobs_count = @search_results.wiki_blobs_count
%li{class: ("active" if @scope == 'commits')}
= link_to search_filter_path(scope: 'commits') do
= icon('history fw')
%span
Commits
%span.badge
= @search_results.commits_count
- elsif @show_snippets - elsif @show_snippets
%li{class: ("active" if @scope == 'snippet_blobs')} %li{class: ("active" if @scope == 'snippet_blobs')}
......
.search-result-row
= render 'projects/commits/commit', project: @project, commit: commit
...@@ -8,24 +8,3 @@ ...@@ -8,24 +8,3 @@
# inflect.irregular 'person', 'people' # inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep ) # inflect.uncountable %w( fish sheep )
# end # end
# Mark "commits" as uncountable.
#
# Without this change, the routes
#
# resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
# resources :commits, only: [:show], constraints: {id: /.+/}
#
# would generate identical route helper methods (`project_commit_path`), resulting
# in one of them not getting a helper method at all.
#
# After this change, the helper methods are:
#
# project_commit_path(@project, @project.commit)
# # => "/gitlabhq/commit/bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a
#
# project_commits_path(@project, 'stable/README.md')
# # => "/gitlabhq/commits/stable/README.md"
ActiveSupport::Inflector.inflections do |inflect|
inflect.uncountable %w(commits)
end
...@@ -23,7 +23,8 @@ Example response: ...@@ -23,7 +23,8 @@ Example response:
"content": "IyA9PSBTY2hlbWEgSW5mb3...", "content": "IyA9PSBTY2hlbWEgSW5mb3...",
"ref": "master", "ref": "master",
"blob_id": "79f7bbd25901e8334750839545a9bd021f0e4c83", "blob_id": "79f7bbd25901e8334750839545a9bd021f0e4c83",
"commit_id": "d5a3ff139356ce33e37e73add446f16869741b50" "commit_id": "d5a3ff139356ce33e37e73add446f16869741b50",
"last_commit_id": "570e7b2abdd848b95f2f578043fc23bd6f6fd24d"
} }
``` ```
......
# Build script examples # Build script examples
+ [Test and deploy Ruby applications to Heroku](test-and-deploy-ruby-application-to-heroku.md) + [Test and deploy a Ruby application to Heroku](test-and-deploy-ruby-application-to-heroku.md)
+ [Test and deploy Python applications to Heroku](test-and-deploy-python-application-to-heroku.md) + [Test and deploy a Python application to Heroku](test-and-deploy-python-application-to-heroku.md)
+ [Test Clojure applications](test-clojure-application.md) + [Test a Clojure application](test-clojure-application.md)
## Test and Deploy a python application ## Test and Deploy a python application
This example will guide you how to run tests in your Python application and deploy it automatically as Heroku application. This example will guide you how to run tests in your Python application and deploy it automatically as Heroku application.
You can checkout the example [source](https://gitlab.com/ayufan/python-getting-started) and check [CI status](https://ci.gitlab.com/projects/4080). You can checkout the example [source](https://gitlab.com/ayufan/python-getting-started) and check [CI status](https://gitlab.com/ayufan/python-getting-started/builds?scope=all).
### Configure project ### Configure project
This is what the `.gitlab-ci.yml` file looks like for this project: This is what the `.gitlab-ci.yml` file looks like for this project:
......
## Test and Deploy a ruby application ## Test and Deploy a ruby application
This example will guide you how to run tests in your Ruby application and deploy it automatiacally as Heroku application. This example will guide you how to run tests in your Ruby application and deploy it automatiacally as Heroku application.
You can checkout the example [source](https://gitlab.com/ayufan/ruby-getting-started) and check [CI status](https://ci.gitlab.com/projects/4050). You can checkout the example [source](https://gitlab.com/ayufan/ruby-getting-started) and check [CI status](https://gitlab.com/ayufan/ruby-getting-started/builds?scope=all).
### Configure project ### Configure project
This is what the `.gitlab-ci.yml` file looks like for this project: This is what the `.gitlab-ci.yml` file looks like for this project:
......
## Test Clojure applications ## Test a Clojure application
This example will guide you how to run tests in your Clojure application. This example will guide you how to run tests in your Clojure application.
You can checkout the example [source](https://gitlab.com/dzaporozhets/clojure-web-application) and check [CI status](https://ci.gitlab.com/projects/6306). You can checkout the example [source](https://gitlab.com/dzaporozhets/clojure-web-application) and check [CI status](https://gitlab.com/dzaporozhets/clojure-web-application/builds?scope=all).
### Configure project ### Configure project
......
...@@ -169,7 +169,7 @@ This are two parameters that allow for setting a refs policy to limit when jobs ...@@ -169,7 +169,7 @@ This are two parameters that allow for setting a refs policy to limit when jobs
There are a few rules that apply to usage of refs policy: There are a few rules that apply to usage of refs policy:
1. `only` and `except` are exclusive. If both `only` and `except` are defined in job specification only `only` is taken into account. 1. `only` and `except` are inclusive. If both `only` and `except` are defined in job specification the ref is filtered by `only` and `except`.
1. `only` and `except` allow for using the regexp expressions. 1. `only` and `except` allow for using the regexp expressions.
1. `only` and `except` allow for using special keywords: `branches` and `tags`. 1. `only` and `except` allow for using special keywords: `branches` and `tags`.
These names can be used for example to exclude all tags and all branches. These names can be used for example to exclude all tags and all branches.
...@@ -182,6 +182,18 @@ job: ...@@ -182,6 +182,18 @@ job:
- branches # use special keyword - branches # use special keyword
``` ```
1. `only` and `except` allow for specify repository path to filter jobs for forks.
The repository path can be used to have jobs executed only for parent repository.
```yaml
job:
only:
- branches@gitlab-org/gitlab-ce
except:
- master@gitlab-org/gitlab-ce
```
The above will run `job` for all branches on `gitlab-org/gitlab-ce`, except master .
### tags ### tags
`tags` is used to select specific runners from the list of all runners that are allowed to run this project. `tags` is used to select specific runners from the list of all runners that are allowed to run this project.
......
...@@ -43,7 +43,8 @@ module API ...@@ -43,7 +43,8 @@ module API
# "content": "IyA9PSBTY2hlbWEgSW5mb3...", # "content": "IyA9PSBTY2hlbWEgSW5mb3...",
# "ref": "master", # "ref": "master",
# "blob_id": "79f7bbd25901e8334750839545a9bd021f0e4c83", # "blob_id": "79f7bbd25901e8334750839545a9bd021f0e4c83",
# "commit_id": "d5a3ff139356ce33e37e73add446f16869741b50" # "commit_id": "d5a3ff139356ce33e37e73add446f16869741b50",
# "last_commit_id": "570e7b2abdd848b95f2f578043fc23bd6f6fd24d",
# } # }
# #
get ":id/repository/files" do get ":id/repository/files" do
...@@ -71,6 +72,7 @@ module API ...@@ -71,6 +72,7 @@ module API
ref: ref, ref: ref,
blob_id: blob.id, blob_id: blob.id,
commit_id: commit.id, commit_id: commit.id,
last_commit_id: user_project.repository.last_commit_for_path(commit.sha, file_path).id
} }
else else
not_found! 'File' not_found! 'File'
......
require 'backup/files'
module Backup module Backup
class Builds < Files class Builds < Files
def initialize def initialize
......
require 'backup/files'
module Backup module Backup
class Uploads < Files class Uploads < Files
......
...@@ -7,10 +7,11 @@ module Ci ...@@ -7,10 +7,11 @@ module Ci
ALLOWED_YAML_KEYS = [:before_script, :image, :services, :types, :stages, :variables] ALLOWED_YAML_KEYS = [:before_script, :image, :services, :types, :stages, :variables]
ALLOWED_JOB_KEYS = [:tags, :script, :only, :except, :type, :image, :services, :allow_failure, :type, :stage, :when] ALLOWED_JOB_KEYS = [:tags, :script, :only, :except, :type, :image, :services, :allow_failure, :type, :stage, :when]
attr_reader :before_script, :image, :services, :variables attr_reader :before_script, :image, :services, :variables, :path
def initialize(config) def initialize(config, path = nil)
@config = YAML.load(config) @config = YAML.load(config)
@path = path
unless @config.is_a? Hash unless @config.is_a? Hash
raise ValidationError, "YAML should be a hash" raise ValidationError, "YAML should be a hash"
...@@ -63,26 +64,6 @@ module Ci ...@@ -63,26 +64,6 @@ module Ci
end end
end end
def process?(only_params, except_params, ref, tag)
return true if only_params.nil? && except_params.nil?
if only_params
return true if tag && only_params.include?("tags")
return true if !tag && only_params.include?("branches")
only_params.find do |pattern|
match_ref?(pattern, ref)
end
else
return false if tag && except_params.include?("tags")
return false if !tag && except_params.include?("branches")
except_params.each do |pattern|
return false if match_ref?(pattern, ref)
end
end
end
def build_job(name, job) def build_job(name, job)
{ {
stage_idx: stages.index(job[:stage]), stage_idx: stages.index(job[:stage]),
...@@ -101,14 +82,6 @@ module Ci ...@@ -101,14 +82,6 @@ module Ci
} }
end end
def match_ref?(pattern, ref)
if pattern.first == "/" && pattern.last == "/"
Regexp.new(pattern[1...-1]) =~ ref
else
pattern == ref
end
end
def normalize_script(script) def normalize_script(script)
if script.is_a? Array if script.is_a? Array
script.join("\n") script.join("\n")
...@@ -208,5 +181,36 @@ module Ci ...@@ -208,5 +181,36 @@ module Ci
def validate_string(value) def validate_string(value)
value.is_a?(String) || value.is_a?(Symbol) value.is_a?(String) || value.is_a?(Symbol)
end end
def process?(only_params, except_params, ref, tag)
if only_params.present?
return false unless matching?(only_params, ref, tag)
end
if except_params.present?
return false if matching?(except_params, ref, tag)
end
true
end
def matching?(patterns, ref, tag)
patterns.any? do |pattern|
match_ref?(pattern, ref, tag)
end
end
def match_ref?(pattern, ref, tag)
pattern, path = pattern.split('@', 2)
return false if path && path != self.path
return true if tag && pattern == 'tags'
return true if !tag && pattern == 'branches'
if pattern.first == "/" && pattern.last == "/"
Regexp.new(pattern[1...-1]) =~ ref
else
pattern == ref
end
end
end end
end end
...@@ -20,6 +20,8 @@ module Gitlab ...@@ -20,6 +20,8 @@ module Gitlab
Kaminari.paginate_array(blobs).page(page).per(per_page) Kaminari.paginate_array(blobs).page(page).per(per_page)
when 'wiki_blobs' when 'wiki_blobs'
Kaminari.paginate_array(wiki_blobs).page(page).per(per_page) Kaminari.paginate_array(wiki_blobs).page(page).per(per_page)
when 'commits'
Kaminari.paginate_array(commits).page(page).per(per_page)
else else
super super
end end
...@@ -27,7 +29,7 @@ module Gitlab ...@@ -27,7 +29,7 @@ module Gitlab
def total_count def total_count
@total_count ||= issues_count + merge_requests_count + blobs_count + @total_count ||= issues_count + merge_requests_count + blobs_count +
notes_count + wiki_blobs_count notes_count + wiki_blobs_count + commits_count
end end
def blobs_count def blobs_count
...@@ -42,6 +44,10 @@ module Gitlab ...@@ -42,6 +44,10 @@ module Gitlab
@wiki_blobs_count ||= wiki_blobs.count @wiki_blobs_count ||= wiki_blobs.count
end end
def commits_count
@commits_count ||= commits.count
end
private private
def blobs def blobs
...@@ -70,6 +76,14 @@ module Gitlab ...@@ -70,6 +76,14 @@ module Gitlab
Note.where(project_id: limit_project_ids).user.search(query).order('updated_at DESC') Note.where(project_id: limit_project_ids).user.search(query).order('updated_at DESC')
end end
def commits
if project.empty_repo? || query.blank?
[]
else
project.repository.find_commits_by_message(query).compact
end
end
def limit_project_ids def limit_project_ids
[project.id] [project.id]
end end
......
...@@ -5,7 +5,7 @@ namespace :spinach do ...@@ -5,7 +5,7 @@ namespace :spinach do
task :project do task :project do
cmds = [ cmds = [
%W(rake gitlab:setup), %W(rake gitlab:setup),
%W(spinach --tags ~@admin,~@dashboard,~@profile,~@public,~@snippets), %W(spinach --tags ~@admin,~@dashboard,~@profile,~@public,~@snippets,~@commits),
] ]
run_commands(cmds) run_commands(cmds)
end end
...@@ -14,7 +14,7 @@ namespace :spinach do ...@@ -14,7 +14,7 @@ namespace :spinach do
task :other do task :other do
cmds = [ cmds = [
%W(rake gitlab:setup), %W(rake gitlab:setup),
%W(spinach --tags @admin,@dashboard,@profile,@public,@snippets), %W(spinach --tags @admin,@dashboard,@profile,@public,@snippets,@commits),
] ]
run_commands(cmds) run_commands(cmds)
end end
......
...@@ -468,7 +468,7 @@ describe Notify do ...@@ -468,7 +468,7 @@ describe Notify do
subject { Notify.note_commit_email(recipient.id, note.id) } subject { Notify.note_commit_email(recipient.id, note.id) }
it_behaves_like 'a note email' it_behaves_like 'a note email'
it_behaves_like 'an answer to an existing thread', 'commits' it_behaves_like 'an answer to an existing thread', 'commit'
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_subject /#{commit.title} \(#{commit.short_id}\)/ is_expected.to have_subject /#{commit.title} \(#{commit.short_id}\)/
......
...@@ -26,6 +26,15 @@ describe Repository do ...@@ -26,6 +26,15 @@ describe Repository do
it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') } it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') }
end end
describe :find_commits_by_message do
subject { repository.find_commits_by_message('submodule').map{ |k| k.id } }
it { is_expected.to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
it { is_expected.to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
it { is_expected.to include('cfe32cf61b73a0d5e9f13e774abde7ff789b1660') }
it { is_expected.not_to include('913c66a37b4a45b9769037c55c2d238bd0942d2e') }
end
describe :blob_at do describe :blob_at do
context 'blank sha' do context 'blank sha' do
subject { repository.blob_at(Gitlab::Git::BLANK_SHA, '.gitignore') } subject { repository.blob_at(Gitlab::Git::BLANK_SHA, '.gitignore') }
......
...@@ -19,6 +19,7 @@ describe API::API, api: true do ...@@ -19,6 +19,7 @@ describe API::API, api: true do
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response['file_path']).to eq(file_path) expect(json_response['file_path']).to eq(file_path)
expect(json_response['file_name']).to eq('popen.rb') expect(json_response['file_name']).to eq('popen.rb')
expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
expect(Base64.decode64(json_response['content']).lines.first).to eq("require 'fileutils'\n") expect(Base64.decode64(json_response['content']).lines.first).to eq("require 'fileutils'\n")
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