Skip to content

Commit 0e961e9

Browse files
committed
Fix import sequence
1 parent 7ce5372 commit 0e961e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+53
-226
lines changed

cmd/dump.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import (
1414
"strings"
1515
"time"
1616

17-
"code.gitea.io/gitea/modules/json"
18-
1917
"code.gitea.io/gitea/models"
18+
"code.gitea.io/gitea/modules/json"
2019
"code.gitea.io/gitea/modules/log"
2120
"code.gitea.io/gitea/modules/setting"
2221
"code.gitea.io/gitea/modules/storage"
@@ -307,7 +306,6 @@ func runDump(ctx *cli.Context) error {
307306
var excludes []string
308307
if setting.Cfg.Section("session").Key("PROVIDER").Value() == "file" {
309308
var opts session.Options
310-
311309
if err = json.Unmarshal([]byte(setting.SessionConfig.ProviderConfig), &opts); err != nil {
312310
return err
313311
}

cmd/serv.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ import (
1616
"strings"
1717
"time"
1818

19-
"code.gitea.io/gitea/modules/json"
20-
2119
"code.gitea.io/gitea/models"
20+
"code.gitea.io/gitea/modules/json"
2221
"code.gitea.io/gitea/modules/log"
2322
"code.gitea.io/gitea/modules/pprof"
2423
"code.gitea.io/gitea/modules/private"

integrations/api_admin_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import (
99
"net/http"
1010
"testing"
1111

12-
"code.gitea.io/gitea/modules/json"
13-
1412
"code.gitea.io/gitea/models"
13+
"code.gitea.io/gitea/modules/json"
1514
api "code.gitea.io/gitea/modules/structs"
1615

1716
"github.com/stretchr/testify/assert"
@@ -191,7 +190,6 @@ func TestAPIEditUser(t *testing.T) {
191190
resp := session.MakeRequest(t, req, http.StatusUnprocessableEntity)
192191

193192
errMap := make(map[string]interface{})
194-
195193
json.Unmarshal(resp.Body.Bytes(), &errMap)
196194
assert.EqualValues(t, "email is not allowed to be empty string", errMap["message"].(string))
197195

integrations/api_helper_for_declarative_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ package integrations
66

77
import (
88
"context"
9-
10-
"code.gitea.io/gitea/modules/json"
11-
129
"fmt"
1310
"io/ioutil"
1411
"net/http"
@@ -17,6 +14,7 @@ import (
1714
"time"
1815

1916
"code.gitea.io/gitea/models"
17+
"code.gitea.io/gitea/modules/json"
2018
"code.gitea.io/gitea/modules/queue"
2119
api "code.gitea.io/gitea/modules/structs"
2220
"code.gitea.io/gitea/services/forms"

integrations/api_pull_review_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
"net/http"
1010
"testing"
1111

12-
"code.gitea.io/gitea/modules/json"
13-
1412
"code.gitea.io/gitea/models"
13+
"code.gitea.io/gitea/modules/json"
1514
api "code.gitea.io/gitea/modules/structs"
15+
1616
"github.com/stretchr/testify/assert"
1717
)
1818

@@ -190,7 +190,6 @@ func TestAPIPullReview(t *testing.T) {
190190
})
191191
resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
192192
errMap := make(map[string]interface{})
193-
194193
json.Unmarshal(resp.Body.Bytes(), &errMap)
195194
assert.EqualValues(t, "review event COMMENT requires a body or a comment", errMap["message"].(string))
196195

integrations/api_repo_lfs_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ package integrations
66

77
import (
88
"bytes"
9-
10-
"code.gitea.io/gitea/modules/json"
11-
129
"net/http"
1310
"path"
1411
"strconv"
1512
"strings"
1613
"testing"
1714

1815
"code.gitea.io/gitea/models"
16+
"code.gitea.io/gitea/modules/json"
1917
"code.gitea.io/gitea/modules/lfs"
2018
"code.gitea.io/gitea/modules/setting"
2119

integrations/create_no_session_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"testing"
1414

1515
"code.gitea.io/gitea/modules/json"
16-
1716
"code.gitea.io/gitea/modules/setting"
1817
"code.gitea.io/gitea/modules/util"
1918
"code.gitea.io/gitea/routers"

integrations/integration_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import (
88
"bytes"
99
"context"
1010
"database/sql"
11-
12-
"code.gitea.io/gitea/modules/json"
13-
1411
"fmt"
1512
"hash"
1613
"hash/fnv"
@@ -31,6 +28,7 @@ import (
3128
"code.gitea.io/gitea/modules/base"
3229
"code.gitea.io/gitea/modules/git"
3330
"code.gitea.io/gitea/modules/graceful"
31+
"code.gitea.io/gitea/modules/json"
3432
"code.gitea.io/gitea/modules/log"
3533
"code.gitea.io/gitea/modules/queue"
3634
"code.gitea.io/gitea/modules/setting"

integrations/oauth_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ package integrations
66

77
import (
88
"bytes"
9-
10-
"code.gitea.io/gitea/modules/json"
11-
129
"io/ioutil"
1310
"testing"
1411

12+
"code.gitea.io/gitea/modules/json"
1513
"code.gitea.io/gitea/modules/setting"
1614

1715
"github.com/stretchr/testify/assert"

integrations/repo_commits_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"testing"
1212

1313
"code.gitea.io/gitea/modules/json"
14-
1514
"code.gitea.io/gitea/modules/setting"
1615
api "code.gitea.io/gitea/modules/structs"
1716

integrations/testlogger.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ package integrations
66

77
import (
88
"context"
9-
10-
"code.gitea.io/gitea/modules/json"
11-
129
"fmt"
1310
"os"
1411
"runtime"
@@ -17,6 +14,7 @@ import (
1714
"testing"
1815
"time"
1916

17+
"code.gitea.io/gitea/modules/json"
2018
"code.gitea.io/gitea/modules/log"
2119
"code.gitea.io/gitea/modules/queue"
2220
)

models/issue_comment.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ package models
88

99
import (
1010
"container/list"
11-
12-
"code.gitea.io/gitea/modules/json"
13-
1411
"fmt"
1512
"regexp"
1613
"strconv"
1714
"strings"
1815
"unicode/utf8"
1916

2017
"code.gitea.io/gitea/modules/git"
18+
"code.gitea.io/gitea/modules/json"
2119
"code.gitea.io/gitea/modules/log"
2220
"code.gitea.io/gitea/modules/markup"
2321
"code.gitea.io/gitea/modules/markup/markdown"

models/migrations/testlogger_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ package migrations
66

77
import (
88
"context"
9-
10-
"code.gitea.io/gitea/modules/json"
11-
129
"fmt"
1310
"os"
1411
"runtime"
@@ -17,6 +14,7 @@ import (
1714
"testing"
1815
"time"
1916

17+
"code.gitea.io/gitea/modules/json"
2018
"code.gitea.io/gitea/modules/log"
2119
"code.gitea.io/gitea/modules/queue"
2220
)

models/migrations/v130.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package migrations
66

77
import (
88
"code.gitea.io/gitea/modules/json"
9-
109
"code.gitea.io/gitea/modules/setting"
1110

1211
"xorm.io/xorm"
@@ -71,7 +70,6 @@ func expandWebhooks(x *xorm.Engine) error {
7170

7271
for _, res := range results {
7372
var events HookEvent
74-
7573
if err = json.Unmarshal([]byte(res.Events), &events); err != nil {
7674
return err
7775
}

models/migrations/v180.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package migrations
66

77
import (
88
"code.gitea.io/gitea/modules/json"
9-
109
"code.gitea.io/gitea/modules/util"
1110

1211
"xorm.io/builder"
@@ -106,7 +105,6 @@ func removeCredentials(payload string) (string, error) {
106105
}
107106

108107
var opts MigrateOptions
109-
110108
err := json.Unmarshal([]byte(payload), &opts)
111109
if err != nil {
112110
return "", err

models/repo_unit.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99

1010
"code.gitea.io/gitea/modules/json"
11-
1211
"code.gitea.io/gitea/modules/timeutil"
1312

1413
"xorm.io/xorm"
@@ -34,7 +33,6 @@ func (cfg *UnitConfig) FromDB(bs []byte) error {
3433

3534
// ToDB exports a UnitConfig to a serialized format.
3635
func (cfg *UnitConfig) ToDB() ([]byte, error) {
37-
3836
return json.Marshal(cfg)
3937
}
4038

@@ -50,7 +48,6 @@ func (cfg *ExternalUncycloConfig) FromDB(bs []byte) error {
5048

5149
// ToDB exports a ExternalUncycloConfig to a serialized format.
5250
func (cfg *ExternalUncycloConfig) ToDB() ([]byte, error) {
53-
5451
return json.Marshal(cfg)
5552
}
5653

@@ -68,7 +65,6 @@ func (cfg *ExternalTrackerConfig) FromDB(bs []byte) error {
6865

6966
// ToDB exports a ExternalTrackerConfig to a serialized format.
7067
func (cfg *ExternalTrackerConfig) ToDB() ([]byte, error) {
71-
7268
return json.Marshal(cfg)
7369
}
7470

@@ -86,7 +82,6 @@ func (cfg *IssuesConfig) FromDB(bs []byte) error {
8682

8783
// ToDB exports a IssuesConfig to a serialized format.
8884
func (cfg *IssuesConfig) ToDB() ([]byte, error) {
89-
9085
return json.Marshal(cfg)
9186
}
9287

@@ -110,7 +105,6 @@ func (cfg *PullRequestsConfig) FromDB(bs []byte) error {
110105

111106
// ToDB exports a PullRequestsConfig to a serialized format.
112107
func (cfg *PullRequestsConfig) ToDB() ([]byte, error) {
113-
114108
return json.Marshal(cfg)
115109
}
116110

models/task.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99

1010
"code.gitea.io/gitea/modules/json"
11-
1211
migration "code.gitea.io/gitea/modules/migrations/base"
1312
"code.gitea.io/gitea/modules/secret"
1413
"code.gitea.io/gitea/modules/setting"
@@ -115,7 +114,6 @@ func (task *Task) UpdateCols(cols ...string) error {
115114
func (task *Task) MigrateConfig() (*migration.MigrateOptions, error) {
116115
if task.Type == structs.TaskTypeMigrateRepo {
117116
var opts migration.MigrateOptions
118-
119117
err := json.Unmarshal([]byte(task.PayloadContent), &opts)
120118
if err != nil {
121119
return nil, err
@@ -191,7 +189,6 @@ func GetMigratingTaskByID(id, doerID int64) (*Task, *migration.MigrateOptions, e
191189
}
192190

193191
var opts migration.MigrateOptions
194-
195192
if err := json.Unmarshal([]byte(task.PayloadContent), &opts); err != nil {
196193
return nil, nil, err
197194
}

models/user_heatmap_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
6969
assert.Equal(t, tc.CountResult, contributions, fmt.Sprintf("testcase %d", i))
7070

7171
// Test JSON rendering
72-
7372
jsonData, err := json.Marshal(heatmap)
7473
assert.NoError(t, err)
7574
assert.Equal(t, tc.JSONResult, string(jsonData))

models/webhook.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ package models
77

88
import (
99
"context"
10-
11-
"code.gitea.io/gitea/modules/json"
12-
1310
"fmt"
1411
"strings"
1512
"time"
1613

14+
"code.gitea.io/gitea/modules/json"
1715
"code.gitea.io/gitea/modules/log"
1816
"code.gitea.io/gitea/modules/setting"
1917
api "code.gitea.io/gitea/modules/structs"
@@ -162,7 +160,6 @@ type Webhook struct {
162160
// AfterLoad updates the webhook object upon setting a column
163161
func (w *Webhook) AfterLoad() {
164162
w.HookEvent = &HookEvent{}
165-
166163
if err := json.Unmarshal([]byte(w.Events), w.HookEvent); err != nil {
167164
log.Error("Unmarshal[%d]: %v", w.ID, err)
168165
}
@@ -175,7 +172,6 @@ func (w *Webhook) History(page int) ([]*HookTask, error) {
175172

176173
// UpdateEvent handles conversion from HookEvent to Events.
177174
func (w *Webhook) UpdateEvent() error {
178-
179175
data, err := json.Marshal(w.HookEvent)
180176
w.Events = string(data)
181177
return err
@@ -688,7 +684,6 @@ func (t *HookTask) AfterLoad() {
688684
}
689685

690686
t.RequestInfo = &HookRequest{}
691-
692687
if err := json.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil {
693688
log.Error("Unmarshal RequestContent[%d]: %v", t.ID, err)
694689
}
@@ -702,7 +697,6 @@ func (t *HookTask) AfterLoad() {
702697
}
703698

704699
func (t *HookTask) simpleMarshalJSON(v interface{}) string {
705-
706700
p, err := json.Marshal(v)
707701
if err != nil {
708702
log.Error("Marshal [%d]: %v", t.ID, err)

models/webhook_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ package models
66

77
import (
88
"context"
9-
10-
"code.gitea.io/gitea/modules/json"
11-
129
"testing"
1310
"time"
1411

12+
"code.gitea.io/gitea/modules/json"
1513
api "code.gitea.io/gitea/modules/structs"
1614

1715
"github.com/stretchr/testify/assert"
@@ -60,7 +58,6 @@ func TestWebhook_UpdateEvent(t *testing.T) {
6058
assert.NoError(t, webhook.UpdateEvent())
6159
assert.NotEmpty(t, webhook.Events)
6260
actualHookEvent := &HookEvent{}
63-
6461
assert.NoError(t, json.Unmarshal([]byte(webhook.Events), actualHookEvent))
6562
assert.Equal(t, *hookEvent, *actualHookEvent)
6663
}

modules/cache/cache_twoqueue.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ func (c *TwoQueueCache) StartAndGC(opts mc.Options) error {
178178
size, err = strconv.Atoi(opts.AdapterConfig)
179179
}
180180
if err != nil {
181-
182181
if !json.Valid([]byte(opts.AdapterConfig)) {
183182
return err
184183
}

0 commit comments

Comments
 (0)