Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zjjhot committed Dec 11, 2023
2 parents 13beca8 + 5b2bbf1 commit 386f33f
Show file tree
Hide file tree
Showing 16 changed files with 188 additions and 172 deletions.
54 changes: 0 additions & 54 deletions .github/stale.yml

This file was deleted.

33 changes: 14 additions & 19 deletions models/git/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,9 @@ func DeleteBranches(ctx context.Context, repoID, doerID int64, branchIDs []int64
})
}

// UpdateBranch updates the branch information in the database. If the branch exist, it will update latest commit of this branch information
// If it doest not exist, insert a new record into database
func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string, commit *git.Commit) error {
cnt, err := db.GetEngine(ctx).Where("repo_id=? AND name=?", repoID, branchName).
// UpdateBranch updates the branch information in the database.
func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string, commit *git.Commit) (int64, error) {
return db.GetEngine(ctx).Where("repo_id=? AND name=?", repoID, branchName).
Cols("commit_id, commit_message, pusher_id, commit_time, is_deleted, updated_unix").
Update(&Branch{
CommitID: commit.ID.String(),
Expand All @@ -217,21 +216,6 @@ func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string
CommitTime: timeutil.TimeStamp(commit.Committer.When.Unix()),
IsDeleted: false,
})
if err != nil {
return err
}
if cnt > 0 {
return nil
}

return db.Insert(ctx, &Branch{
RepoID: repoID,
Name: branchName,
CommitID: commit.ID.String(),
CommitMessage: commit.Summary(),
PusherID: pusherID,
CommitTime: timeutil.TimeStamp(commit.Committer.When.Unix()),
})
}

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

sess := db.GetEngine(ctx)

var branch Branch
exist, err := db.GetEngine(ctx).Where("repo_id=? AND name=?", repo.ID, from).Get(&branch)
if err != nil {
return err
} else if !exist || branch.IsDeleted {
return ErrBranchNotExist{
RepoID: repo.ID,
BranchName: from,
}
}

// 1. update branch in database
if n, err := sess.Where("repo_id=? AND name=?", repo.ID, from).Update(&Branch{
Name: to,
Expand Down
8 changes: 4 additions & 4 deletions models/git/branch_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type FindBranchOptions struct {
Keyword string
}

func (opts *FindBranchOptions) Cond() builder.Cond {
func (opts FindBranchOptions) ToConds() builder.Cond {
cond := builder.NewCond()
if opts.RepoID > 0 {
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
Expand All @@ -92,7 +92,7 @@ func (opts *FindBranchOptions) Cond() builder.Cond {
}

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

func orderByBranches(sess *xorm.Session, opts FindBranchOptions) *xorm.Session {
Expand All @@ -108,7 +108,7 @@ func orderByBranches(sess *xorm.Session, opts FindBranchOptions) *xorm.Session {
}

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

func FindBranchNames(ctx context.Context, opts FindBranchOptions) ([]string, error) {
sess := db.GetEngine(ctx).Select("name").Where(opts.Cond())
sess := db.GetEngine(ctx).Select("name").Where(opts.ToConds())
if opts.PageSize > 0 && !opts.IsListAll() {
sess = db.SetSessionPagination(sess, &opts.ListOptions)
}
Expand Down
2 changes: 1 addition & 1 deletion models/git/branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAddDeletedBranch(t *testing.T) {
},
}

err := git_model.UpdateBranch(db.DefaultContext, repo.ID, secondBranch.PusherID, secondBranch.Name, commit)
_, err := git_model.UpdateBranch(db.DefaultContext, repo.ID, secondBranch.PusherID, secondBranch.Name, commit)
assert.NoError(t, err)
}

Expand Down
15 changes: 15 additions & 0 deletions options/license/xkeyboard-config-Zinoviev
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright (C) 1999, 2000 by Anton Zinoviev <anton@lml.bas.bg>

This software may be used, modified, copied, distributed, and sold,
in both source and binary form provided that the above copyright
and these terms are retained. Under no circumstances is the author
responsible for the proper functioning of this software, nor does
the author assume any responsibility for damages incurred with its
use.

Permission is granted to anyone to use, distribute and modify
this file in any way, provided that the above copyright notice
is left intact and the author of the modification summarizes
the changes in this header.

This file is distributed without any expressed or implied warranty.
12 changes: 6 additions & 6 deletions options/locale/locale_fr-FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ cancel=Annuler
language=Langue
ui=Thème
hidden_comment_types=Catégories de commentaires masqués
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. »
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. »
hidden_comment_types.ref_tooltip=Commentaires où ce ticket a été référencé sur un autre ticket, révision, etc.
hidden_comment_types.issue_ref_tooltip=Commentaires où l’utilisateur change la branche/étiquette associée au ticket
comment_type_group_reference=Référence
Expand Down Expand Up @@ -3227,7 +3227,7 @@ comment_pull=`a commenté la demande d’ajout <a href="%[1]s">%[3]s#%[2]s</a>`
merge_pull_request=`a fusionné la demande d’ajout <a href="%[1]s">%[3]s#%[2]s</a>`
auto_merge_pull_request=`a fusionné automatiquement la demande d’ajout <a href="%[1]s">%[3]s#%[2]s</a>`
transfer_repo=a transféré le dépôt <code>%s</code> vers <a href="%s">%s</a>
push_tag=a poussé l’étiquette <a href="%[2]s">%[3]s</a> vers <a href="%[1]s">%[4]s</a>
push_tag=a poussé l’étiquette <a href="%[2]s">%[3]s</a> de <a href="%[1]s">%[4]s</a>
delete_tag=a supprimé l’étiquette %[2]s de <a href="%[1]s">%[3]s</a>
delete_branch=a supprimée la branche %[2]s de <a href="%[1]s">%[3]s</a>
compare_branch=Comparer
Expand All @@ -3236,12 +3236,12 @@ compare_commits_general=Comparer les révisions
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>.
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>.
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
approve_pull_request=`a approuvé <a href="%[1]s">%[3]s#%[2]s</a>.`
approve_pull_request=`a approuvé <a href="%[1]s">%[3]s#%[2]s</a>`
reject_pull_request=`a suggérés des changements pour <a href="%[1]s">%[3]s#%[2]s</a>`
publish_release=`a publié <a href="%[2]s"> "%[4]s" </a> à <a href="%[1]s">%[3]s</a>`
review_dismissed=`a révoqué l’évaluation de <b>%[4]s</b> sur <a href="%[1]s">%[3]s#%[2]s</a>.`
publish_release=`a publié <a href="%[2]s"> "%[4]s" </a> dans <a href="%[1]s">%[3]s</a>`
review_dismissed=`a révoqué l’évaluation de <b>%[4]s</b> dans <a href="%[1]s">%[3]s#%[2]s</a>`
review_dismissed_reason=Raison :
create_branch=a créé la branche <a href="%[2]s">%[3]s</a> dans <a href="%[1]s">%[4]s</a>.
create_branch=a créé la branche <a href="%[2]s">%[3]s</a> dans <a href="%[1]s">%[4]s</a>
starred_repo=aime <a href="%[1]s">%[2]s</a>
watched_repo=observe <a href="%[1]s">%[2]s</a>
Expand Down
Loading

0 comments on commit 386f33f

Please sign in to comment.