Skip to content

Commit 041b0fe

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Add API to support link package to repository and unlink it (go-gitea#33481) [skip ci] Updated translations via Crowdin Update JS and PY dependencies (go-gitea#33587) [chore] add git mailmap for proper attribution of authorship (go-gitea#33612) Move commits signature and verify functions to service layers (go-gitea#33605) add spacing between sign in button's icon and text (go-gitea#33609) enable literal string for code search (go-gitea#33590) [skip ci] Updated translations via Crowdin Artifacts download api for artifact actions v4 (go-gitea#33510) Fix bug when get commit (go-gitea#33602) Fix mirror bug (go-gitea#33597) Fix typo in HTML attribute (go-gitea#33599) Use default Git timeout when checking repo health (go-gitea#33593) Improve commits list performance to reduce unnecessary database queries (go-gitea#33528) Performance optimization for pull request files loading comments attachments (go-gitea#33585) Fix PR's target branch dropdown (go-gitea#33589)
2 parents 9c63998 + 5df9fd3 commit 041b0fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+4931
-4434
lines changed

.mailmap

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+

cmd/migrate_storage.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func migrateActionsLog(ctx context.Context, dstStorage storage.ObjectStorage) er
196196

197197
func migrateActionsArtifacts(ctx context.Context, dstStorage storage.ObjectStorage) error {
198198
return db.Iterate(ctx, nil, func(ctx context.Context, artifact *actions_model.ActionArtifact) error {
199-
if artifact.Status == int64(actions_model.ArtifactStatusExpired) {
199+
if artifact.Status == actions_model.ArtifactStatusExpired {
200200
return nil
201201
}
202202

models/actions/artifact.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type ActionArtifact struct {
4848
ContentEncoding string // The content encoding of the artifact
4949
ArtifactPath string `xorm:"index unique(runid_name_path)"` // The path to the artifact when runner uploads it
5050
ArtifactName string `xorm:"index unique(runid_name_path)"` // The name of the artifact when runner uploads it
51-
Status int64 `xorm:"index"` // The status of the artifact, uploading, expired or need-delete
51+
Status ArtifactStatus `xorm:"index"` // The status of the artifact, uploading, expired or need-delete
5252
CreatedUnix timeutil.TimeStamp `xorm:"created"`
5353
UpdatedUnix timeutil.TimeStamp `xorm:"updated index"`
5454
ExpiredUnix timeutil.TimeStamp `xorm:"index"` // The time when the artifact will be expired
@@ -68,7 +68,7 @@ func CreateArtifact(ctx context.Context, t *ActionTask, artifactName, artifactPa
6868
RepoID: t.RepoID,
6969
OwnerID: t.OwnerID,
7070
CommitSHA: t.CommitSHA,
71-
Status: int64(ArtifactStatusUploadPending),
71+
Status: ArtifactStatusUploadPending,
7272
ExpiredUnix: timeutil.TimeStamp(time.Now().Unix() + timeutil.Day*expiredDays),
7373
}
7474
if _, err := db.GetEngine(ctx).Insert(artifact); err != nil {
@@ -108,10 +108,11 @@ func UpdateArtifactByID(ctx context.Context, id int64, art *ActionArtifact) erro
108108

109109
type FindArtifactsOptions struct {
110110
db.ListOptions
111-
RepoID int64
112-
RunID int64
113-
ArtifactName string
114-
Status int
111+
RepoID int64
112+
RunID int64
113+
ArtifactName string
114+
Status int
115+
FinalizedArtifactsV4 bool
115116
}
116117

117118
func (opts FindArtifactsOptions) ToOrders() string {
@@ -134,6 +135,10 @@ func (opts FindArtifactsOptions) ToConds() builder.Cond {
134135
if opts.Status > 0 {
135136
cond = cond.And(builder.Eq{"status": opts.Status})
136137
}
138+
if opts.FinalizedArtifactsV4 {
139+
cond = cond.And(builder.Eq{"status": ArtifactStatusUploadConfirmed}.Or(builder.Eq{"status": ArtifactStatusExpired}))
140+
cond = cond.And(builder.Eq{"content_encoding": "application/zip"})
141+
}
137142

138143
return cond
139144
}
@@ -172,18 +177,18 @@ func ListPendingDeleteArtifacts(ctx context.Context, limit int) ([]*ActionArtifa
172177

173178
// SetArtifactExpired sets an artifact to expired
174179
func SetArtifactExpired(ctx context.Context, artifactID int64) error {
175-
_, err := db.GetEngine(ctx).Where("id=? AND status = ?", artifactID, ArtifactStatusUploadConfirmed).Cols("status").Update(&ActionArtifact{Status: int64(ArtifactStatusExpired)})
180+
_, err := db.GetEngine(ctx).Where("id=? AND status = ?", artifactID, ArtifactStatusUploadConfirmed).Cols("status").Update(&ActionArtifact{Status: ArtifactStatusExpired})
176181
return err
177182
}
178183

179184
// SetArtifactNeedDelete sets an artifact to need-delete, cron job will delete it
180185
func SetArtifactNeedDelete(ctx context.Context, runID int64, name string) error {
181-
_, err := db.GetEngine(ctx).Where("run_id=? AND artifact_name=? AND status = ?", runID, name, ArtifactStatusUploadConfirmed).Cols("status").Update(&ActionArtifact{Status: int64(ArtifactStatusPendingDeletion)})
186+
_, err := db.GetEngine(ctx).Where("run_id=? AND artifact_name=? AND status = ?", runID, name, ArtifactStatusUploadConfirmed).Cols("status").Update(&ActionArtifact{Status: ArtifactStatusPendingDeletion})
182187
return err
183188
}
184189

185190
// SetArtifactDeleted sets an artifact to deleted
186191
func SetArtifactDeleted(ctx context.Context, artifactID int64) error {
187-
_, err := db.GetEngine(ctx).ID(artifactID).Cols("status").Update(&ActionArtifact{Status: int64(ArtifactStatusDeleted)})
192+
_, err := db.GetEngine(ctx).ID(artifactID).Cols("status").Update(&ActionArtifact{Status: ArtifactStatusDeleted})
188193
return err
189194
}

models/asymkey/gpg_key.go

+3-33
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func GPGKeyToEntity(ctx context.Context, k *GPGKey) (*openpgp.Entity, error) {
106106
if err != nil {
107107
return nil, err
108108
}
109-
keys, err := checkArmoredGPGKeyString(impKey.Content)
109+
keys, err := CheckArmoredGPGKeyString(impKey.Content)
110110
if err != nil {
111111
return nil, err
112112
}
@@ -115,7 +115,7 @@ func GPGKeyToEntity(ctx context.Context, k *GPGKey) (*openpgp.Entity, error) {
115115

116116
// parseSubGPGKey parse a sub Key
117117
func parseSubGPGKey(ownerID int64, primaryID string, pubkey *packet.PublicKey, expiry time.Time) (*GPGKey, error) {
118-
content, err := base64EncPubKey(pubkey)
118+
content, err := Base64EncPubKey(pubkey)
119119
if err != nil {
120120
return nil, err
121121
}
@@ -183,7 +183,7 @@ func parseGPGKey(ctx context.Context, ownerID int64, e *openpgp.Entity, verified
183183
}
184184
}
185185

186-
content, err := base64EncPubKey(pubkey)
186+
content, err := Base64EncPubKey(pubkey)
187187
if err != nil {
188188
return nil, err
189189
}
@@ -239,33 +239,3 @@ func DeleteGPGKey(ctx context.Context, doer *user_model.User, id int64) (err err
239239

240240
return committer.Commit()
241241
}
242-
243-
func checkKeyEmails(ctx context.Context, email string, keys ...*GPGKey) (bool, string) {
244-
uid := int64(0)
245-
var userEmails []*user_model.EmailAddress
246-
var user *user_model.User
247-
for _, key := range keys {
248-
for _, e := range key.Emails {
249-
if e.IsActivated && (email == "" || strings.EqualFold(e.Email, email)) {
250-
return true, e.Email
251-
}
252-
}
253-
if key.Verified && key.OwnerID != 0 {
254-
if uid != key.OwnerID {
255-
userEmails, _ = user_model.GetEmailAddresses(ctx, key.OwnerID)
256-
uid = key.OwnerID
257-
user = &user_model.User{ID: uid}
258-
_, _ = user_model.GetUser(ctx, user)
259-
}
260-
for _, e := range userEmails {
261-
if e.IsActivated && (email == "" || strings.EqualFold(e.Email, email)) {
262-
return true, e.Email
263-
}
264-
}
265-
if user.KeepEmailPrivate && strings.EqualFold(email, user.GetEmail()) {
266-
return true, user.GetEmail()
267-
}
268-
}
269-
}
270-
return false, email
271-
}

models/asymkey/gpg_key_add.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func addGPGSubKey(ctx context.Context, key *GPGKey) (err error) {
6767

6868
// AddGPGKey adds new public key to database.
6969
func AddGPGKey(ctx context.Context, ownerID int64, content, token, signature string) ([]*GPGKey, error) {
70-
ekeys, err := checkArmoredGPGKeyString(content)
70+
ekeys, err := CheckArmoredGPGKeyString(content)
7171
if err != nil {
7272
return nil, err
7373
}

0 commit comments

Comments
 (0)