Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not overwrite empty DefaultBranch #22708

Merged
merged 5 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions models/fixtures/repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
owner_name: user2
lower_name: repo1
name: repo1
default_branch: master
num_watches: 4
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -34,6 +35,7 @@
owner_name: user2
lower_name: repo2
name: repo2
default_branch: master
num_watches: 0
num_stars: 1
num_forks: 0
Expand Down Expand Up @@ -64,6 +66,7 @@
owner_name: user3
lower_name: repo3
name: repo3
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -94,6 +97,7 @@
owner_name: user5
lower_name: repo4
name: repo4
default_branch: master
num_watches: 0
num_stars: 1
num_forks: 0
Expand Down Expand Up @@ -274,6 +278,7 @@
owner_name: user12
lower_name: repo10
name: repo10
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 1
Expand Down Expand Up @@ -304,6 +309,7 @@
owner_name: user13
lower_name: repo11
name: repo11
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -425,6 +431,7 @@
owner_name: user2
lower_name: repo15
name: repo15
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -455,6 +462,7 @@
owner_name: user2
lower_name: repo16
name: repo16
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -905,6 +913,7 @@
owner_name: user2
lower_name: repo20
name: repo20
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -965,6 +974,7 @@
owner_name: user2
lower_name: utf8
name: utf8
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1055,6 +1065,7 @@
owner_name: user2
lower_name: commits_search_test
name: commits_search_test
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1085,6 +1096,7 @@
owner_name: user2
lower_name: git_hooks_test
name: git_hooks_test
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1115,6 +1127,7 @@
owner_name: limited_org
lower_name: public_repo_on_limited_org
name: public_repo_on_limited_org
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1145,6 +1158,7 @@
owner_name: limited_org
lower_name: private_repo_on_limited_org
name: private_repo_on_limited_org
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1175,6 +1189,7 @@
owner_name: privated_org
lower_name: public_repo_on_private_org
name: public_repo_on_private_org
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1205,6 +1220,7 @@
owner_name: privated_org
lower_name: private_repo_on_private_org
name: private_repo_on_private_org
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1235,6 +1251,7 @@
owner_name: user2
lower_name: glob
name: glob
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1295,6 +1312,7 @@
owner_name: user27
lower_name: template1
name: template1
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1355,6 +1373,7 @@
owner_name: org26
lower_name: repo_external_tracker
name: repo_external_tracker
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1385,6 +1404,7 @@
owner_name: org26
lower_name: repo_external_tracker_numeric
name: repo_external_tracker_numeric
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1415,6 +1435,7 @@
owner_name: org26
lower_name: repo_external_tracker_alpha
name: repo_external_tracker_alpha
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1445,6 +1466,7 @@
owner_name: user27
lower_name: repo49
name: repo49
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1475,6 +1497,7 @@
owner_name: user30
lower_name: repo50
name: repo50
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1505,6 +1528,7 @@
owner_name: user30
lower_name: repo51
name: repo51
default_branch: master
num_watches: 0
num_stars: 0
num_forks: 0
Expand Down Expand Up @@ -1565,6 +1589,7 @@
owner_name: user30
lower_name: renderer
name: renderer
default_branch: master
is_archived: false
is_empty: false
is_private: false
Expand Down Expand Up @@ -1592,6 +1617,7 @@
owner_name: user2
lower_name: lfs
name: lfs
default_branch: master
is_empty: false
is_archived: false
is_private: true
Expand Down
5 changes: 0 additions & 5 deletions models/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,6 @@ func (repo *Repository) IsBroken() bool {

// AfterLoad is invoked from XORM after setting the values of all fields of this object.
func (repo *Repository) AfterLoad() {
// FIXME: use models migration to solve all at once.
if len(repo.DefaultBranch) == 0 {
repo.DefaultBranch = setting.Repository.DefaultBranch
}

repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
repo.NumOpenPulls = repo.NumPulls - repo.NumClosedPulls
repo.NumOpenMilestones = repo.NumMilestones - repo.NumClosedMilestones
Expand Down