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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
38ca8915
Commit
38ca8915
authored
Aug 28, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
26a13e21
fe641cbd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
1 deletion
+46
-1
app/models/commit.rb
app/models/commit.rb
+6
-1
changelogs/unreleased/sh-fix-issue-move-api.yml
changelogs/unreleased/sh-fix-issue-move-api.yml
+5
-0
spec/lib/gitlab/gfm/reference_rewriter_spec.rb
spec/lib/gitlab/gfm/reference_rewriter_spec.rb
+17
-0
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+18
-0
No files found.
app/models/commit.rb
View file @
38ca8915
...
...
@@ -35,6 +35,7 @@ class Commit
MIN_SHA_LENGTH
=
Gitlab
::
Git
::
Commit
::
MIN_SHA_LENGTH
COMMIT_SHA_PATTERN
=
/\h{
#{
MIN_SHA_LENGTH
}
,40}/
.
freeze
EXACT_COMMIT_SHA_PATTERN
=
/\A
#{
COMMIT_SHA_PATTERN
}
\z/
.
freeze
# Used by GFM to match and present link extensions on node texts and hrefs.
LINK_EXTENSION_PATTERN
=
/(patch)/
.
freeze
...
...
@@ -90,7 +91,7 @@ class Commit
end
def
valid_hash?
(
key
)
!!
(
/\A
#{
COMMIT_SHA_PATTERN
}
\z/
=~
key
)
!!
(
EXACT_COMMIT_SHA_PATTERN
=~
key
)
end
def
lazy
(
project
,
oid
)
...
...
@@ -139,6 +140,10 @@ class Commit
'@'
end
def
self
.
reference_valid?
(
reference
)
!!
(
reference
=~
EXACT_COMMIT_SHA_PATTERN
)
end
# Pattern used to extract commit references from text
#
# This pattern supports cross-project references.
...
...
changelogs/unreleased/sh-fix-issue-move-api.yml
0 → 100644
View file @
38ca8915
---
title
:
Fix moving issues API failing when text includes commit URLs
merge_request
:
32317
author
:
type
:
fixed
spec/lib/gitlab/gfm/reference_rewriter_spec.rb
View file @
38ca8915
...
...
@@ -102,6 +102,23 @@ describe Gitlab::Gfm::ReferenceRewriter do
end
end
context
'with a commit'
do
let
(
:old_project
)
{
create
(
:project
,
:repository
,
name:
'old-project'
,
group:
group
)
}
let
(
:commit
)
{
old_project
.
commit
}
context
'reference to an absolute URL to a commit'
do
let
(
:text
)
{
Gitlab
::
UrlBuilder
.
build
(
commit
)
}
it
{
is_expected
.
to
eq
(
text
)
}
end
context
'reference to a commit'
do
let
(
:text
)
{
commit
.
id
}
it
{
is_expected
.
to
eq
(
"
#{
old_project_ref
}
@
#{
text
}
"
)
}
end
end
context
'reference contains project milestone'
do
let!
(
:milestone
)
do
create
(
:milestone
,
title:
'9.0'
,
project:
old_project
)
...
...
spec/models/commit_spec.rb
View file @
38ca8915
...
...
@@ -192,6 +192,24 @@ describe Commit do
end
end
describe
'.reference_valid?'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:ref
,
:result
)
do
'1234567'
|
true
'123456'
|
false
'1'
|
false
'0'
*
40
|
true
'c1acaa58bbcbc3eafe538cb8274ba387047b69f8'
|
true
'H1acaa58bbcbc3eafe538cb8274ba387047b69f8'
|
false
nil
|
false
end
with_them
do
it
{
expect
(
described_class
.
reference_valid?
(
ref
)).
to
eq
(
result
)
}
end
end
describe
'#reference_link_text'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
path:
'sample-project'
)
}
...
...
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