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
b8e30b44
Commit
b8e30b44
authored
Jan 13, 2020
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
01226c75
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
11 deletions
+29
-11
app/assets/javascripts/repository/utils/readme.js
app/assets/javascripts/repository/utils/readme.js
+1
-1
changelogs/unreleased/25343-show-readme-txt.yml
changelogs/unreleased/25343-show-readme-txt.yml
+5
-0
lib/gitlab/file_detector.rb
lib/gitlab/file_detector.rb
+1
-1
spec/frontend/repository/utils/readme_spec.js
spec/frontend/repository/utils/readme_spec.js
+6
-0
spec/helpers/markup_helper_spec.rb
spec/helpers/markup_helper_spec.rb
+1
-1
spec/lib/gitlab/file_detector_spec.rb
spec/lib/gitlab/file_detector_spec.rb
+15
-8
No files found.
app/assets/javascripts/repository/utils/readme.js
View file @
b8e30b44
...
@@ -24,7 +24,7 @@ const isRichReadme = file => {
...
@@ -24,7 +24,7 @@ const isRichReadme = file => {
};
};
const
isPlainReadme
=
file
=>
{
const
isPlainReadme
=
file
=>
{
const
re
=
new
RegExp
(
`^(
${
FILENAMES
.
join
(
'
|
'
)}
)$`
,
'
i
'
);
const
re
=
new
RegExp
(
`^(
${
FILENAMES
.
join
(
'
|
'
)}
)
(\\.txt)?
$`
,
'
i
'
);
return
re
.
test
(
file
.
name
);
return
re
.
test
(
file
.
name
);
};
};
...
...
changelogs/unreleased/25343-show-readme-txt.yml
0 → 100644
View file @
b8e30b44
---
title
:
Fix README.txt not showing up on a project page
merge_request
:
21763
author
:
Alexander Oleynikov
type
:
fixed
lib/gitlab/file_detector.rb
View file @
b8e30b44
...
@@ -8,7 +8,7 @@ module Gitlab
...
@@ -8,7 +8,7 @@ module Gitlab
module
FileDetector
module
FileDetector
PATTERNS
=
{
PATTERNS
=
{
# Project files
# Project files
readme:
/\A(
#{
Regexp
.
union
(
*
Gitlab
::
MarkupHelper
::
PLAIN_FILENAMES
).
source
}
)(\.(
#{
Regexp
.
union
(
*
Gitlab
::
MarkupHelper
::
EXTENSIONS
).
source
}
))?\z/i
,
readme:
/\A(
#{
Regexp
.
union
(
*
Gitlab
::
MarkupHelper
::
PLAIN_FILENAMES
).
source
}
)(\.(
txt|
#{
Regexp
.
union
(
*
Gitlab
::
MarkupHelper
::
EXTENSIONS
).
source
}
))?\z/i
,
changelog:
%r{
\A
(changelog|history|changes|news)[^/]*
\z
}i
,
changelog:
%r{
\A
(changelog|history|changes|news)[^/]*
\z
}i
,
license:
%r{
\A
((un)?licen[sc]e|copying)(
\.
[^/]+)?
\z
}i
,
license:
%r{
\A
((un)?licen[sc]e|copying)(
\.
[^/]+)?
\z
}i
,
contributing:
%r{
\A
contributing[^/]*
\z
}i
,
contributing:
%r{
\A
contributing[^/]*
\z
}i
,
...
...
spec/frontend/repository/utils/readme_spec.js
View file @
b8e30b44
...
@@ -31,6 +31,12 @@ describe('readmeFile', () => {
...
@@ -31,6 +31,12 @@ describe('readmeFile', () => {
});
});
});
});
it
(
'
recognizes Readme.txt as a plain text README
'
,
()
=>
{
expect
(
readmeFile
([{
name
:
'
Readme.txt
'
}])).
toEqual
({
name
:
'
Readme.txt
'
,
});
});
it
(
'
returns undefined when there are no appropriate files
'
,
()
=>
{
it
(
'
returns undefined when there are no appropriate files
'
,
()
=>
{
expect
(
readmeFile
([{
name
:
'
index.js
'
},
{
name
:
'
md.README
'
}])).
toBe
(
undefined
);
expect
(
readmeFile
([{
name
:
'
index.js
'
},
{
name
:
'
md.README
'
}])).
toBe
(
undefined
);
expect
(
readmeFile
([])).
toBe
(
undefined
);
expect
(
readmeFile
([])).
toBe
(
undefined
);
...
...
spec/helpers/markup_helper_spec.rb
View file @
b8e30b44
...
@@ -410,7 +410,7 @@ describe MarkupHelper do
...
@@ -410,7 +410,7 @@ describe MarkupHelper do
end
end
context
'when file has an unknown type'
do
context
'when file has an unknown type'
do
let
(
:file_name
)
{
'foo'
}
let
(
:file_name
)
{
'foo
.tex
'
}
it
'returns html (rendered by Gitlab::OtherMarkup)'
do
it
'returns html (rendered by Gitlab::OtherMarkup)'
do
expected_html
=
'Noël'
expected_html
=
'Noël'
...
...
spec/lib/gitlab/file_detector_spec.rb
View file @
b8e30b44
...
@@ -16,23 +16,30 @@ describe Gitlab::FileDetector do
...
@@ -16,23 +16,30 @@ describe Gitlab::FileDetector do
end
end
describe
'.type_of'
do
describe
'.type_of'
do
it
'returns the type of a README file'
do
it
'returns the type of a README without extension'
do
filenames
=
Gitlab
::
MarkupHelper
::
PLAIN_FILENAMES
+
Gitlab
::
MarkupHelper
::
PLAIN_FILENAMES
.
map
(
&
:upcase
)
expect
(
described_class
.
type_of
(
'README'
)).
to
eq
(
:readme
)
extensions
=
Gitlab
::
MarkupHelper
::
EXTENSIONS
+
Gitlab
::
MarkupHelper
::
EXTENSIONS
.
map
(
&
:upcase
)
expect
(
described_class
.
type_of
(
'INDEX'
)).
to
eq
(
:readme
)
end
filenames
.
each
do
|
filename
|
it
'returns the type of a README file with a recognized extension'
do
expect
(
described_class
.
type_of
(
filename
)).
to
eq
(
:readme
)
extensions
=
[
'txt'
,
*
Gitlab
::
MarkupHelper
::
EXTENSIONS
]
extensions
.
each
do
|
extname
|
extensions
.
each
do
|
ext
|
expect
(
described_class
.
type_of
(
"
#{
filename
}
.
#{
extname
}
"
)).
to
eq
(
:readme
)
%w(index readme)
.
each
do
|
file
|
expect
(
described_class
.
type_of
(
"
#{
file
}
.
#{
ext
}
"
)).
to
eq
(
:readme
)
end
end
end
end
end
end
it
'returns nil for a README
.rb file
'
do
it
'returns nil for a README
with unrecognized extension
'
do
expect
(
described_class
.
type_of
(
'README.rb'
)).
to
be_nil
expect
(
described_class
.
type_of
(
'README.rb'
)).
to
be_nil
end
end
it
'is case insensitive'
do
expect
(
described_class
.
type_of
(
'ReadMe'
)).
to
eq
(
:readme
)
expect
(
described_class
.
type_of
(
'index.TXT'
)).
to
eq
(
:readme
)
end
it
'returns nil for a README file in a directory'
do
it
'returns nil for a README file in a directory'
do
expect
(
described_class
.
type_of
(
'foo/README.md'
)).
to
be_nil
expect
(
described_class
.
type_of
(
'foo/README.md'
)).
to
be_nil
end
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