Skip to content

Commit 386f33f

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated licenses and gitignores Actually recover from a panic in cron task (go-gitea#28409) Fix missing check (go-gitea#28406) Also sync DB branches on push if necessary (go-gitea#28361) Remove stale since giteabot has similiar feature (go-gitea#28401) [skip ci] Updated translations via Crowdin
2 parents 13beca8 + 5b2bbf1 commit 386f33f

File tree

16 files changed

+188
-172
lines changed

16 files changed

+188
-172
lines changed

.github/stale.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

models/git/branch.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,9 @@ func DeleteBranches(ctx context.Context, repoID, doerID int64, branchIDs []int64
205205
})
206206
}
207207

208-
// UpdateBranch updates the branch information in the database. If the branch exist, it will update latest commit of this branch information
209-
// If it doest not exist, insert a new record into database
210-
func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string, commit *git.Commit) error {
211-
cnt, err := db.GetEngine(ctx).Where("repo_id=? AND name=?", repoID, branchName).
208+
// UpdateBranch updates the branch information in the database.
209+
func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string, commit *git.Commit) (int64, error) {
210+
return db.GetEngine(ctx).Where("repo_id=? AND name=?", repoID, branchName).
212211
Cols("commit_id, commit_message, pusher_id, commit_time, is_deleted, updated_unix").
213212
Update(&Branch{
214213
CommitID: commit.ID.String(),
@@ -217,21 +216,6 @@ func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string
217216
CommitTime: timeutil.TimeStamp(commit.Committer.When.Unix()),
218217
IsDeleted: false,
219218
})
220-
if err != nil {
221-
return err
222-
}
223-
if cnt > 0 {
224-
return nil
225-
}
226-
227-
return db.Insert(ctx, &Branch{
228-
RepoID: repoID,
229-
Name: branchName,
230-
CommitID: commit.ID.String(),
231-
CommitMessage: commit.Summary(),
232-
PusherID: pusherID,
233-
CommitTime: timeutil.TimeStamp(commit.Committer.When.Unix()),
234-
})
235219
}
236220

237221
// AddDeletedBranch adds a deleted branch to the database
@@ -308,6 +292,17 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to str
308292

309293
sess := db.GetEngine(ctx)
310294

