blob: 0a67e033b83d94fc6362f096d7fadc41b1e94c0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# Controller for viewing a repository's file structure
class TreeController < ProjectResourceController
include ExtractsPath
# Authorize
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
before_filter :assign_ref_vars
def show
@hex_path = Digest::SHA1.hexdigest(@path)
@logs_path = logs_file_project_ref_path(@project, @ref, @path)
respond_to do |format|
format.html
# Disable cache so browser history works
format.js { no_cache_headers }
end
end
def edit
@last_commit = @project.commits(@ref, @path, 1).first.sha
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.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
|