BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
tree_controller.rb
app/controllers/tree_controller.rb
+8
-0
edit.html.haml
app/views/tree/edit.html.haml
+2
-2
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