|
|
|
@ -5,6 +5,7 @@ package actions
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"bytes"
|
|
|
|
|
|
|
|
stdCtx "context"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
"slices"
|
|
|
|
"slices"
|
|
|
|
@ -245,7 +246,7 @@ func List(ctx *context.Context) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := loadIsRefDeleted(ctx, runs); err != nil {
|
|
|
|
if err := loadIsRefDeleted(ctx, ctx.Repo.Repository.ID, runs); err != nil {
|
|
|
|
log.Error("LoadIsRefDeleted", err)
|
|
|
|
log.Error("LoadIsRefDeleted", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -273,7 +274,7 @@ func List(ctx *context.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
// loadIsRefDeleted loads the IsRefDeleted field for each run in the list.
|
|
|
|
// loadIsRefDeleted loads the IsRefDeleted field for each run in the list.
|
|
|
|
// TODO: move this function to models/actions/run_list.go but now it will result in a circular import.
|
|
|
|
// TODO: move this function to models/actions/run_list.go but now it will result in a circular import.
|
|
|
|
func loadIsRefDeleted(ctx *context.Context, runs actions_model.RunList) error {
|
|
|
|
func loadIsRefDeleted(ctx stdCtx.Context, repoID int64, runs actions_model.RunList) error {
|
|
|
|
branches := make(container.Set[string], len(runs))
|
|
|
|
branches := make(container.Set[string], len(runs))
|
|
|
|
for _, run := range runs {
|
|
|
|
for _, run := range runs {
|
|
|
|
refName := git.RefName(run.Ref)
|
|
|
|
refName := git.RefName(run.Ref)
|
|
|
|
@ -285,14 +286,14 @@ func loadIsRefDeleted(ctx *context.Context, runs actions_model.RunList) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
branchInfos, err := git_model.GetBranches(ctx, ctx.Repo.Repository.ID, branches.Values(), false)
|
|
|
|
branchInfos, err := git_model.GetBranches(ctx, repoID, branches.Values(), false)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
branchSet := git_model.BranchesToNamesSet(branchInfos)
|
|
|
|
branchSet := git_model.BranchesToNamesSet(branchInfos)
|
|
|
|
for _, run := range runs {
|
|
|
|
for _, run := range runs {
|
|
|
|
refName := git.RefName(run.Ref)
|
|
|
|
refName := git.RefName(run.Ref)
|
|
|
|
if refName.IsBranch() && !branchSet.Contains(run.Ref) {
|
|
|
|
if refName.IsBranch() && !branchSet.Contains(refName.ShortName()) {
|
|
|
|
run.IsRefDeleted = true
|
|
|
|
run.IsRefDeleted = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|