Skip to content

Commit 33e6466

Browse files
Rename properties/variables to use URL and ID instead of "Url" and "Id"
Delete obsolete files left behind in rebase. Fix linting issues.
1 parent 7580432 commit 33e6466

File tree

9 files changed

+24
-21
lines changed

9 files changed

+24
-21
lines changed

modules/auth/repo_form.go

Whitespace-only changes.

modules/webhook/deliver.go

Whitespace-only changes.

modules/webhook/webhook.go

Whitespace-only changes.

routers/repo/webhook.go

Whitespace-only changes.

routers/routes/routes.go

Whitespace-only changes.

routers/web/repo/webhook.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -556,24 +556,24 @@ func TeamCityHooksNewPost(ctx *context.Context) {
556556
}
557557

558558
meta, err := json.Marshal(&webhook_service.TeamCityMeta{
559-
HostUrl: form.HostUrl,
559+
HostURL: form.HostURL,
560560
AuthToken: form.AuthToken,
561-
VcsRootId: form.VcsRootId,
561+
VcsRootID: form.VcsRootID,
562562
})
563563
if err != nil {
564564
ctx.ServerError("Marshal", err)
565565
return
566566
}
567567

568-
payloadUrl, err := buildTeamCityUrl(form)
568+
payloadURL, err := buildTeamCityURL(form)
569569
if err != nil {
570-
ctx.ServerError("buildTeamCityUrl", err)
570+
ctx.ServerError("buildTeamCityURL", err)
571571
return
572572
}
573573

574574
w := &webhook.Webhook{
575575
RepoID: orCtx.RepoID,
576-
URL: payloadUrl,
576+
URL: payloadURL,
577577
ContentType: webhook.ContentTypeForm,
578578
HookEvent: ParseHookEvent(form.WebhookForm),
579579
IsActive: form.Active,
@@ -1210,19 +1210,18 @@ func TeamCityHooksEditPost(ctx *context.Context) {
12101210
}
12111211

12121212
meta, err := json.Marshal(&webhook_service.TeamCityMeta{
1213-
HostUrl: form.HostUrl,
1213+
HostURL: form.HostURL,
12141214
AuthToken: form.AuthToken,
1215-
VcsRootId: form.VcsRootId,
1215+
VcsRootID: form.VcsRootID,
12161216
})
1217-
12181217
if err != nil {
12191218
ctx.ServerError("Marshal", err)
12201219
return
12211220
}
12221221

1223-
w.URL, err = buildTeamCityUrl(form)
1222+
w.URL, err = buildTeamCityURL(form)
12241223
if err != nil {
1225-
ctx.ServerError("buildTeamCityUrl", err)
1224+
ctx.ServerError("buildTeamCityURL", err)
12261225
return
12271226
}
12281227

@@ -1243,13 +1242,14 @@ func TeamCityHooksEditPost(ctx *context.Context) {
12431242
ctx.Redirect(fmt.Sprintf("%s/%d", orCtx.Link, w.ID))
12441243
}
12451244

1246-
func buildTeamCityUrl(meta *forms.NewTeamCityHookForm) (string, error) {
1247-
tcUrl, err := url.Parse(meta.HostUrl)
1245+
// buildTeamCityURL returns the correct REST API url for a TeamCity POST request.
1246+
func buildTeamCityURL(meta *forms.NewTeamCityHookForm) (string, error) {
1247+
tcURL, err := url.Parse(meta.HostURL)
12481248
if err != nil {
12491249
return "", err
12501250
}
12511251

1252-
return fmt.Sprintf("%s/app/rest/vcs-root-instances/commitHookNotification?locator=vcsRoot:%s", tcUrl, meta.VcsRootId), nil
1252+
return fmt.Sprintf("%s/app/rest/vcs-root-instances/commitHookNotification?locator=vcsRoot:%s", tcURL, meta.VcsRootID), nil
12531253
}
12541254

12551255
// FeishuHooksEditPost response for editing feishu hook

services/forms/repo_form.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ func (f *NewMSTeamsHookForm) Validate(req *http.Request, errs binding.Errors) bi
373373
}
374374

375375
type NewTeamCityHookForm struct {
376-
HostUrl string `binding:"Required;ValidUrl"`
376+
HostURL string `binding:"Required;ValidUrl"`
377377
AuthToken string `binding:"Required"`
378-
VcsRootId string `binding:"Required"`
378+
VcsRootID string `binding:"Required"`
379379
WebhookForm
380380
}
381381

services/webhook/teamcity.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
package webhook
66

77
import (
8-
"encoding/json"
9-
108
webhook_model "code.gitea.io/gitea/models/webhook"
9+
"code.gitea.io/gitea/modules/json"
1110
"code.gitea.io/gitea/modules/log"
1211
api "code.gitea.io/gitea/modules/structs"
1312
)
1413

1514
type (
1615
// TeamCityMeta contains metadata for the TeamCity WebHook
1716
TeamCityMeta struct {
18-
HostUrl string `json:"host_url"`
17+
HostURL string `json:"host_url"`
1918
AuthToken string `json:"auth_token"`
20-
VcsRootId string `json:"vcs_root_id"`
19+
VcsRootID string `json:"vcs_root_id"`
2120
}
2221
)
2322

services/webhook/teamcity_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2019 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.package webhook
4+
15
package webhook
26

37
import (
@@ -27,9 +31,9 @@ func TestWebhook_GetTeamCityHook(t *testing.T) {
2731

2832
teamcityHook := GetTeamCityHook(w)
2933
assert.Equal(t, *teamcityHook, TeamCityMeta{
30-
HostUrl: "http://localhost.com",
34+
HostURL: "http://localhost.com",
3135
AuthToken: "testToken",
32-
VcsRootId: "fooVCS",
36+
VcsRootID: "fooVCS",
3337
})
3438
})
3539
}

0 commit comments

Comments
 (0)