diff options
author | zeripath <art27@cantab.net> | 2020-09-20 18:55:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-20 13:55:15 -0400 |
commit | 037d5a33a0aa466164890658cffb8eca0daa8801 (patch) | |
tree | 43f9f7502bd4e7f232603b513dc8cfb0778ffad2 /services/repository/push.go | |
parent | 7e5499575b3a159c3c17d381eeeabd230ca83373 (diff) | |
download | gitea-037d5a33a0aa466164890658cffb8eca0daa8801.tar.gz gitea-037d5a33a0aa466164890658cffb8eca0daa8801.zip |
Update only the repository columns that need updating (#12900)
We should only update is_empty, default_branch and updated time columns
during commitRepoAction and not update other columns as we risk
overwriting incorrect information.
Fix #11823
Fix #10536
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'services/repository/push.go')
-rw-r--r-- | services/repository/push.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/services/repository/push.go b/services/repository/push.go index 05871dea53..91a9d23b7c 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" "strings" + "time" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/cache" @@ -291,6 +292,10 @@ func commitRepoAction(repo *models.Repository, gitRepo *git.Repository, optsList } } } + // Update the is empty and default_branch columns + if err := models.UpdateRepositoryCols(repo, "default_branch", "is_empty"); err != nil { + return fmt.Errorf("UpdateRepositoryCols: %v", err) + } } opType := models.ActionCommitRepo @@ -359,9 +364,9 @@ func commitRepoAction(repo *models.Repository, gitRepo *git.Repository, optsList } } - // Change repository empty status and update last updated time. - if err := models.UpdateRepository(repo, false); err != nil { - return fmt.Errorf("UpdateRepository: %v", err) + // Change repository last updated time. + if err := models.UpdateRepositoryUpdatedTime(repo.ID, time.Now()); err != nil { + return fmt.Errorf("UpdateRepositoryUpdatedTime: %v", err) } if err := models.NotifyWatchers(actions...); err != nil { |