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
0b3e9fd2
Commit
0b3e9fd2
authored
Oct 12, 2012
by
Valeriy Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WebEditor: Check if save is possible
parent
e53b47b4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
tree_controller.rb
app/controllers/tree_controller.rb
+2
-3
file_editor.rb
lib/gitlab/file_editor.rb
+5
-3
No files found.
app/controllers/tree_controller.rb
View file @
0b3e9fd2
...
...
@@ -25,9 +25,8 @@ class TreeController < ProjectResourceController
end
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
=
Gitlab
::
FileEditor
.
new
(
current_user
,
@project
,
@ref
)
if
file_editor
.
can_edit?
(
@path
,
params
[
:last_commit
])
file_editor
.
update
(
@path
,
params
[
:content
])
redirect_to
project_tree_path
(
@project
,
@id
),
:notice
=>
"File has been successfully changed"
else
...
...
lib/gitlab/file_editor.rb
View file @
0b3e9fd2
module
Gitlab
class
FileEditor
attr_accessor
:user
,
:project
attr_accessor
:user
,
:project
,
:ref
def
initialize
(
user
,
project
)
def
initialize
(
user
,
project
,
ref
)
self
.
user
=
user
self
.
project
=
project
self
.
ref
=
ref
end
def
can_edit?
(
path
,
last_commit
)
true
current_last_commit
=
@project
.
commits
(
ref
,
path
,
1
).
first
.
sha
last_commit
==
current_last_commit
end
def
update
(
path
,
content
)
...
...
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