Show More
@@ -211,7 +211,7 b' class RepoFilesView(RepoAppView):' | |||
|
211 | 211 | |
|
212 | 212 | return file_node |
|
213 | 213 | |
|
214 | def _is_valid_head(self, commit_id, repo): | |
|
214 | def _is_valid_head(self, commit_id, repo, landing_ref): | |
|
215 | 215 | branch_name = sha_commit_id = '' |
|
216 | 216 | is_head = False |
|
217 | 217 | log.debug('Checking if commit_id `%s` is a head for %s.', commit_id, repo) |
@@ -237,7 +237,11 b' class RepoFilesView(RepoAppView):' | |||
|
237 | 237 | return branch_name, sha_commit_id, is_head |
|
238 | 238 | |
|
239 | 239 | # checked branches, means we only need to try to get the branch/commit_sha |
|
240 |
if |
|
|
240 | if repo.is_empty(): | |
|
241 | is_head = True | |
|
242 | branch_name = landing_ref | |
|
243 | sha_commit_id = EmptyCommit().raw_id | |
|
244 | else: | |
|
241 | 245 | commit = repo.get_commit(commit_id=commit_id) |
|
242 | 246 | if commit: |
|
243 | 247 | branch_name = commit.branch |
@@ -696,8 +700,9 b' class RepoFilesView(RepoAppView):' | |||
|
696 | 700 | if not c.renderer: |
|
697 | 701 | c.lines = filenode_as_lines_tokens(c.file) |
|
698 | 702 | |
|
699 |
_branch_name, _sha_commit_id, is_head = |
|
|
700 |
commit_id, self.rhodecode_vcs_repo |
|
|
703 | _branch_name, _sha_commit_id, is_head = \ | |
|
704 | self._is_valid_head(commit_id, self.rhodecode_vcs_repo, | |
|
705 | landing_ref=self.db_repo.landing_ref_name) | |
|
701 | 706 | c.on_branch_head = is_head |
|
702 | 707 | |
|
703 | 708 | branch = c.commit.branch if ( |
@@ -1135,7 +1140,8 b' class RepoFilesView(RepoAppView):' | |||
|
1135 | 1140 | |
|
1136 | 1141 | commit_id, f_path = self._get_commit_and_path() |
|
1137 | 1142 | _branch_name, _sha_commit_id, is_head = \ |
|
1138 |
self._is_valid_head(commit_id, self.rhodecode_vcs_repo |
|
|
1143 | self._is_valid_head(commit_id, self.rhodecode_vcs_repo, | |
|
1144 | landing_ref=self.db_repo.landing_ref_name) | |
|
1139 | 1145 | |
|
1140 | 1146 | new_path = self.request.POST.get('path') |
|
1141 | 1147 | operation = self.request.POST.get('operation') |
@@ -1173,7 +1179,8 b' class RepoFilesView(RepoAppView):' | |||
|
1173 | 1179 | |
|
1174 | 1180 | self._ensure_not_locked() |
|
1175 | 1181 | _branch_name, _sha_commit_id, is_head = \ |
|
1176 |
self._is_valid_head(commit_id, self.rhodecode_vcs_repo |
|
|
1182 | self._is_valid_head(commit_id, self.rhodecode_vcs_repo, | |
|
1183 | landing_ref=self.db_repo.landing_ref_name) | |
|
1177 | 1184 | |
|
1178 | 1185 | self.forbid_non_head(is_head, f_path) |
|
1179 | 1186 | self.check_branch_permission(_branch_name) |
@@ -1201,7 +1208,8 b' class RepoFilesView(RepoAppView):' | |||
|
1201 | 1208 | |
|
1202 | 1209 | self._ensure_not_locked() |
|
1203 | 1210 | _branch_name, _sha_commit_id, is_head = \ |
|
1204 |
self._is_valid_head(commit_id, self.rhodecode_vcs_repo |
|
|
1211 | self._is_valid_head(commit_id, self.rhodecode_vcs_repo, | |
|
1212 | landing_ref=self.db_repo.landing_ref_name) | |
|
1205 | 1213 | |
|
1206 | 1214 | self.forbid_non_head(is_head, f_path) |
|
1207 | 1215 | self.check_branch_permission(_branch_name) |
@@ -1251,7 +1259,8 b' class RepoFilesView(RepoAppView):' | |||
|
1251 | 1259 | |
|
1252 | 1260 | self._ensure_not_locked() |
|
1253 | 1261 | _branch_name, _sha_commit_id, is_head = \ |
|
1254 |
self._is_valid_head(commit_id, self.rhodecode_vcs_repo |
|
|
1262 | self._is_valid_head(commit_id, self.rhodecode_vcs_repo, | |
|
1263 | landing_ref=self.db_repo.landing_ref_name) | |
|
1255 | 1264 | |
|
1256 | 1265 | self.forbid_non_head(is_head, f_path, commit_id=commit_id) |
|
1257 | 1266 | self.check_branch_permission(_branch_name, commit_id=commit_id) |
@@ -1292,7 +1301,8 b' class RepoFilesView(RepoAppView):' | |||
|
1292 | 1301 | commit_id=c.commit.raw_id, f_path=f_path)) |
|
1293 | 1302 | |
|
1294 | 1303 | _branch_name, _sha_commit_id, is_head = \ |
|
1295 |
self._is_valid_head(commit_id, self.rhodecode_vcs_repo |
|
|
1304 | self._is_valid_head(commit_id, self.rhodecode_vcs_repo, | |
|
1305 | landing_ref=self.db_repo.landing_ref_name) | |
|
1296 | 1306 | |
|
1297 | 1307 | self.forbid_non_head(is_head, f_path, commit_id=commit_id) |
|
1298 | 1308 | self.check_branch_permission(_branch_name, commit_id=commit_id) |
@@ -1380,7 +1390,8 b' class RepoFilesView(RepoAppView):' | |||
|
1380 | 1390 | _branch_name, _sha_commit_id, is_head = c.commit.branch, '', True |
|
1381 | 1391 | else: |
|
1382 | 1392 | _branch_name, _sha_commit_id, is_head = \ |
|
1383 |
self._is_valid_head(commit_id, self.rhodecode_vcs_repo |
|
|
1393 | self._is_valid_head(commit_id, self.rhodecode_vcs_repo, | |
|
1394 | landing_ref=self.db_repo.landing_ref_name) | |
|
1384 | 1395 | |
|
1385 | 1396 | self.forbid_non_head(is_head, f_path, commit_id=commit_id) |
|
1386 | 1397 | self.check_branch_permission(_branch_name, commit_id=commit_id) |
@@ -1421,7 +1432,8 b' class RepoFilesView(RepoAppView):' | |||
|
1421 | 1432 | _branch_name, _sha_commit_id, is_head = c.commit.branch, '', True |
|
1422 | 1433 | else: |
|
1423 | 1434 | _branch_name, _sha_commit_id, is_head = \ |
|
1424 |
self._is_valid_head(commit_id, self.rhodecode_vcs_repo |
|
|
1435 | self._is_valid_head(commit_id, self.rhodecode_vcs_repo, | |
|
1436 | landing_ref=self.db_repo.landing_ref_name) | |
|
1425 | 1437 | |
|
1426 | 1438 | self.forbid_non_head(is_head, f_path, commit_id=commit_id) |
|
1427 | 1439 | self.check_branch_permission(_branch_name, commit_id=commit_id) |
@@ -1517,7 +1529,8 b' class RepoFilesView(RepoAppView):' | |||
|
1517 | 1529 | _branch_name, _sha_commit_id, is_head = c.commit.branch, '', True |
|
1518 | 1530 | else: |
|
1519 | 1531 | _branch_name, _sha_commit_id, is_head = \ |
|
1520 |
self._is_valid_head(commit_id, self.rhodecode_vcs_repo |
|
|
1532 | self._is_valid_head(commit_id, self.rhodecode_vcs_repo, | |
|
1533 | landing_ref=self.db_repo.landing_ref_name) | |
|
1521 | 1534 | |
|
1522 | 1535 | error = self.forbid_non_head(is_head, f_path, json_mode=True) |
|
1523 | 1536 | if error: |
General Comments 0
You need to be logged in to leave comments.
Login now