Skip to content

Commit c919783

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix duplicate ID when deleting repo (go-gitea#28520) chore(api): support ignore password if login source type is LDAP for creating user API (go-gitea#28491) Update go dependencies (go-gitea#28518) Bump google/go-github to v57 (go-gitea#28514) Only check online runner when detecting matching runners in workflows (go-gitea#28286) Add orphaned topic consistency check (go-gitea#28507) Improve the prompt for "ssh-keygen sign" (go-gitea#28509)
2 parents a17d5f9 + 128eac9 commit c919783

File tree

19 files changed

+350
-439
lines changed

19 files changed

+350
-439
lines changed

assets/go-licenses.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/backport/backport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"strings"
1818
"syscall"
1919

20-
"github.com/google/go-github/v53/github"
20+
"github.com/google/go-github/v57/github"
2121
"github.com/urfave/cli/v2"
2222
"gopkg.in/yaml.v3"
2323
)

go.mod

Lines changed: 83 additions & 83 deletions
Large diffs are not rendered by default.

go.sum

Lines changed: 175 additions & 309 deletions
Large diffs are not rendered by default.

models/actions/runner.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ type ActionRunner struct {
5151
Deleted timeutil.TimeStamp `xorm:"deleted"`
5252
}
5353

54+
const (
55+
RunnerOfflineTime = time.Minute
56+
RunnerIdleTime = 10 * time.Second
57+
)
58+
5459
// BelongsToOwnerName before calling, should guarantee that all attributes are loaded
5560
func (r *ActionRunner) BelongsToOwnerName() string {
5661
if r.RepoID != 0 {
@@ -76,11 +81,12 @@ func (r *ActionRunner) BelongsToOwnerType() types.OwnerType {
7681
return types.OwnerTypeSystemGlobal
7782
}
7883

84+
// if the logic here changed, you should also modify FindRunnerOptions.ToCond
7985
func (r *ActionRunner) Status() runnerv1.RunnerStatus {
80-
if time.Since(r.LastOnline.AsTime()) > time.Minute {
86+
if time.Since(r.LastOnline.AsTime()) > RunnerOfflineTime {
8187
return runnerv1.RunnerStatus_RUNNER_STATUS_OFFLINE
8288
}
83-
if time.Since(r.LastActive.AsTime()) > 10*time.Second {
89+
if time.Since(r.LastActive.AsTime()) > RunnerIdleTime {
8490
return runnerv1.RunnerStatus_RUNNER_STATUS_IDLE
8591
}
8692
return runnerv1.RunnerStatus_RUNNER_STATUS_ACTIVE
@@ -153,6 +159,7 @@ type FindRunnerOptions struct {
153159
OwnerID int64
154160
Sort string
155161
Filter string
162+
IsOnline util.OptionalBool
156163
WithAvailable bool // not only runners belong to, but also runners can be used
157164
}
158165

@@ -178,6 +185,12 @@ func (opts FindRunnerOptions) ToConds() builder.Cond {
178185
if opts.Filter != "" {
179186
cond = cond.And(builder.Like{"name", opts.Filter})
180187
}
188+
189+
if opts.IsOnline.IsTrue() {
190+
cond = cond.And(builder.Gt{"last_online": time.Now().Add(-RunnerOfflineTime).Unix()})
191+
} else if opts.IsOnline.IsFalse() {
192+
cond = cond.And(builder.Lte{"last_online": time.Now().Add(-RunnerOfflineTime).Unix()})
193+
}
181194
return cond
182195
}
183196

models/repo/topic.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,13 @@ func syncTopicsInRepository(sess db.Engine, repoID int64) error {
377377
}
378378
return nil
379379
}
380+
381+
// CountOrphanedAttachments returns the number of topics that don't belong to any repository.
382+
func CountOrphanedTopics(ctx context.Context) (int64, error) {
383+
return db.GetEngine(ctx).Where("repo_count = 0").Count(new(Topic))
384+
}
385+
386+
// DeleteOrphanedAttachments delete all topics that don't belong to any repository.
387+
func DeleteOrphanedTopics(ctx context.Context) (int64, error) {
388+
return db.GetEngine(ctx).Where("repo_count = 0").Delete(new(Topic))
389+
}

modules/doctor/dbconsistency.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ func checkDBConsistency(ctx context.Context, logger log.Logger, autofix bool) er
158158
Fixer: actions_model.FixRunnersWithoutBelongingOwner,
159159
FixedMessage: "Removed",
160160
},
161+
{
162+
Name: "Topics with empty repository count",
163+
Counter: repo_model.CountOrphanedTopics,
164+
Fixer: repo_model.DeleteOrphanedTopics,
165+
FixedMessage: "Removed",
166+
},
161167
}
162168

163169
// TODO: function to recalc all counters

modules/git/repo_commitgraph_gogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (r *Repository) CommitNodeIndex() (cgobject.CommitNodeIndex, *os.File) {
2222

2323
file, err := os.Open(indexPath)
2424
if err == nil {
25-
var index commitgraph.Index
25+
var index commitgraph.Index // TODO: in newer go-git, it might need to use "github.com/go-git/go-git/v5/plumbing/format/commitgraph/v2" package to compile
2626
index, err = commitgraph.OpenFileIndex(file)
2727
if err == nil {
2828
return cgobject.NewGraphCommitNodeIndex(index, r.gogitRepo.Storer), file

modules/structs/admin_user.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ type CreateUserOption struct {
1515
FullName string `json:"full_name" binding:"MaxSize(100)"`
1616
// required: true
1717
// swagger:strfmt email
18-
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
19-
// required: true
20-
Password string `json:"password" binding:"Required;MaxSize(255)"`
18+
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
19+
Password string `json:"password" binding:"MaxSize(255)"`
2120
MustChangePassword *bool `json:"must_change_password"`
2221
SendNotify bool `json:"send_notify"`
2322
Restricted *bool `json:"restricted"`

options/locale/locale_en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,7 @@ runs.commit = Commit
35253525
runs.scheduled = Scheduled
35263526
runs.pushed_by = pushed by
35273527
runs.invalid_workflow_helper = Workflow config file is invalid. Please check your config file: %s
3528-
runs.no_matching_runner_helper = No matching runner: %s
3528+
runs.no_matching_online_runner_helper = No matching online runner with label: %s
35293529
runs.actor = Actor
35303530
runs.status = Status
35313531
runs.actors_no_select = All actors

0 commit comments

Comments
 (0)