mirror of
https://github.com/go-gitea/gitea
synced 2025-07-27 12:48:37 +00:00
Detect whether action view branch was deleted (#32764)
Fix #32761 
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
"code.gitea.io/gitea/models/perm"
|
||||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
@@ -136,8 +137,9 @@ type ViewUser struct {
|
||||
}
|
||||
|
||||
type ViewBranch struct {
|
||||
Name string `json:"name"`
|
||||
Link string `json:"link"`
|
||||
Name string `json:"name"`
|
||||
Link string `json:"link"`
|
||||
IsDeleted bool `json:"isDeleted"`
|
||||
}
|
||||
|
||||
type ViewJobStep struct {
|
||||
@@ -236,6 +238,16 @@ func ViewPost(ctx *context_module.Context) {
|
||||
Name: run.PrettyRef(),
|
||||
Link: run.RefLink(),
|
||||
}
|
||||
refName := git.RefName(run.Ref)
|
||||
if refName.IsBranch() {
|
||||
b, err := git_model.GetBranch(ctx, ctx.Repo.Repository.ID, refName.ShortName())
|
||||
if err != nil && !git_model.IsErrBranchNotExist(err) {
|
||||
log.Error("GetBranch: %v", err)
|
||||
} else if git_model.IsErrBranchNotExist(err) || (b != nil && b.IsDeleted) {
|
||||
branch.IsDeleted = true
|
||||
}
|
||||
}
|
||||
|
||||
resp.State.Run.Commit = ViewCommit{
|
||||
ShortSha: base.ShortSha(run.CommitSHA),
|
||||
Link: fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA),
|
||||
|
Reference in New Issue
Block a user