mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-28 08:45:48 +00:00
646ea0f253
Deploy keys only work over SSH. A deploy token is their counterpart for HTTPS: a repository scoped credential, used as the password of a Git request, with read or read and write access. It covers Git operations and LFS, and can be regenerated in place. Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: Claude Mythos <noreply@anthropic.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: bircni <bircni@icloud.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package actions
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitea.dev/models/db"
|
|
user_model "gitea.dev/models/user"
|
|
"gitea.dev/modules/container"
|
|
)
|
|
|
|
type ActionRunAttemptList []*ActionRunAttempt
|
|
|
|
// GetUserIDs returns a slice of user's id
|
|
func (attempts ActionRunAttemptList) GetUserIDs() []int64 {
|
|
return container.FilterSlice(attempts, func(attempt *ActionRunAttempt) (int64, bool) {
|
|
return attempt.TriggerUserID, true
|
|
})
|
|
}
|
|
|
|
func (attempts ActionRunAttemptList) LoadTriggerUser(ctx context.Context) error {
|
|
userIDs := attempts.GetUserIDs()
|
|
users := make(map[int64]*user_model.User, len(userIDs))
|
|
if err := db.GetEngine(ctx).In("id", userIDs).Find(&users); err != nil {
|
|
return err
|
|
}
|
|
for _, attempt := range attempts {
|
|
attempt.TriggerUser = user_model.GetPossibleUserFromMap(attempt.TriggerUserID, users)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ListRunAttemptsByRunID returns all attempts of a run, ordered by attempt number DESC (newest first).
|
|
func ListRunAttemptsByRunID(ctx context.Context, runID int64) (ActionRunAttemptList, error) {
|
|
var attempts ActionRunAttemptList
|
|
return attempts, db.GetEngine(ctx).Where("run_id=?", runID).OrderBy("attempt DESC").Find(&attempts)
|
|
}
|