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
Léo-Paul Géneau
gitlab-ce
Commits
e53b47b4
Commit
e53b47b4
authored
Oct 12, 2012
by
Valeriy Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WebEditor: sceleton
parent
02c83f12
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
app/controllers/tree_controller.rb
app/controllers/tree_controller.rb
+8
-0
app/views/tree/edit.html.haml
app/views/tree/edit.html.haml
+2
-2
lib/gitlab/file_editor.rb
lib/gitlab/file_editor.rb
+20
-0
No files found.
app/controllers/tree_controller.rb
View file @
e53b47b4
...
...
@@ -26,5 +26,13 @@ class TreeController < ProjectResourceController
def
update
last_commit
=
@project
.
commits
(
@ref
,
@path
,
1
).
first
.
sha
file_editor
=
Gitlab
::
FileEditor
.
new
(
current_user
,
@project
)
if
file_editor
.
can_edit?
(
@path
,
last_commit
)
file_editor
.
update
(
@path
,
params
[
:content
])
redirect_to
project_tree_path
(
@project
,
@id
),
:notice
=>
"File has been successfully changed"
else
flash
[
:notice
]
=
"You can't save file because it has been changed"
render
:edit
end
end
end
app/views/tree/edit.html.haml
View file @
e53b47b4
...
...
@@ -8,9 +8,9 @@
#editor
=
@tree
.
data
.editor-commit-comment
=
label_tag
'
text-commit
'
do
=
label_tag
'
commit_message
'
do
%p
.slead
Commit message
=
text_area_tag
'
text_commit
'
=
text_area_tag
'
commit_message
'
.form-actions
=
hidden_field_tag
'last_commit'
,
@last_commit
=
hidden_field_tag
'content'
...
...
lib/gitlab/file_editor.rb
0 → 100644
View file @
e53b47b4
module
Gitlab
class
FileEditor
attr_accessor
:user
,
:project
def
initialize
(
user
,
project
)
self
.
user
=
user
self
.
project
=
project
end
def
can_edit?
(
path
,
last_commit
)
true
end
def
update
(
path
,
content
)
true
end
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