-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Detect whether action view branch was deleted #32764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
d37bd75
2b6a605
a87efd7
890863f
450b309
affe773
3a06760
f45c6f6
a16748d
de6160a
434e3ed
581c194
632b154
e1eab27
f1fa72d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,6 +245,11 @@ func List(ctx *context.Context) { | |
return | ||
} | ||
|
||
if err := loadIsRefDeleted(ctx, runs); err != nil { | ||
ctx.ServerError("LoadIsRefDeleted", err) | ||
lunny marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
return | ||
} | ||
|
||
ctx.Data["Runs"] = runs | ||
|
||
actors, err := actions_model.GetActors(ctx, ctx.Repo.Repository.ID) | ||
|
@@ -267,6 +272,36 @@ func List(ctx *context.Context) { | |
ctx.HTML(http.StatusOK, tplListActions) | ||
} | ||
|
||
// 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. | ||
func loadIsRefDeleted(ctx *context.Context, runs actions_model.RunList) error { | ||
branchRuns := make(map[string][]*actions_model.ActionRun) | ||
branches := make(container.Set[string], len(runs)) | ||
for _, run := range runs { | ||
refName := git.RefName(run.Ref) | ||
if refName.IsBranch() { | ||
branchName := refName.ShortName() | ||
run.IsRefDeleted = true // assume it's deleted then if it's found in the database it's not deleted | ||
branchRuns[branchName] = append(branchRuns[branchName], run) | ||
|
||
branches.Add(branchName) | ||
} | ||
} | ||
if len(branches) == 0 { | ||
return nil | ||
} | ||
branchInfos, err := git_model.GetExistBranches(ctx, ctx.Repo.Repository.ID, branches.Values()) | ||
if err != nil { | ||
return err | ||
} | ||
for _, branchInfo := range branchInfos { | ||
branchRun := branchRuns[branchInfo.Name] | ||
for _, br := range branchRun { | ||
br.IsRefDeleted = false | ||
} | ||
} | ||
lunny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return nil | ||
} | ||
|
||
type WorkflowDispatchInput struct { | ||
Name string `yaml:"name"` | ||
Description string `yaml:"description"` | ||
|
Uh oh!
There was an error while loading. Please reload this page.