files: fixed creation of new files for empty repos....
dan -
r4463:d626e159 stable
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -211,7 +211,7 class RepoFilesView(RepoAppView):
211
211
212 return file_node
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 branch_name = sha_commit_id = ''
215 branch_name = sha_commit_id = ''
216 is_head = False
216 is_head = False
217 log.debug('Checking if commit_id `%s` is a head for %s.', commit_id, repo)
217 log.debug('Checking if commit_id `%s` is a head for %s.', commit_id, repo)
@@ -237,7 +237,11 class RepoFilesView(RepoAppView):
237 return branch_name, sha_commit_id, is_head
237 return branch_name, sha_commit_id, is_head
238
238
239 # checked branches, means we only need to try to get the branch/commit_sha
239 # checked branches, means we only need to try to get the branch/commit_sha
240 if not repo.is_empty():
240 if repo.is_empty():
241 is_head = True
242 branch_name = landing_ref
243 sha_commit_id = EmptyCommit().raw_id
244 else:
241 commit = repo.get_commit(commit_id=commit_id)
245 commit = repo.get_commit(commit_id=commit_id)
242 if commit:
246 if commit:
243 branch_name = commit.branch
247 branch_name = commit.branch
@@ -696,8 +700,9 class RepoFilesView(RepoAppView):
696 if not c.renderer:
700 if not c.renderer:
697 c.lines = filenode_as_lines_tokens(c.file)
701 c.lines = filenode_as_lines_tokens(c.file)
698
702
699 _branch_name, _sha_commit_id, is_head = self._is_valid_head(
703 _branch_name, _sha_commit_id, is_head = \
700 commit_id, self.rhodecode_vcs_repo)
704 self._is_valid_head(commit_id, self.rhodecode_vcs_repo,
705 landing_ref=self.db_repo.landing_ref_name)
701 c.on_branch_head = is_head
706 c.on_branch_head = is_head
702
707
703 branch = c.commit.branch if (
708 branch = c.commit.branch if (
@@ -1135,7 +1140,8 class RepoFilesView(RepoAppView):
1135
1140
1136 commit_id, f_path = self._get_commit_and_path()
1141 commit_id, f_path = self._get_commit_and_path()
1137 _branch_name, _sha_commit_id, is_head = \
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 new_path = self.request.POST.get('path')
1146 new_path = self.request.POST.get('path')
1141 operation = self.request.POST.get('operation')
1147 operation = self.request.POST.get('operation')
@@ -1173,7 +1179,8 class RepoFilesView(RepoAppView):
1173
1179
1174 self._ensure_not_locked()
1180 self._ensure_not_locked()
1175 _branch_name, _sha_commit_id, is_head = \
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 self.forbid_non_head(is_head, f_path)
1185 self.forbid_non_head(is_head, f_path)
1179 self.check_branch_permission(_branch_name)
1186 self.check_branch_permission(_branch_name)
@@ -1201,7 +1208,8 class RepoFilesView(RepoAppView):
1201
1208
1202 self._ensure_not_locked()
1209 self._ensure_not_locked()
1203 _branch_name, _sha_commit_id, is_head = \
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 self.forbid_non_head(is_head, f_path)
1214 self.forbid_non_head(is_head, f_path)
1207 self.check_branch_permission(_branch_name)
1215 self.check_branch_permission(_branch_name)
@@ -1251,7 +1259,8 class RepoFilesView(RepoAppView):
1251
1259
1252 self._ensure_not_locked()
1260 self._ensure_not_locked()
1253 _branch_name, _sha_commit_id, is_head = \
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 self.forbid_non_head(is_head, f_path, commit_id=commit_id)
1265 self.forbid_non_head(is_head, f_path, commit_id=commit_id)
1257 self.check_branch_permission(_branch_name, commit_id=commit_id)
1266 self.check_branch_permission(_branch_name, commit_id=commit_id)
@@ -1292,7 +1301,8 class RepoFilesView(RepoAppView):
1292 commit_id=c.commit.raw_id, f_path=f_path))
1301 commit_id=c.commit.raw_id, f_path=f_path))
1293
1302
1294 _branch_name, _sha_commit_id, is_head = \
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 self.forbid_non_head(is_head, f_path, commit_id=commit_id)
1307 self.forbid_non_head(is_head, f_path, commit_id=commit_id)
1298 self.check_branch_permission(_branch_name, commit_id=commit_id)
1308 self.check_branch_permission(_branch_name, commit_id=commit_id)
@@ -1380,7 +1390,8 class RepoFilesView(RepoAppView):
1380 _branch_name, _sha_commit_id, is_head = c.commit.branch, '', True
1390 _branch_name, _sha_commit_id, is_head = c.commit.branch, '', True
1381 else:
1391 else:
1382 _branch_name, _sha_commit_id, is_head = \
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 self.forbid_non_head(is_head, f_path, commit_id=commit_id)
1396 self.forbid_non_head(is_head, f_path, commit_id=commit_id)
1386 self.check_branch_permission(_branch_name, commit_id=commit_id)
1397 self.check_branch_permission(_branch_name, commit_id=commit_id)
@@ -1421,7 +1432,8 class RepoFilesView(RepoAppView):
1421 _branch_name, _sha_commit_id, is_head = c.commit.branch, '', True
1432 _branch_name, _sha_commit_id, is_head = c.commit.branch, '', True
1422 else:
1433 else:
1423 _branch_name, _sha_commit_id, is_head = \
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 self.forbid_non_head(is_head, f_path, commit_id=commit_id)
1438 self.forbid_non_head(is_head, f_path, commit_id=commit_id)
1427 self.check_branch_permission(_branch_name, commit_id=commit_id)
1439 self.check_branch_permission(_branch_name, commit_id=commit_id)
@@ -1517,7 +1529,8 class RepoFilesView(RepoAppView):
1517 _branch_name, _sha_commit_id, is_head = c.commit.branch, '', True
1529 _branch_name, _sha_commit_id, is_head = c.commit.branch, '', True
1518 else:
1530 else:
1519 _branch_name, _sha_commit_id, is_head = \
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 error = self.forbid_non_head(is_head, f_path, json_mode=True)
1535 error = self.forbid_non_head(is_head, f_path, json_mode=True)
1523 if error:
1536 if error:
Comments 0
You need to be logged in to leave comments. Login now