Commit 8e8d82d49ac80b230e89f034f7aac00ddd555d1e
1 parent
ad5a6a4a
Exists in
master
and in
4 other branches
Only allow editing text files
Showing
1 changed file
with
9 additions
and
0 deletions
Show diff stats
app/controllers/tree_controller.rb
| ... | ... | @@ -8,6 +8,7 @@ class TreeController < ProjectResourceController |
| 8 | 8 | before_filter :require_non_empty_project |
| 9 | 9 | |
| 10 | 10 | before_filter :assign_ref_vars |
| 11 | + before_filter :edit_requirements, only: [:edit, :update] | |
| 11 | 12 | |
| 12 | 13 | def show |
| 13 | 14 | @hex_path = Digest::SHA1.hexdigest(@path) |
| ... | ... | @@ -40,4 +41,12 @@ class TreeController < ProjectResourceController |
| 40 | 41 | render :edit |
| 41 | 42 | end |
| 42 | 43 | end |
| 44 | + | |
| 45 | + private | |
| 46 | + | |
| 47 | + def edit_requirements | |
| 48 | + unless @tree.is_blob? && @tree.text? | |
| 49 | + redirect_to project_tree_path(@project, @id), notice: "You can only edit text files" | |
| 50 | + end | |
| 51 | + end | |
| 43 | 52 | end | ... | ... |