295+
var branch Branch
296+
exist, err := db.GetEngine(ctx).Where("repo_id=? AND name=?", repo.ID, from).Get(&branch)
297+
if err != nil {
298+
return err
299+
} else if !exist || branch.IsDeleted {
300+
return ErrBranchNotExist{
301+
RepoID: repo.ID,
302+
BranchName: from,
303+
}
304+
}
305+
311306
// 1. update branch in database
312307
if n, err := sess.Where("repo_id=? AND name=?", repo.ID, from).Update(&Branch{
313308
Name: to,

models/git/branch_list.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type FindBranchOptions struct {
7373
Keyword string
7474
}
7575

76-
func (opts *FindBranchOptions) Cond() builder.Cond {
76+
func (opts FindBranchOptions) ToConds() builder.Cond {
7777
cond := builder.NewCond()
7878
if opts.RepoID > 0 {
7979
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
@@ -92,7 +92,7 @@ func (opts *FindBranchOptions) Cond() builder.Cond {
9292
}
9393

9494
func CountBranches(ctx context.Context, opts FindBranchOptions) (int64, error) {
95-
return db.GetEngine(ctx).Where(opts.Cond()).Count(&Branch{})
95+
return db.GetEngine(ctx).Where(opts.ToConds()).Count(&Branch{})
9696
}
9797

9898
func orderByBranches(sess *xorm.Session, opts FindBranchOptions) *xorm.Session {
@@ -108,7 +108,7 @@ func orderByBranches(sess *xorm.Session, opts FindBranchOptions) *xorm.Session {
108108
}
109109

110110
func FindBranches(ctx context.Context, opts FindBranchOptions) (BranchList, error) {
111-
sess := db.GetEngine(ctx).Where(opts.Cond())
111+
sess := db.GetEngine(ctx).Where(opts.ToConds())
112112
if opts.PageSize > 0 && !opts.IsListAll() {
113113
sess = db.SetSessionPagination(sess, &opts.ListOptions)
114114
}
@@ -119,7 +119,7 @@ func FindBranches(ctx context.Context, opts FindBranchOptions) (BranchList, erro
119119
}
120120

121121
func FindBranchNames(ctx context.Context, opts FindBranchOptions) ([]string, error) {
122-
sess := db.GetEngine(ctx).Select("name").Where(opts.Cond())
122+
sess := db.GetEngine(ctx).Select("name").Where(opts.ToConds())
123123
if opts.PageSize > 0 && !opts.IsListAll() {
124124
sess = db.SetSessionPagination(sess, &opts.ListOptions)
125125
}

models/git/branch_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestAddDeletedBranch(t *testing.T) {
3737
},
3838
}
3939

40-
err := git_model.UpdateBranch(db.DefaultContext, repo.ID, secondBranch.PusherID, secondBranch.Name, commit)
40+
_, err := git_model.UpdateBranch(db.DefaultContext, repo.ID, secondBranch.PusherID, secondBranch.Name, commit)
4141
assert.NoError(t, err)
4242
}
4343

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Copyright (C) 1999, 2000 by Anton Zinoviev <[email protected]>
2+
3+
This software may be used, modified, copied, distributed, and sold,
4+
in both source and binary form provided that the above copyright
5+
and these terms are retained. Under no circumstances is the author
6+
responsible for the proper functioning of this software, nor does
7+
the author assume any responsibility for damages incurred with its
8+
use.
9+
10+
Permission is granted to anyone to use, distribute and modify
11+
this file in any way, provided that the above copyright notice
12+
is left intact and the author of the modification summarizes
13+
the changes in this header.
14+
15+
This file is distributed without any expressed or implied warranty.

options/locale/locale_fr-FR.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ cancel=Annuler
655655
language=Langue
656656
ui=Thème
657657
hidden_comment_types=Catégories de commentaires masqués
658-
hidden_comment_types_description=Les catégories cochées masquent les commentaires respectifs des tickets. Par exemple, « Label » cache les commentaires du genre « Cerise a attribué le label Bug il y a 2 heures. »
658+
hidden_comment_types_description=Cochez les catégories suivantes pour masquer les commentaires correspondants des fils d'activité. Par exemple, « Label » cache les commentaires du genre « Cerise a attribué le label Bug il y a 2 heures. »
659659
hidden_comment_types.ref_tooltip=Commentaires où ce ticket a été référencé sur un autre ticket, révision, etc.
660660
hidden_comment_types.issue_ref_tooltip=Commentaires où l’utilisateur change la branche/étiquette associée au ticket
661661
comment_type_group_reference=Référence
@@ -3227,7 +3227,7 @@ comment_pull=`a commenté la demande d’ajout <a href="%[1]s">%[3]s#%[2]s</a>`
32273227
merge_pull_request=`a fusionné la demande d’ajout <a href="%[1]s">%[3]s#%[2]s</a>`
32283228
auto_merge_pull_request=`a fusionné automatiquement la demande d’ajout <a href="%[1]s">%[3]s#%[2]s</a>`
32293229
transfer_repo=a transféré le dépôt <code>%s</code> vers <a href="%s">%s</a>
3230-
push_tag=a poussé l’étiquette <a href="%[2]s">%[3]s</a> vers <a href="%[1]s">%[4]s</a>
3230+
push_tag=a poussé l’étiquette <a href="%[2]s">%[3]s</a> de <a href="%[1]s">%[4]s</a>
32313231
delete_tag=a supprimé l’étiquette %[2]s de <a href="%[1]s">%[3]s</a>
32323232
delete_branch=a supprimée la branche %[2]s de <a href="%[1]s">%[3]s</a>
32333233
compare_branch=Comparer
@@ -3236,12 +3236,12 @@ compare_commits_general=Comparer les révisions
32363236
mirror_sync_push=a synchronisé les révisions de <a href="%[2]s">%[3]s</a> d’un miroir vers <a href="%[1]s">%[4]s</a>.
32373237
mirror_sync_create=a synchronisé la nouvelle référence <a href="%[2]s">%[3]s</a> d’un miroir vers <a href="%[1]s">%[4]s</a>.
32383238
mirror_sync_delete=a synchronisé puis supprimé la nouvelle référence <code>%[2]s</code> vers <a href="%[1]s">%[3]s</a> depuis le miroir
3239-
approve_pull_request=`a approuvé <a href="%[1]s">%[3]s#%[2]s</a>.`
3239+
approve_pull_request=`a approuvé <a href="%[1]s">%[3]s#%[2]s</a>`
32403240
reject_pull_request=`a suggérés des changements pour <a href="%[1]s">%[3]s#%[2]s</a>`
3241-
publish_release=`a publié <a href="%[2]s"> "%[4]s" </a> à <a href="%[1]s">%[3]s</a>`
3242-
review_dismissed=`a révoqué l’évaluation de <b>%[4]s</b> sur <a href="%[1]s">%[3]s#%[2]s</a>.`
3241+
publish_release=`a publié <a href="%[2]s"> "%[4]s" </a> dans <a href="%[1]s">%[3]s</a>`
3242+
review_dismissed=`a révoqué l’évaluation de <b>%[4]s</b> dans <a href="%[1]s">%[3]s#%[2]s</a>`
32433243
review_dismissed_reason=Raison :
3244-
create_branch=a créé la branche <a href="%[2]s">%[3]s</a> dans <a href="%[1]s">%[4]s</a>.
3244+
create_branch=a créé la branche <a href="%[2]s">%[3]s</a> dans <a href="%[1]s">%[4]s</a>
32453245
starred_repo=aime <a href="%[1]s">%[2]s</a>
32463246
watched_repo=observe <a href="%[1]s">%[2]s</a>
32473247

0 commit comments

Comments
 (0)