fix: rename api.{List,}ActionRun to api.{List,}RepoActionRun (#8066)
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions

This variable name conflict happened because both

https://codeberg.org/forgejo/forgejo/pulls/7699

and

https://codeberg.org/forgejo/forgejo/pulls/7508

introduced the same names in different places and were merged at the same time.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8066
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-06-04 07:09:06 +02:00 committed by Earl Warren
parent 4dd0514022
commit 2529923dea
6 changed files with 86 additions and 86 deletions

View file

@ -34,7 +34,7 @@ type ActionTaskResponse struct {
}
// ActionRun represents an ActionRun
type ActionRun struct {
type RepoActionRun struct {
ID int64 `json:"id"`
Name string `json:"name"`
RunNumber int64 `json:"run_number"`
@ -48,7 +48,7 @@ type ActionRun struct {
}
// ListActionRunResponse return a list of ActionRun
type ListActionRunResponse struct {
Entries []*ActionRun `json:"workflow_runs"`
type ListRepoActionRunResponse struct {
Entries []*RepoActionRun `json:"workflow_runs"`
TotalCount int64 `json:"total_count"`
}

View file

@ -748,7 +748,7 @@ func ListActionRuns(ctx *context.APIContext) {
// type: string
// responses:
// "200":
// "$ref": "#/responses/ActionRunList"
// "$ref": "#/responses/RepoActionRunList"
// "400":
// "$ref": "#/responses/error"
// "403":
@ -779,12 +779,12 @@ func ListActionRuns(ctx *context.APIContext) {
return
}
res := new(api.ListActionRunResponse)
res := new(api.ListRepoActionRunResponse)
res.TotalCount = total
res.Entries = make([]*api.ActionRun, len(runs))
res.Entries = make([]*api.RepoActionRun, len(runs))
for i, r := range runs {
cr, err := convert.ToActionRun(ctx, r)
cr, err := convert.ToRepoActionRun(ctx, r)
if err != nil {
ctx.Error(http.StatusInternalServerError, "ToActionRun", err)
return
@ -821,7 +821,7 @@ func GetActionRun(ctx *context.APIContext) {
// required: true
// responses:
// "200":
// "$ref": "#/responses/ActionRun"
// "$ref": "#/responses/RepoActionRun"
// "400":
// "$ref": "#/responses/error"
// "403":
@ -844,9 +844,9 @@ func GetActionRun(ctx *context.APIContext) {
return
}
res, err := convert.ToActionRun(ctx, run)
res, err := convert.ToRepoActionRun(ctx, run)
if err != nil {
ctx.Error(http.StatusInternalServerError, "ToActionRun", err)
ctx.Error(http.StatusInternalServerError, "ToRepoActionRun", err)
return
}

View file

@ -456,16 +456,16 @@ type swaggerSyncForkInfo struct {
Body []api.SyncForkInfo `json:"body"`
}
// ActionRunList
// swagger:response ActionRunList
// RepoActionRunList
// swagger:response RepoActionRunList
type swaggerRepoActionRunList struct {
// in:body
Body api.ListActionRunResponse `json:"body"`
Body api.ListRepoActionRunResponse `json:"body"`
}
// ActionRun
// swagger:response ActionRun
// RepoActionRun
// swagger:response RepoActionRun
type swaggerRepoActionRun struct {
// in:body
Body api.ActionRun `json:"body"`
Body api.RepoActionRun `json:"body"`
}

View file

@ -222,8 +222,8 @@ func ToActionTask(ctx context.Context, t *actions_model.ActionTask) (*api.Action
}, nil
}
// ToActionRun convert a actions_model.ActionRun to an api.ActionRun
func ToActionRun(ctx context.Context, r *actions_model.ActionRun) (*api.ActionRun, error) {
// ToRepoActionRun convert a actions_model.ActionRun to an api.RepoActionRun
func ToRepoActionRun(ctx context.Context, r *actions_model.ActionRun) (*api.RepoActionRun, error) {
if err := r.LoadAttributes(ctx); err != nil {
return nil, err
}
@ -231,7 +231,7 @@ func ToActionRun(ctx context.Context, r *actions_model.ActionRun) (*api.ActionRu
url := strings.TrimSuffix(setting.AppURL, "/") + r.Link()
actor := ToUser(ctx, r.TriggerUser, nil)
return &api.ActionRun{
return &api.RepoActionRun{
ID: r.ID,
Name: r.Title,
HeadBranch: r.PrettyRef(),

View file

@ -4985,7 +4985,7 @@
],
"responses": {
"200": {
"$ref": "#/responses/ActionRunList"
"$ref": "#/responses/RepoActionRunList"
},
"400": {
"$ref": "#/responses/error"
@ -5032,7 +5032,7 @@
],
"responses": {
"200": {
"$ref": "#/responses/ActionRun"
"$ref": "#/responses/RepoActionRun"
},
"400": {
"$ref": "#/responses/error"
@ -21067,54 +21067,6 @@
},
"x-go-package": "forgejo.org/modules/structs"
},
"ActionRun": {
"description": "ActionRun represents an ActionRun",
"type": "object",
"properties": {
"event": {
"type": "string",
"x-go-name": "Event"
},
"head_branch": {
"type": "string",
"x-go-name": "HeadBranch"
},
"head_sha": {
"type": "string",
"x-go-name": "HeadSHA"
},
"id": {
"type": "integer",
"format": "int64",
"x-go-name": "ID"
},
"name": {
"type": "string",
"x-go-name": "Name"
},
"run_number": {
"type": "integer",
"format": "int64",
"x-go-name": "RunNumber"
},
"status": {
"type": "string",
"x-go-name": "Status"
},
"triggering_actor": {
"$ref": "#/definitions/User"
},
"url": {
"type": "string",
"x-go-name": "URL"
},
"workflow_id": {
"type": "string",
"x-go-name": "WorkflowID"
}
},
"x-go-package": "forgejo.org/modules/structs"
},
"ActionRunJob": {
"description": "ActionRunJob represents a job of a run",
"type": "object",
@ -25571,7 +25523,7 @@
},
"x-go-package": "forgejo.org/modules/structs"
},
"ListActionRunResponse": {
"ListRepoActionRunResponse": {
"description": "ListActionRunResponse return a list of ActionRun",
"type": "object",
"properties": {
@ -25583,7 +25535,7 @@
"workflow_runs": {
"type": "array",
"items": {
"$ref": "#/definitions/ActionRun"
"$ref": "#/definitions/RepoActionRun"
},
"x-go-name": "Entries"
}
@ -27348,6 +27300,54 @@
},
"x-go-package": "forgejo.org/modules/structs"
},
"RepoActionRun": {
"description": "ActionRun represents an ActionRun",
"type": "object",
"properties": {
"event": {
"type": "string",
"x-go-name": "Event"
},
"head_branch": {
"type": "string",
"x-go-name": "HeadBranch"
},
"head_sha": {
"type": "string",
"x-go-name": "HeadSHA"
},
"id": {
"type": "integer",
"format": "int64",
"x-go-name": "ID"
},
"name": {
"type": "string",
"x-go-name": "Name"
},
"run_number": {
"type": "integer",
"format": "int64",
"x-go-name": "RunNumber"
},
"status": {
"type": "string",
"x-go-name": "Status"
},
"triggering_actor": {
"$ref": "#/definitions/User"
},
"url": {
"type": "string",
"x-go-name": "URL"
},
"workflow_id": {
"type": "string",
"x-go-name": "WorkflowID"
}
},
"x-go-package": "forgejo.org/modules/structs"
},
"RepoCollaboratorPermission": {
"description": "RepoCollaboratorPermission to get repository permission for a collaborator",
"type": "object",
@ -28794,18 +28794,6 @@
}
}
},
"ActionRun": {
"description": "ActionRun",
"schema": {
"$ref": "#/definitions/ActionRun"
}
},
"ActionRunList": {
"description": "ActionRunList",
"schema": {
"$ref": "#/definitions/ListActionRunResponse"
}
},
"ActionVariable": {
"description": "ActionVariable",
"schema": {
@ -29566,6 +29554,18 @@
}
}
},
"RepoActionRun": {
"description": "RepoActionRun",
"schema": {
"$ref": "#/definitions/RepoActionRun"
}
},
"RepoActionRunList": {
"description": "RepoActionRunList",
"schema": {
"$ref": "#/definitions/ListRepoActionRunResponse"
}
},
"RepoCollaboratorPermission": {
"description": "RepoCollaboratorPermission",
"schema": {

View file

@ -169,7 +169,7 @@ func TestAPIGetListActionRun(t *testing.T) {
req.AddTokenAuth(token)
res := MakeRequest(t, req, http.StatusOK)
apiRuns := new(api.ListActionRunResponse)
apiRuns := new(api.ListRepoActionRunResponse)
DecodeJSON(t, res, apiRuns)
assert.Equal(t, int64(len(tt.expectedIDs)), apiRuns.TotalCount)
@ -231,7 +231,7 @@ func TestAPIGetActionRun(t *testing.T) {
}
dbRun := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{ID: tt.runID})
apiRun := new(api.ActionRun)
apiRun := new(api.RepoActionRun)
DecodeJSON(t, res, apiRun)
assert.Equal(t, dbRun.Index, apiRun.RunNumber)