Commit 82728a7
authored
Do not overwrite empty DefaultBranch (#22708)
Fix #21994.
And fix #19470.
While generating new repo from a template, it does something like
"commit to git repo, re-fetch repo model from DB, and update default
branch if it's empty".
https://github.com/go-gitea/gitea/blob/19d5b2f922c2defde579a935fbedb680eb8fff18/modules/repository/generate.go#L241-L253
Unfortunately, when load repo from DB, the default branch will be set to
`setting.Repository.DefaultBranch` if it's empty:
https://github.com/go-gitea/gitea/blob/19d5b2f922c2defde579a935fbedb680eb8fff18/models/repo/repo.go#L228-L233
I believe it's a very old temporary patch but has been kept for many
years, see:
[2d2d85b](2d2d85bb#diff-1851799b06733db4df3ec74385c1e8850ee5aedee70b8b55366910d22725eea8)
I know it's a risk to delete it, may lead to potential behavioral
changes, but we cannot keep the outdated `FIXME` forever. On the other
hand, an empty `DefaultBranch` does make sense: an empty repo doesn't
have one conceptually (actually, Gitea will still set it to
`setting.Repository.DefaultBranch` to make it safer).1 parent 2914c52 commit 82728a7
2 files changed
+26
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| |||
274 | 278 | | |
275 | 279 | | |
276 | 280 | | |
| 281 | + | |
277 | 282 | | |
278 | 283 | | |
279 | 284 | | |
| |||
304 | 309 | | |
305 | 310 | | |
306 | 311 | | |
| 312 | + | |
307 | 313 | | |
308 | 314 | | |
309 | 315 | | |
| |||
425 | 431 | | |
426 | 432 | | |
427 | 433 | | |
| 434 | + | |
428 | 435 | | |
429 | 436 | | |
430 | 437 | | |
| |||
455 | 462 | | |
456 | 463 | | |
457 | 464 | | |
| 465 | + | |
458 | 466 | | |
459 | 467 | | |
460 | 468 | | |
| |||
905 | 913 | | |
906 | 914 | | |
907 | 915 | | |
| 916 | + | |
908 | 917 | | |
909 | 918 | | |
910 | 919 | | |
| |||
965 | 974 | | |
966 | 975 | | |
967 | 976 | | |
| 977 | + | |
968 | 978 | | |
969 | 979 | | |
970 | 980 | | |
| |||
1055 | 1065 | | |
1056 | 1066 | | |
1057 | 1067 | | |
| 1068 | + | |
1058 | 1069 | | |
1059 | 1070 | | |
1060 | 1071 | | |
| |||
1085 | 1096 | | |
1086 | 1097 | | |
1087 | 1098 | | |
| 1099 | + | |
1088 | 1100 | | |
1089 | 1101 | | |
1090 | 1102 | | |
| |||
1115 | 1127 | | |
1116 | 1128 | | |
1117 | 1129 | | |
| 1130 | + | |
1118 | 1131 | | |
1119 | 1132 | | |
1120 | 1133 | | |
| |||
1145 | 1158 | | |
1146 | 1159 | | |
1147 | 1160 | | |
| 1161 | + | |
1148 | 1162 | | |
1149 | 1163 | | |
1150 | 1164 | | |
| |||
1175 | 1189 | | |
1176 | 1190 | | |
1177 | 1191 | | |
| 1192 | + | |
1178 | 1193 | | |
1179 | 1194 | | |
1180 | 1195 | | |
| |||
1205 | 1220 | | |
1206 | 1221 | | |
1207 | 1222 | | |
| 1223 | + | |
1208 | 1224 | | |
1209 | 1225 | | |
1210 | 1226 | | |
| |||
1235 | 1251 | | |
1236 | 1252 | | |
1237 | 1253 | | |
| 1254 | + | |
1238 | 1255 | | |
1239 | 1256 | | |
1240 | 1257 | | |
| |||
1295 | 1312 | | |
1296 | 1313 | | |
1297 | 1314 | | |
| 1315 | + | |
1298 | 1316 | | |
1299 | 1317 | | |
1300 | 1318 | | |
| |||
1355 | 1373 | | |
1356 | 1374 | | |
1357 | 1375 | | |
| 1376 | + | |
1358 | 1377 | | |
1359 | 1378 | | |
1360 | 1379 | | |
| |||
1385 | 1404 | | |
1386 | 1405 | | |
1387 | 1406 | | |
| 1407 | + | |
1388 | 1408 | | |
1389 | 1409 | | |
1390 | 1410 | | |
| |||
1415 | 1435 | | |
1416 | 1436 | | |
1417 | 1437 | | |
| 1438 | + | |
1418 | 1439 | | |
1419 | 1440 | | |
1420 | 1441 | | |
| |||
1445 | 1466 | | |
1446 | 1467 | | |
1447 | 1468 | | |
| 1469 | + | |
1448 | 1470 | | |
1449 | 1471 | | |
1450 | 1472 | | |
| |||
1475 | 1497 | | |
1476 | 1498 | | |
1477 | 1499 | | |
| 1500 | + | |
1478 | 1501 | | |
1479 | 1502 | | |
1480 | 1503 | | |
| |||
1505 | 1528 | | |
1506 | 1529 | | |
1507 | 1530 | | |
| 1531 | + | |
1508 | 1532 | | |
1509 | 1533 | | |
1510 | 1534 | | |
| |||
1565 | 1589 | | |
1566 | 1590 | | |
1567 | 1591 | | |
| 1592 | + | |
1568 | 1593 | | |
1569 | 1594 | | |
1570 | 1595 | | |
| |||
1592 | 1617 | | |
1593 | 1618 | | |
1594 | 1619 | | |
| 1620 | + | |
1595 | 1621 | | |
1596 | 1622 | | |
1597 | 1623 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | 230 | | |
236 | 231 | | |
237 | 232 | | |
| |||
0 commit comments