From d60d5fe4e422ecd83437653bc5764c6269162125 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Sat, 15 Oct 2016 01:36:05 +0300
Subject: [PATCH] Improve ExtractsPath logic related to atom format

* Don't set request format to atom if '.atom' suffix was not provided
* Don't try '.atom' detection logic on request that uses extended_sha1

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
---
 lib/extracts_path.rb | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index e4d996a3fb6..9b74364849e 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -113,17 +113,18 @@ module ExtractsPath
     @id = get_id
     @ref, @path = extract_ref(@id)
     @repo = @project.repository
-    if @options[:extended_sha1].blank?
-      @commit = @repo.commit(@ref)
-    else
-      @commit = @repo.commit(@options[:extended_sha1])
-    end
 
-    if @path.empty? && !@commit
-      @id = @ref = extract_ref_without_atom(@id)
+    if @options[:extended_sha1].present?
+      @commit = @repo.commit(@options[:extended_sha1])
+    else
       @commit = @repo.commit(@ref)
 
-      request.format = :atom if @commit
+      if @path.empty? && !@commit && @id.ends_with?('.atom')
+        @id = @ref = extract_ref_without_atom(@id)
+        @commit = @repo.commit(@ref)
+
+        request.format = :atom if @commit
+      end
     end
 
     raise InvalidPathError unless @commit
-- 
GitLab