class TreeController

Controller for viewing a repository’s file structure

Public Instance Methods

edit() click to toggle source
# File app/controllers/tree_controller.rb, line 24
def edit
  @last_commit = @project.last_commit_for(@ref, @path).sha
end
show() click to toggle source
# File app/controllers/tree_controller.rb, line 13
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
update() click to toggle source
# File app/controllers/tree_controller.rb, line 28
def update
  file_editor = Gitlab::FileEditor.new(current_user, @project, @ref)
  update_status = file_editor.update(
    @path,
    params[:content],
    params[:commit_message],
    params[:last_commit]
  )

  if update_status
    redirect_to project_tree_path(@project, @id), notice: "Your changes have been successfully commited"
  else
    flash[:notice] = "Your changes could not be commited, because the file has been changed"
    render :edit
  end
end