@@ -1085,6 +1085,7 @@ async def show(self, filename, ref, top_repo_path):
1085
1085
"fatal: Path '{}' does not exist (neither on disk nor in the index)" .format (
1086
1086
filename
1087
1087
),
1088
+ "fatal: Path '{}' does not exist in '{}'" .format (filename , ref ),
1088
1089
],
1089
1090
)
1090
1091
lower_error = error .lower ()
@@ -1104,20 +1105,34 @@ def get_content(self, filename, top_repo_path):
1104
1105
Get the file content of filename.
1105
1106
"""
1106
1107
relative_repo = os .path .relpath (top_repo_path , self .root_dir )
1107
- model = self .contents_manager .get (path = os .path .join (relative_repo , filename ))
1108
+ try :
1109
+ model = self .contents_manager .get (
1110
+ path = os .path .join (relative_repo , filename )
1111
+ )
1112
+ except tornado .web .HTTPError as error :
1113
+ # Handle versioned file being deleted case
1114
+ if error .status_code == 404 and error .log_message .startswith (
1115
+ "No such file or directory: "
1116
+ ):
1117
+ return ""
1118
+ raise error
1108
1119
return model ["content" ]
1109
1120
1110
1121
async def diff_content (self , filename , prev_ref , curr_ref , top_repo_path ):
1111
1122
"""
1112
1123
Collect get content of prev and curr and return.
1113
1124
"""
1114
- is_binary = await self ._is_binary (filename , prev_ref ["git" ], top_repo_path )
1115
- if is_binary :
1116
- raise tornado .web .HTTPError (
1117
- log_message = "Error occurred while executing command to retrieve plaintext diff as file is not UTF-8."
1118
- )
1125
+ if prev_ref ["git" ]:
1126
+ is_binary = await self ._is_binary (filename , prev_ref ["git" ], top_repo_path )
1127
+ if is_binary :
1128
+ raise tornado .web .HTTPError (
1129
+ log_message = "Error occurred while executing command to retrieve plaintext diff as file is not UTF-8."
1130
+ )
1131
+
1132
+ prev_content = await self .show (filename , prev_ref ["git" ], top_repo_path )
1133
+ else :
1134
+ prev_content = ""
1119
1135
1120
- prev_content = await self .show (filename , prev_ref ["git" ], top_repo_path )
1121
1136
if "special" in curr_ref :
1122
1137
if curr_ref ["special" ] == "WORKING" :
1123
1138
curr_content = self .get_content (filename , top_repo_path )
0 commit comments