Skip to content

Commit aadd7dc

Browse files
committed
And others
1 parent b3828e3 commit aadd7dc

File tree

12 files changed

+34
-34
lines changed

12 files changed

+34
-34
lines changed

cmd/serve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func runServ(c *cli.Context) error {
213213
keyID = key.ID
214214

215215
// Check deploy key or user key.
216-
if key.Type == models.KEY_TYPE_DEPLOY {
216+
if key.Type == models.KeyTypeDeploy {
217217
if key.Mode < requestedMode {
218218
fail("Key permission denied", "Cannot push with deployment key: %d", key.ID)
219219
}

models/org.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func GetOrgByName(name string) (*User, error) {
170170
}
171171
u := &User{
172172
LowerName: strings.ToLower(name),
173-
Type: USER_TYPE_ORGANIZATION,
173+
Type: UserTypeOrganization,
174174
}
175175
has, err := x.Get(u)
176176
if err != nil {

models/ssh_key.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ import (
2929
)
3030

3131
const (
32-
_TPL_PUBLICK_KEY = `command="%s serv key-%d --config='%s'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
32+
tplPublicKey = `command="%s serv key-%d --config='%s'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
3333
)
3434

3535
var sshOpLocker sync.Mutex
3636

3737
type KeyType int
3838

3939
const (
40-
KEY_TYPE_USER = iota + 1
41-
KEY_TYPE_DEPLOY
40+
KeyTypeUser = iota + 1
41+
KeyTypeDeploy
4242
)
4343

4444
// PublicKey represents a user or deploy SSH public key.
@@ -85,7 +85,7 @@ func (k *PublicKey) OmitEmail() string {
8585

8686
// AuthorizedString returns formatted public key string for authorized_keys file.
8787
func (key *PublicKey) AuthorizedString() string {
88-
return fmt.Sprintf(_TPL_PUBLICK_KEY, setting.AppPath, key.ID, setting.CustomConf, key.Content)
88+
return fmt.Sprintf(tplPublicKey, setting.AppPath, key.ID, setting.CustomConf, key.Content)
8989
}
9090

9191
func extractTypeFromBase64Key(key string) (string, error) {
@@ -352,7 +352,7 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error {
352352
func checkKeyContent(content string) error {
353353
has, err := x.Get(&PublicKey{
354354
Content: content,
355-
Type: KEY_TYPE_USER,
355+
Type: KeyTypeUser,
356356
})
357357
if err != nil {
358358
return err
@@ -416,7 +416,7 @@ func AddPublicKey(ownerID int64, name, content string) (*PublicKey, error) {
416416
Name: name,
417417
Content: content,
418418
Mode: AccessModeWrite,
419-
Type: KEY_TYPE_USER,
419+
Type: KeyTypeUser,
420420
}
421421
if err = addKey(sess, key); err != nil {
422422
return nil, fmt.Errorf("addKey: %v", err)
@@ -643,7 +643,7 @@ func AddDeployKey(repoID int64, name, content string) (*DeployKey, error) {
643643
pkey := &PublicKey{
644644
Content: content,
645645
Mode: AccessModeRead,
646-
Type: KEY_TYPE_DEPLOY,
646+
Type: KeyTypeDeploy,
647647
}
648648
has, err := x.Get(pkey)
649649
if err != nil {

models/user.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ import (
3737
type UserType int
3838

3939
const (
40-
USER_TYPE_INDIVIDUAL UserType = iota // Historic reason to make it starts at 0.
41-
USER_TYPE_ORGANIZATION
40+
UserTypeIndividual UserType = iota // Historic reason to make it starts at 0.
41+
UserTypeOrganization
4242
)
4343

4444
var (
@@ -393,7 +393,7 @@ func (u *User) IsWriterOfRepo(repo *Repository) bool {
393393

394394
// IsOrganization returns true if user is actually a organization.
395395
func (u *User) IsOrganization() bool {
396-
return u.Type == USER_TYPE_ORGANIZATION
396+
return u.Type == UserTypeOrganization
397397
}
398398

399399
// IsUserOrgOwner returns true if user is in the owner team of given organization.

models/webhook.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
2828
type HookContentType int
2929

3030
const (
31-
JSON HookContentType = iota + 1
32-
FORM
31+
ContentTypeJson HookContentType = iota + 1
32+
ContentTypeForm
3333
)
3434

3535
var hookContentTypes = map[string]HookContentType{
36-
"json": JSON,
37-
"form": FORM,
36+
"json": ContentTypeJson,
37+
"form": ContentTypeForm,
3838
}
3939

4040
// ToHookContentType returns HookContentType by given name.
@@ -44,9 +44,9 @@ func ToHookContentType(name string) HookContentType {
4444

4545
func (t HookContentType) Name() string {
4646
switch t {
47-
case JSON:
47+
case ContentTypeJson:
4848
return "json"
49-
case FORM:
49+
case ContentTypeForm:
5050
return "form"
5151
}
5252
return ""
@@ -511,9 +511,9 @@ func (t *HookTask) deliver() {
511511
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify})
512512

513513
switch t.ContentType {
514-
case JSON:
514+
case ContentTypeJson:
515515
req = req.Header("Content-Type", "application/json").Body(t.PayloadContent)
516-
case FORM:
516+
case ContentTypeForm:
517517
req.Param("payload", t.PayloadContent)
518518
}
519519

routers/admin/orgs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func Organizations(ctx *context.Context) {
2222
ctx.Data["PageIsAdminOrganizations"] = true
2323

2424
routers.RenderUserSearch(ctx, &routers.UserSearchOptions{
25-
Type: models.USER_TYPE_ORGANIZATION,
25+
Type: models.UserTypeOrganization,
2626
Counter: models.CountOrganizations,
2727
Ranger: models.Organizations,
2828
PageSize: setting.UI.Admin.OrgPagingNum,

routers/admin/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Users(ctx *context.Context) {
3030
ctx.Data["PageIsAdminUsers"] = true
3131

3232
routers.RenderUserSearch(ctx, &routers.UserSearchOptions{
33-
Type: models.USER_TYPE_INDIVIDUAL,
33+
Type: models.UserTypeIndividual,
3434
Counter: models.CountUsers,
3535
Ranger: models.Users,
3636
PageSize: setting.UI.Admin.UserPagingNum,

routers/api/v1/admin/org.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) {
2727
Website: form.Website,
2828
Location: form.Location,
2929
IsActive: true,
30-
Type: models.USER_TYPE_ORGANIZATION,
30+
Type: models.UserTypeOrganization,
3131
}
3232
if err := models.CreateOrganization(org, u); err != nil {
3333
if models.IsErrUserAlreadyExist(err) ||

routers/api/v1/user/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
func Search(ctx *context.APIContext) {
1717
opts := &models.SearchUserOptions{
1818
Keyword: ctx.Query("q"),
19-
Type: models.USER_TYPE_INDIVIDUAL,
19+
Type: models.UserTypeIndividual,
2020
PageSize: com.StrTo(ctx.Query("limit")).MustInt(),
2121
}
2222
if opts.PageSize == 0 {

routers/home.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func ExploreUsers(ctx *context.Context) {
172172
ctx.Data["PageIsExploreUsers"] = true
173173

174174
RenderUserSearch(ctx, &UserSearchOptions{
175-
Type: models.USER_TYPE_INDIVIDUAL,
175+
Type: models.UserTypeIndividual,
176176
Counter: models.CountUsers,
177177
Ranger: models.Users,
178178
PageSize: setting.UI.ExplorePagingNum,
@@ -187,7 +187,7 @@ func ExploreOrganizations(ctx *context.Context) {
187187
ctx.Data["PageIsExploreOrganizations"] = true
188188

189189
RenderUserSearch(ctx, &UserSearchOptions{
190-
Type: models.USER_TYPE_ORGANIZATION,
190+
Type: models.UserTypeOrganization,
191191
Counter: models.CountOrganizations,
192192
Ranger: models.Organizations,
193193
PageSize: setting.UI.ExplorePagingNum,

routers/org/org.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func CreatePost(ctx *context.Context, form auth.CreateOrgForm) {
3333
org := &models.User{
3434
Name: form.OrgName,
3535
IsActive: true,
36-
Type: models.USER_TYPE_ORGANIZATION,
36+
Type: models.UserTypeOrganization,
3737
}
3838

3939
if err := models.CreateOrganization(org, ctx.User); err != nil {

routers/repo/webhook.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ func WebHooksNewPost(ctx *context.Context, form auth.NewWebhookForm) {
134134
return
135135
}
136136

137-
contentType := models.JSON
138-
if models.HookContentType(form.ContentType) == models.FORM {
139-
contentType = models.FORM
137+
contentType := models.ContentTypeJson
138+
if models.HookContentType(form.ContentType) == models.ContentTypeForm {
139+
contentType = models.ContentTypeForm
140140
}
141141

142142
w := &models.Webhook{
@@ -192,7 +192,7 @@ func SlackHooksNewPost(ctx *context.Context, form auth.NewSlackHookForm) {
192192
w := &models.Webhook{
193193
RepoID: orCtx.RepoID,
194194
URL: form.PayloadURL,
195-
ContentType: models.JSON,
195+
ContentType: models.ContentTypeJson,
196196
HookEvent: ParseHookEvent(form.WebhookForm),
197197
IsActive: form.Active,
198198
HookTaskType: models.SLACK,
@@ -281,9 +281,9 @@ func WebHooksEditPost(ctx *context.Context, form auth.NewWebhookForm) {
281281
return
282282
}
283283

284-
contentType := models.JSON
285-
if models.HookContentType(form.ContentType) == models.FORM {
286-
contentType = models.FORM
284+
contentType := models.ContentTypeJson
285+
if models.HookContentType(form.ContentType) == models.ContentTypeForm {
286+
contentType = models.ContentTypeForm
287287
}
288288

289289
w.URL = form.PayloadURL

0 commit comments

Comments
 (0)