4343from .api import ApiIdentGetterResource
4444from .query import get_query
4545from .web_utils import ProjectConverter , IdentConverter , validate_version , validate_project , validate_ident , \
46- get_elixir_version_string , get_elixir_repo_link , RequestContext , Config , DiffFormater
46+ get_elixir_version_string , get_elixir_repo_url , RequestContext , Config , DiffFormater
4747
4848VERSION_CACHE_DURATION_SECONDS = 2 * 60 # 2 minutes
4949ADD_ISSUE_LINK = "https://github.com/bootlin/elixir/issues/new"
@@ -884,7 +884,9 @@ def generate_diff_page(ctx: RequestContext, q: Query,
884884 breadcrumb_links .append ((p , f'{ diff_base_url } { path_temp } ' ))
885885
886886 type = q .get_file_type (version , path )
887- type_other = q .get_file_type (version , path )
887+ type_other = q .get_file_type (version_other , path )
888+ blob_id = q .get_blob_id (version , path )
889+ blob_id_other = q .get_blob_id (version_other , path )
888890
889891 if type == 'tree' or type_other == 'tree' :
890892 back_path = os .path .dirname (path [:- 1 ])
@@ -906,7 +908,7 @@ def generate_warning(type, version):
906908 }
907909 template = ctx .jinja_env .get_template ('tree.html' )
908910 elif type == 'blob' or type_other == 'blob' :
909- if type == type_other == 'blob' :
911+ if type == type_other == 'blob' and blob_id != blob_id_other :
910912 code , code_other = generate_diff (q , project , version , version_other , path )
911913 template_ctx = {
912914 'code' : code ,
@@ -915,10 +917,15 @@ def generate_warning(type, version):
915917 }
916918 template = ctx .jinja_env .get_template ('diff.html' )
917919 else :
918- missing_version = version_other if type == 'blob' else version
920+ if blob_id == blob_id_other :
921+ warning = f'Files are the same in { version } and { version_other } .'
922+ else :
923+ missing_version = version_other if type == 'blob' else version
924+ warning = f'File does not exist or is not a file { missing_version } .'
925+
919926 template_ctx = {
920927 'code' : generate_source (q , project , version if type == 'blob' else version_other , path ),
921- 'warning' : f'File does not exist in { missing_version } .'
928+ 'warning' : warning
922929 }
923930 template = ctx .jinja_env .get_template ('source.html' )
924931 else :
0 commit comments