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
Jérome Perrin
gitlab-ce
Commits
948e1b84
Commit
948e1b84
authored
Feb 13, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respect autocrlf setting when creating/updating file through web UI
parent
79e8e613
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
app/models/repository.rb
app/models/repository.rb
+8
-0
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+11
-0
No files found.
app/models/repository.rb
View file @
948e1b84
...
@@ -1230,6 +1230,14 @@ class Repository
...
@@ -1230,6 +1230,14 @@ class Repository
action
[
:content
]
action
[
:content
]
end
end
detect
=
CharlockHolmes
::
EncodingDetector
.
new
.
detect
(
content
)
if
content
unless
detect
&&
detect
[
:type
]
==
:binary
# When writing to the repo directly as we are doing here,
# the `core.autocrlf` config isn't taken into account.
content
.
gsub!
(
"
\r\n
"
,
"
\n
"
)
if
self
.
autocrlf
end
oid
=
rugged
.
write
(
content
,
:blob
)
oid
=
rugged
.
write
(
content
,
:blob
)
index
.
add
(
path:
path
,
oid:
oid
,
mode:
mode
)
index
.
add
(
path:
path
,
oid:
oid
,
mode:
mode
)
...
...
spec/models/repository_spec.rb
View file @
948e1b84
...
@@ -351,6 +351,17 @@ describe Repository, models: true do
...
@@ -351,6 +351,17 @@ describe Repository, models: true do
expect
(
blob
.
data
).
to
eq
(
'Changelog!'
)
expect
(
blob
.
data
).
to
eq
(
'Changelog!'
)
end
end
it
'respects the autocrlf setting'
do
repository
.
commit_file
(
user
,
'hello.txt'
,
"Hello,
\r\n
World"
,
message:
'Add hello world'
,
branch_name:
'master'
,
update:
true
)
blob
=
repository
.
blob_at
(
'master'
,
'hello.txt'
)
expect
(
blob
.
data
).
to
eq
(
"Hello,
\n
World"
)
end
context
"when an author is specified"
do
context
"when an author is specified"
do
it
"uses the given email/name to set the commit's author"
do
it
"uses the given email/name to set the commit's author"
do
expect
do
expect
do
...
...
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