Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e1e6dd76
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e1e6dd76
编写于
2月 29, 2016
作者:
A
Achilleas Pipinellis
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into ci_examples
上级
cbd9f1bc
17251cf4
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
290 addition
and
46 deletion
+290
-46
CHANGELOG
CHANGELOG
+6
-3
app/models/project.rb
app/models/project.rb
+1
-4
app/models/repository.rb
app/models/repository.rb
+40
-9
app/services/git_push_service.rb
app/services/git_push_service.rb
+3
-3
app/services/git_tag_push_service.rb
app/services/git_tag_push_service.rb
+1
-1
app/services/projects/destroy_service.rb
app/services/projects/destroy_service.rb
+2
-4
app/validators/url_validator.rb
app/validators/url_validator.rb
+3
-0
app/workers/repository_fork_worker.rb
app/workers/repository_fork_worker.rb
+1
-1
app/workers/repository_import_worker.rb
app/workers/repository_import_worker.rb
+1
-1
doc/development/README.md
doc/development/README.md
+6
-5
doc/development/gotchas.md
doc/development/gotchas.md
+103
-0
doc/permissions/permissions.md
doc/permissions/permissions.md
+1
-1
spec/features/issues/filter_by_milestone_spec.rb
spec/features/issues/filter_by_milestone_spec.rb
+2
-2
spec/models/hooks/project_hook_spec.rb
spec/models/hooks/project_hook_spec.rb
+4
-0
spec/models/hooks/web_hook_spec.rb
spec/models/hooks/web_hook_spec.rb
+10
-10
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+106
-2
未找到文件。
CHANGELOG
浏览文件 @
e1e6dd76
...
...
@@ -3,6 +3,12 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.6.0 (unreleased)
- Improve the formatting for the user page bio (Connor Shea)
- Fix avatar stretching by providing a cropping feature (Johann Pardanaud)
- Strip leading and trailing spaces in URL validator (evuez)
- Update documentation to reflect Guest role not being enforced on internal projects
v 8.5.2
- Fix sidebar overlapping content when screen width was below 1200px
- Fix error 500 when commenting on a commit
v 8.5.1
- Fix group projects styles
...
...
@@ -23,9 +29,6 @@ v 8.5.1
- Update sentry-raven gem to 0.15.6
- Add build coverage in project's builds page (Steffen Köhler)
v 8.5.2
- Fix error 500 when commenting on a commit
v 8.5.0
- Fix duplicate "me" in tooltip of the "thumbsup" awards Emoji (Stan Hu)
- Cache various Repository methods to improve performance (Yorick Peterse)
...
...
app/models/project.rb
浏览文件 @
e1e6dd76
...
...
@@ -801,10 +801,7 @@ class Project < ActiveRecord::Base
end
def
change_head
(
branch
)
# Cached divergent commit counts are based on repository head
repository
.
expire_branch_cache
repository
.
expire_root_ref_cache
repository
.
before_change_head
gitlab_shell
.
update_repository_head
(
self
.
path_with_namespace
,
branch
)
reload_default_branch
end
...
...
app/models/repository.rb
浏览文件 @
e1e6dd76
...
...
@@ -245,15 +245,6 @@ class Repository
expire_emptiness_caches
if
empty?
end
# Expires _all_ caches, including those that would normally only be expired
# under specific conditions.
def
expire_all_caches!
expire_cache
expire_root_ref_cache
expire_emptiness_caches
expire_has_visible_content_cache
end
def
expire_branch_cache
(
branch_name
=
nil
)
# When we push to the root branch we have to flush the cache for all other
# branches as their statistics are based on the commits relative to the
...
...
@@ -307,6 +298,46 @@ class Repository
cache
.
expire
(
:branch_names
)
end
# Runs code just before a repository is deleted.
def
before_delete
expire_cache
if
exists?
expire_root_ref_cache
expire_emptiness_caches
end
# Runs code just before the HEAD of a repository is changed.
def
before_change_head
# Cached divergent commit counts are based on repository head
expire_branch_cache
expire_root_ref_cache
end
# Runs code before creating a new tag.
def
before_create_tag
expire_cache
end
# Runs code after a repository has been forked/imported.
def
after_import
expire_emptiness_caches
end
# Runs code after a new commit has been pushed.
def
after_push_commit
(
branch_name
)
expire_cache
(
branch_name
)
end
# Runs code after a new branch has been created.
def
after_create_branch
expire_has_visible_content_cache
end
# Runs code after an existing branch has been removed.
def
after_remove_branch
expire_has_visible_content_cache
end
def
method_missing
(
m
,
*
args
,
&
block
)
if
m
==
:lookup
&&
!
block_given?
lookup_cache
[
m
]
||=
{}
...
...
app/services/git_push_service.rb
浏览文件 @
e1e6dd76
...
...
@@ -16,13 +16,13 @@ class GitPushService < BaseService
# 5. Executes the project's services
#
def
execute
@project
.
repository
.
expire_cache
(
branch_name
)
@project
.
repository
.
after_push_commit
(
branch_name
)
if
push_remove_branch?
@project
.
repository
.
expire_has_visible_content_cache
@project
.
repository
.
after_remove_branch
@push_commits
=
[]
elsif
push_to_new_branch?
@project
.
repository
.
expire_has_visible_content_cache
@project
.
repository
.
after_create_branch
# Re-find the pushed commits.
if
is_default_branch?
...
...
app/services/git_tag_push_service.rb
浏览文件 @
e1e6dd76
...
...
@@ -2,7 +2,7 @@ class GitTagPushService
attr_accessor
:project
,
:user
,
:push_data
def
execute
(
project
,
user
,
oldrev
,
newrev
,
ref
)
project
.
repository
.
expire_cache
project
.
repository
.
before_create_tag
@project
,
@user
=
project
,
user
@push_data
=
build_push_data
(
oldrev
,
newrev
,
ref
)
...
...
app/services/projects/destroy_service.rb
浏览文件 @
e1e6dd76
...
...
@@ -76,11 +76,9 @@ module Projects
end
def
flush_caches
(
project
,
wiki_path
)
project
.
repository
.
expire_all_caches!
if
project
.
repository
.
exists?
project
.
repository
.
before_delete
wiki_repo
=
Repository
.
new
(
wiki_path
,
project
)
wiki_repo
.
expire_all_caches!
if
wiki_repo
.
exists?
Repository
.
new
(
wiki_path
,
project
).
before_delete
end
end
end
app/validators/url_validator.rb
浏览文件 @
e1e6dd76
...
...
@@ -29,8 +29,11 @@ class UrlValidator < ActiveModel::EachValidator
end
def
valid_url?
(
value
)
return
false
if
value
.
nil?
options
=
default_options
.
merge
(
self
.
options
)
value
.
strip!
value
=~
/\A
#{
URI
.
regexp
(
options
[
:protocols
])
}
\z/
end
end
app/workers/repository_fork_worker.rb
浏览文件 @
e1e6dd76
...
...
@@ -27,7 +27,7 @@ class RepositoryForkWorker
return
end
project
.
repository
.
expire_emptiness_caches
project
.
repository
.
after_import
project
.
import_finish
end
end
app/workers/repository_import_worker.rb
浏览文件 @
e1e6dd76
...
...
@@ -18,7 +18,7 @@ class RepositoryImportWorker
return
end
project
.
repository
.
expire_emptiness_caches
project
.
repository
.
after_import
project
.
import_finish
end
end
doc/development/README.md
浏览文件 @
e1e6dd76
# Development
-
[
Architecture
](
architecture.md
)
of GitLab
-
[
Shell commands
](
shell_commands.md
)
in the GitLab codebase
-
[
Rake tasks
](
rake_tasks.md
)
for development
-
[
Benchmarking
](
benchmarking.md
)
-
[
CI setup
](
ci_setup.md
)
for testing GitLab
-
[
Gotchas
](
gotchas.md
)
to avoid
-
[
How to dump production data to staging
](
db_dump.md
)
-
[
Migration Style Guide
](
migration_style_guide.md
)
for creating safe migrations
-
[
Rake tasks
](
rake_tasks.md
)
for development
-
[
Shell commands
](
shell_commands.md
)
in the GitLab codebase
-
[
Sidekiq debugging
](
sidekiq_debugging.md
)
-
[
UI guide
](
ui_guide.md
)
for building GitLab with existing css styles and elements
-
[
Migration Style Guide
](
migration_style_guide.md
)
for creating safe migrations
-
[
How to dump production data to staging
](
dump_db.md
)
-
[
Benchmarking
](
benchmarking.md
)
doc/development/gotchas.md
0 → 100644
浏览文件 @
e1e6dd76
# Gotchas
The purpose of this guide is to document potential "gotchas" that contributors
might encounter or should avoid during development of GitLab CE and EE.
## Don't `describe` symbols
Consider the following model spec:
```
ruby
require
'rails_helper'
describe
User
do
describe
:to_param
do
it
'converts the username to a param'
do
user
=
described_class
.
new
(
username:
'John Smith'
)
expect
(
user
.
to_param
).
to
eq
'john-smith'
end
end
end
```
When run, this spec doesn't do what we might expect:
```
sh
spec/models/user_spec.rb|6 error| Failure/Error: u
=
described_class.new NoMethodError: undefined method
`
new
' for :to_param:Symbol
```
### Solution
Except for the top-level
`describe`
block, always provide a String argument to
`describe`
.
## Don't `rescue Exception`
See
[
"Why is it bad style to `rescue Exception => e` in Ruby?"
][
Exception
]
.
_
**Note:**
This rule is
[
enforced automatically by
Rubocop
](
https://gitlab.com/gitlab-org/gitlab-ce/blob/8-4-stable/.rubocop.yml#L911-914
)
._
[
Exception
]:
http://stackoverflow.com/q/10048173/223897
## Don't use inline CoffeeScript in views
Using the inline
`:coffee`
or
`:coffeescript`
Haml filters comes with a
performance overhead.
_
**Note:**
We've
[
removed these two filters
](
https://gitlab.com/gitlab-org/gitlab-ce/blob/8-5-stable/config/initializers/haml.rb
)
in an initializer._
### Further reading
-
Pull Request:
[
Replace CoffeeScript block into JavaScript in Views
](
https://git.io/vztMu
)
-
Stack Overflow:
[
Performance implications of using :coffescript filter inside HAML templates?
](
http://stackoverflow.com/a/17571242/223897
)
## ID-based CSS selectors need to be a bit more specific
Normally, because HTML
`id`
attributes need to be unique to the page, it's
perfectly fine to write some JavaScript like the following:
```
javascript
$
(
'
#js-my-selector
'
).
hide
();
```
However, there's a feature of GitLab's Markdown processing that
[
automatically
adds anchors to header elements
][
ToC Processing
]
, with the
`id`
attribute being
automatically generated based on the content of the header.
Unfortunately, this feature makes it possible for user-generated content to
create a header element with the same
`id`
attribute we're using in our
selector, potentially breaking the JavaScript behavior. A user could break the
above example with the following Markdown:
```
markdown
## JS My Selector
```
Which gets converted to the following HTML:
```
html
<h2>
<a
id=
"js-my-selector"
class=
"anchor"
href=
"#js-my-selector"
aria-hidden=
"true"
></a>
JS My Selector
</h2>
```
[
ToC Processing
]:
https://gitlab.com/gitlab-org/gitlab-ce/blob/8-4-stable/lib/banzai/filter/table_of_contents_filter.rb#L31-37
### Solution
The current recommended fix for this is to make our selectors slightly more
specific:
```
javascript
$
(
'
div#js-my-selector
'
).
hide
();
```
### Further reading
-
Issue:
[
Merge request ToC anchor conflicts with tabs
](
https://gitlab.com/gitlab-org/gitlab-ce/issues/3908
)
-
Merge Request:
[
Make tab target selectors less naive
](
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2023
)
-
Merge Request:
[
Make cross-project reference's clipboard target less naive
](
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2024
)
doc/permissions/permissions.md
浏览文件 @
e1e6dd76
...
...
@@ -6,7 +6,7 @@ If a user is both in a project group and in the project itself, the highest perm
If a user is a GitLab administrator they receive all permissions.
On public projects the Guest role is not enforced.
On public
and internal
projects the Guest role is not enforced.
All users will be able to create issues, leave comments, and pull or download the project code.
To add or import a user, you can follow the
[
project users and members
...
...
spec/features/issues/filter_by_milestone_spec.rb
浏览文件 @
e1e6dd76
...
...
@@ -13,7 +13,7 @@ feature 'Issue filtering by Milestone', feature: true do
visit_issues
(
project
)
filter_by_milestone
(
Milestone
::
None
.
title
)
expect
(
page
).
to
have_css
(
'.title'
,
count:
1
)
expect
(
page
).
to
have_css
(
'.
issue .
title'
,
count:
1
)
end
scenario
'filters by a specific Milestone'
,
js:
true
do
...
...
@@ -23,7 +23,7 @@ feature 'Issue filtering by Milestone', feature: true do
visit_issues
(
project
)
filter_by_milestone
(
milestone
.
title
)
expect
(
page
).
to
have_css
(
'.title'
,
count:
1
)
expect
(
page
).
to
have_css
(
'.
issue .
title'
,
count:
1
)
end
def
visit_issues
(
project
)
...
...
spec/models/hooks/project_hook_spec.rb
浏览文件 @
e1e6dd76
...
...
@@ -19,6 +19,10 @@
require
'spec_helper'
describe
ProjectHook
,
models:
true
do
describe
"Associations"
do
it
{
is_expected
.
to
belong_to
:project
}
end
describe
'.push_hooks'
do
it
'should return hooks for push events only'
do
hook
=
create
(
:project_hook
,
push_events:
true
)
...
...
spec/models/hooks/web_hook_spec.rb
浏览文件 @
e1e6dd76
...
...
@@ -18,20 +18,14 @@
require
'spec_helper'
describe
ProjectHook
,
models:
true
do
describe
"Associations"
do
it
{
is_expected
.
to
belong_to
:project
}
end
describe
"Mass assignment"
do
end
describe
WebHook
,
models:
true
do
describe
"Validations"
do
it
{
is_expected
.
to
validate_presence_of
(
:url
)
}
context
"url format"
do
describe
'url'
do
it
{
is_expected
.
to
allow_value
(
"http://example.com"
).
for
(
:url
)
}
it
{
is_expected
.
to
allow_value
(
"https://excample.com"
).
for
(
:url
)
}
it
{
is_expected
.
to
allow_value
(
"https://example.com"
).
for
(
:url
)
}
it
{
is_expected
.
to
allow_value
(
" https://example.com "
).
for
(
:url
)
}
it
{
is_expected
.
to
allow_value
(
"http://test.com/api"
).
for
(
:url
)
}
it
{
is_expected
.
to
allow_value
(
"http://test.com/api?key=abc"
).
for
(
:url
)
}
it
{
is_expected
.
to
allow_value
(
"http://test.com/api?key=abc&type=def"
).
for
(
:url
)
}
...
...
@@ -39,6 +33,12 @@ describe ProjectHook, models: true do
it
{
is_expected
.
not_to
allow_value
(
"example.com"
).
for
(
:url
)
}
it
{
is_expected
.
not_to
allow_value
(
"ftp://example.com"
).
for
(
:url
)
}
it
{
is_expected
.
not_to
allow_value
(
"herp-and-derp"
).
for
(
:url
)
}
it
'strips :url before saving it'
do
hook
=
create
(
:project_hook
,
url:
' https://example.com '
)
expect
(
hook
.
url
).
to
eq
(
'https://example.com'
)
end
end
end
...
...
spec/models/repository_spec.rb
浏览文件 @
e1e6dd76
...
...
@@ -362,14 +362,14 @@ describe Repository, models: true do
repository
.
expire_cache
(
'master'
)
end
it
'expires the emptiness cache for an empty repository'
do
it
'expires the emptiness cache
s
for an empty repository'
do
expect
(
repository
).
to
receive
(
:empty?
).
and_return
(
true
)
expect
(
repository
).
to
receive
(
:expire_emptiness_caches
)
repository
.
expire_cache
end
it
'does not expire the emptiness cache for a non-empty repository'
do
it
'does not expire the emptiness cache
s
for a non-empty repository'
do
expect
(
repository
).
to
receive
(
:empty?
).
and_return
(
false
)
expect
(
repository
).
to_not
receive
(
:expire_emptiness_caches
)
...
...
@@ -464,4 +464,108 @@ describe Repository, models: true do
expect
(
repository
.
blob_at_branch
(
'master'
,
'files/ruby/feature.rb'
)).
not_to
be_present
end
end
describe
'#before_delete'
do
describe
'when a repository does not exist'
do
before
do
allow
(
repository
).
to
receive
(
:exists?
).
and_return
(
false
)
end
it
'does not flush caches that depend on repository data'
do
expect
(
repository
).
to_not
receive
(
:expire_cache
)
repository
.
before_delete
end
it
'flushes the root ref cache'
do
expect
(
repository
).
to
receive
(
:expire_root_ref_cache
)
repository
.
before_delete
end
it
'flushes the emptiness caches'
do
expect
(
repository
).
to
receive
(
:expire_emptiness_caches
)
repository
.
before_delete
end
end
describe
'when a repository exists'
do
before
do
allow
(
repository
).
to
receive
(
:exists?
).
and_return
(
true
)
end
it
'flushes the caches that depend on repository data'
do
expect
(
repository
).
to
receive
(
:expire_cache
)
repository
.
before_delete
end
it
'flushes the root ref cache'
do
expect
(
repository
).
to
receive
(
:expire_root_ref_cache
)
repository
.
before_delete
end
it
'flushes the emptiness caches'
do
expect
(
repository
).
to
receive
(
:expire_emptiness_caches
)
repository
.
before_delete
end
end
end
describe
'#before_change_head'
do
it
'flushes the branch cache'
do
expect
(
repository
).
to
receive
(
:expire_branch_cache
)
repository
.
before_change_head
end
it
'flushes the root ref cache'
do
expect
(
repository
).
to
receive
(
:expire_root_ref_cache
)
repository
.
before_change_head
end
end
describe
'#before_create_tag'
do
it
'flushes the cache'
do
expect
(
repository
).
to
receive
(
:expire_cache
)
repository
.
before_create_tag
end
end
describe
'#after_import'
do
it
'flushes the emptiness cachess'
do
expect
(
repository
).
to
receive
(
:expire_emptiness_caches
)
repository
.
after_import
end
end
describe
'#after_push_commit'
do
it
'flushes the cache'
do
expect
(
repository
).
to
receive
(
:expire_cache
).
with
(
'master'
)
repository
.
after_push_commit
(
'master'
)
end
end
describe
'#after_create_branch'
do
it
'flushes the visible content cache'
do
expect
(
repository
).
to
receive
(
:expire_has_visible_content_cache
)
repository
.
after_create_branch
end
end
describe
'#after_remove_branch'
do
it
'flushes the visible content cache'
do
expect
(
repository
).
to
receive
(
:expire_has_visible_content_cache
)
repository
.
after_remove_branch
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录