Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
6a1aa476
Commit
6a1aa476
authored
Jan 21, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:gitlabhq/gitlabhq
parents
ac050b6f
e5d491b7
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
120 additions
and
25 deletions
+120
-25
CHANGELOG
CHANGELOG
+1
-1
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+15
-0
app/helpers/submodule_helper.rb
app/helpers/submodule_helper.rb
+2
-2
app/views/projects/diffs/_file.html.haml
app/views/projects/diffs/_file.html.haml
+3
-0
app/views/projects/tree/_submodule_item.html.haml
app/views/projects/tree/_submodule_item.html.haml
+1
-9
config/gitlab.yml.example
config/gitlab.yml.example
+1
-1
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-1
lib/gitlab/closing_issue_extractor.rb
lib/gitlab/closing_issue_extractor.rb
+12
-7
spec/lib/gitlab/closing_issue_extractor_spec.rb
spec/lib/gitlab/closing_issue_extractor_spec.rb
+84
-0
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+0
-4
No files found.
CHANGELOG
View file @
6a1aa476
...
...
@@ -11,7 +11,7 @@ v 7.8.0
-
-
-
-
-
Allow more variations for commit messages closing issues (Julien Bianchi and Hannes Rosenögger)
-
-
-
...
...
app/helpers/diff_helper.rb
View file @
6a1aa476
...
...
@@ -135,4 +135,19 @@ module DiffHelper
'Side-by-side'
end
end
def
submodule_link
(
blob
,
ref
)
tree
,
commit
=
submodule_links
(
blob
,
ref
)
commit_id
=
if
commit
.
nil?
blob
.
id
[
0
..
10
]
else
link_to
"
#{
blob
.
id
[
0
..
10
]
}
"
,
commit
end
[
content_tag
(
:span
,
link_to
(
truncate
(
blob
.
name
,
length:
40
),
tree
)),
'@'
,
content_tag
(
:span
,
commit_id
,
class:
'monospace'
),
].
join
(
' '
).
html_safe
end
end
app/helpers/submodule_helper.rb
View file @
6a1aa476
...
...
@@ -2,8 +2,8 @@ module SubmoduleHelper
include
Gitlab
::
ShellAdapter
# links to files listing for submodule if submodule is a project on this server
def
submodule_links
(
submodule_item
)
url
=
@repository
.
submodule_url_for
(
@
ref
,
submodule_item
.
path
)
def
submodule_links
(
submodule_item
,
ref
=
nil
)
url
=
@repository
.
submodule_url_for
(
ref
,
submodule_item
.
path
)
return
url
,
nil
unless
url
=~
/([^\/:]+\/[^\/]+\.git)\Z/
...
...
app/views/projects/diffs/_file.html.haml
View file @
6a1aa476
...
...
@@ -9,6 +9,9 @@
.diff-btn-group
-
if
@commit
.
parent_ids
.
present?
=
view_file_btn
(
@commit
.
parent_id
,
diff_file
,
project
)
-
elsif
diff_file
.
diff
.
submodule?
-
submodule_item
=
project
.
repository
.
blob_at
(
@commit
.
id
,
diff_file
.
file_path
)
=
submodule_link
(
submodule_item
,
@commit
.
id
)
-
else
-
if
diff_file
.
renamed_file
%span
=
"
#{
diff_file
.
old_path
}
renamed to
#{
diff_file
.
new_path
}
"
...
...
app/views/projects/tree/_submodule_item.html.haml
View file @
6a1aa476
-
tree
,
commit
=
submodule_links
(
submodule_item
)
%tr
{
class:
"tree-item"
}
%td
.tree-item-file-name
%i
.fa.fa-archive
%span
=
link_to
truncate
(
submodule_item
.
name
,
length:
40
),
tree
@
%span
.monospace
-
if
commit
.
nil?
#{
truncate_sha
(
submodule_item
.
id
)
}
-
else
=
link_to
"
#{
truncate_sha
(
submodule_item
.
id
)
}
"
,
commit
=
submodule_link
(
submodule_item
,
@ref
)
%td
%td
.hidden-xs
config/gitlab.yml.example
View file @
6a1aa476
...
...
@@ -77,7 +77,7 @@ production: &base
# This happens when the commit is pushed or merged into the default branch of a project.
# When not specified the default issue_closing_pattern as specified below will be used.
# Tip: you can test your closing pattern at http://rubular.com
# issue_closing_pattern: '(
[Cc]lose[sd]|[Ff]ixe[sd]) #(\d
+)'
# issue_closing_pattern: '(
(?:[Cc]los(?:e[sd]|ing)|[Ff]ix(?:e[sd]|ing)?) +(?:(?:issues? +)?#\d+(?:(?:, *| +and +)?))
+)'
## Default project features settings
default_projects_features:
...
...
config/initializers/1_settings.rb
View file @
6a1aa476
...
...
@@ -109,7 +109,7 @@ Settings.gitlab['signup_enabled'] ||= true if Settings.gitlab['signup_enabled'].
Settings
.
gitlab
[
'signin_enabled'
]
||=
true
if
Settings
.
gitlab
[
'signin_enabled'
].
nil?
Settings
.
gitlab
[
'restricted_visibility_levels'
]
=
Settings
.
send
(
:verify_constant_array
,
Gitlab
::
VisibilityLevel
,
Settings
.
gitlab
[
'restricted_visibility_levels'
],
[])
Settings
.
gitlab
[
'username_changing_enabled'
]
=
true
if
Settings
.
gitlab
[
'username_changing_enabled'
].
nil?
Settings
.
gitlab
[
'issue_closing_pattern'
]
=
'(
[Cc]lose[sd]|[Ff]ixe[sd]) #(\d
+)'
if
Settings
.
gitlab
[
'issue_closing_pattern'
].
nil?
Settings
.
gitlab
[
'issue_closing_pattern'
]
=
'(
(?:[Cc]los(?:e[sd]|ing)|[Ff]ix(?:e[sd]|ing)?) +(?:(?:issues? +)?#\d+(?:(?:, *| +and +)?))
+)'
if
Settings
.
gitlab
[
'issue_closing_pattern'
].
nil?
Settings
.
gitlab
[
'default_projects_features'
]
||=
{}
Settings
.
gitlab
[
'webhook_timeout'
]
||=
10
Settings
.
gitlab
.
default_projects_features
[
'issues'
]
=
true
if
Settings
.
gitlab
.
default_projects_features
[
'issues'
].
nil?
...
...
lib/gitlab/closing_issue_extractor.rb
View file @
6a1aa476
...
...
@@ -3,14 +3,19 @@ module Gitlab
ISSUE_CLOSING_REGEX
=
Regexp
.
new
(
Gitlab
.
config
.
gitlab
.
issue_closing_pattern
)
def
self
.
closed_by_message_in_project
(
message
,
project
)
md
=
ISSUE_CLOSING_REGEX
.
match
(
message
)
if
md
issues
=
[]
unless
message
.
nil?
md
=
message
.
scan
(
ISSUE_CLOSING_REGEX
)
md
.
each
do
|
ref
|
extractor
=
Gitlab
::
ReferenceExtractor
.
new
extractor
.
analyze
(
md
[
0
],
project
)
extractor
.
issues_for
(
project
)
else
[]
extractor
.
analyze
(
ref
[
0
],
project
)
issues
+=
extractor
.
issues_for
(
project
)
end
end
issues
.
uniq
end
end
end
spec/lib/gitlab/closing_issue_extractor_spec.rb
0 → 100644
View file @
6a1aa476
require
'spec_helper'
describe
Gitlab
::
ClosingIssueExtractor
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:iid1
)
{
issue
.
iid
}
describe
:closed_by_message_in_project
do
context
'with a single reference'
do
it
do
message
=
"Awesome commit (Closes #
#{
iid1
}
)"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
]
end
it
do
message
=
"Awesome commit (closes #
#{
iid1
}
)"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
]
end
it
do
message
=
"Closed #
#{
iid1
}
"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
]
end
it
do
message
=
"closed #
#{
iid1
}
"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
]
end
it
do
message
=
"Awesome commit (fixes #
#{
iid1
}
)"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
]
end
it
do
message
=
"Awesome commit (fix #
#{
iid1
}
)"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
]
end
end
context
'with multiple references'
do
let
(
:other_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:third_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:iid2
)
{
other_issue
.
iid
}
let
(
:iid3
)
{
third_issue
.
iid
}
it
'fetches issues in single line message'
do
message
=
"Closes #
#{
iid1
}
and fix #
#{
iid2
}
"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
,
other_issue
]
end
it
'fetches comma-separated issues references in single line message'
do
message
=
"Closes #
#{
iid1
}
, closes #
#{
iid2
}
"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
,
other_issue
]
end
it
'fetches comma-separated issues numbers in single line message'
do
message
=
"Closes #
#{
iid1
}
, #
#{
iid2
}
and #
#{
iid3
}
"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
,
other_issue
,
third_issue
]
end
it
'fetches issues in multi-line message'
do
message
=
"Awesome commit (closes #
#{
iid1
}
)
\n
Also fixes #
#{
iid2
}
"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
,
other_issue
]
end
it
'fetches issues in hybrid message'
do
message
=
"Awesome commit (closes #
#{
iid1
}
)
\n
"
\
"Also fixing issues #
#{
iid2
}
, #
#{
iid3
}
and #4"
subject
.
closed_by_message_in_project
(
message
,
project
).
should
==
[
issue
,
other_issue
,
third_issue
]
end
end
end
end
spec/models/commit_spec.rb
View file @
6a1aa476
...
...
@@ -57,16 +57,12 @@ eos
let
(
:other_issue
)
{
create
:issue
,
project:
other_project
}
it
'detects issues that this commit is marked as closing'
do
stub_const
(
'Gitlab::ClosingIssueExtractor::ISSUE_CLOSING_REGEX'
,
/Fixes #\d+/
)
commit
.
stub
(
safe_message:
"Fixes #
#{
issue
.
iid
}
"
)
commit
.
closes_issues
(
project
).
should
==
[
issue
]
end
it
'does not detect issues from other projects'
do
ext_ref
=
"
#{
other_project
.
path_with_namespace
}
#
#{
other_issue
.
iid
}
"
stub_const
(
'Gitlab::ClosingIssueExtractor::ISSUE_CLOSING_REGEX'
,
/^([Cc]loses|[Ff]ixes)/
)
commit
.
stub
(
safe_message:
"Fixes
#{
ext_ref
}
"
)
commit
.
closes_issues
(
project
).
should
be_empty
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment