mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-08 18:04:14 +01:00
fix(api): error 500 on tag creation when a workflow exists
files_service.CreateCommitStatus must not explicitly call gitRepo.Close(), it will be called by the closer function. Calling it explicitly will cause the repository to be closed prematurely when obtained from the context, making it unusuable by the caller later on. For instance, as CreateCommitStatus is called indirectly when a workflow exists for the tag to be created, it will make the repositoryn in the context unusable for the tag creation API.
This commit is contained in:
parent
cc80e66153
commit
a53194f4b1
1 changed files with 0 additions and 2 deletions
|
@ -30,13 +30,11 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creato
|
||||||
defer closer.Close()
|
defer closer.Close()
|
||||||
|
|
||||||
if commit, err := gitRepo.GetCommit(sha); err != nil {
|
if commit, err := gitRepo.GetCommit(sha); err != nil {
|
||||||
gitRepo.Close()
|
|
||||||
return fmt.Errorf("GetCommit[%s]: %w", sha, err)
|
return fmt.Errorf("GetCommit[%s]: %w", sha, err)
|
||||||
} else if len(sha) != git.SHAFullLength {
|
} else if len(sha) != git.SHAFullLength {
|
||||||
// use complete commit sha
|
// use complete commit sha
|
||||||
sha = commit.ID.String()
|
sha = commit.ID.String()
|
||||||
}
|
}
|
||||||
gitRepo.Close()
|
|
||||||
|
|
||||||
if err := git_model.NewCommitStatus(ctx, git_model.NewCommitStatusOptions{
|
if err := git_model.NewCommitStatus(ctx, git_model.NewCommitStatusOptions{
|
||||||
Repo: repo,
|
Repo: repo,
|
||||||
|
|
Loading…
Reference in a new issue