diff options
author | Hiroyuki Sato <sathiroyuki@gmail.com> | 2013-08-21 16:55:18 +0900 |
---|---|---|
committer | Hiroyuki Sato <sathiroyuki@gmail.com> | 2013-08-21 17:53:51 +0900 |
commit | 5f24bdb7d067df9204e08e126f43c071116089b0 (patch) | |
tree | 750250171049a6501692e3f8497b0485eaaac042 /lib/extracts_path.rb | |
parent | 0a44ecf3a0eb7be66b2dbbb6e8404e3242a4b016 (diff) | |
download | gitlab-ce-5f24bdb7d067df9204e08e126f43c071116089b0.tar.gz |
Render not found when failing to look for a commit
Diffstat (limited to 'lib/extracts_path.rb')
-rw-r--r-- | lib/extracts_path.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index d1035240cb6..f9843d503b4 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -94,19 +94,23 @@ module ExtractsPath # Automatically renders `not_found!` if a valid tree path could not be # resolved (e.g., when a user inserts an invalid path or ref). def assign_ref_vars + # assign allowed options + allowed_options = ["filter_ref", "q"] + @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? } + @options = HashWithIndifferentAccess.new(@options) + @id = get_id @ref, @path = extract_ref(@id) @repo = @project.repository - @commit = @repo.commit(@ref) + if @options[:q].blank? + @commit = @repo.commit(@ref) + else + @commit = @repo.commit(@options[:q]) + end @tree = Tree.new(@repo, @commit.id, @ref, @path) @hex_path = Digest::SHA1.hexdigest(@path) @logs_path = logs_file_project_ref_path(@project, @ref, @path) - # assign allowed options - allowed_options = ["filter_ref", "q"] - @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? } - @options = HashWithIndifferentAccess.new(@options) - raise InvalidPathError unless @tree.exists? rescue RuntimeError, NoMethodError, InvalidPathError not_found! |