Skip to content

Commit 7ce5372

Browse files
committed
Fix import
1 parent 610299e commit 7ce5372

Some content is hidden

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

70 files changed

+155
-69
lines changed

cmd/dump.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package cmd
77

88
import (
9-
"encoding/json"
109
"fmt"
1110
"io/ioutil"
1211
"os"
@@ -15,6 +14,8 @@ import (
1514
"strings"
1615
"time"
1716

17+
"code.gitea.io/gitea/modules/json"
18+
1819
"code.gitea.io/gitea/models"
1920
"code.gitea.io/gitea/modules/log"
2021
"code.gitea.io/gitea/modules/setting"

cmd/serv.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package cmd
77

88
import (
9-
"encoding/json"
109
"fmt"
1110
"net/http"
1211
"net/url"
@@ -17,6 +16,8 @@ import (
1716
"strings"
1817
"time"
1918

19+
"code.gitea.io/gitea/modules/json"
20+
2021
"code.gitea.io/gitea/models"
2122
"code.gitea.io/gitea/modules/log"
2223
"code.gitea.io/gitea/modules/pprof"

integrations/api_admin_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
package integrations
66

77
import (
8-
"encoding/json"
98
"fmt"
109
"net/http"
1110
"testing"
1211

12+
"code.gitea.io/gitea/modules/json"
13+
1314
"code.gitea.io/gitea/models"
1415
api "code.gitea.io/gitea/modules/structs"
1516

integrations/api_helper_for_declarative_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package integrations
66

77
import (
88
"context"
9-
"encoding/json"
9+
10+
"code.gitea.io/gitea/modules/json"
1011

1112
"fmt"
1213
"io/ioutil"

integrations/api_pull_review_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
package integrations
66

77
import (
8-
"encoding/json"
98
"fmt"
109
"net/http"
1110
"testing"
1211

12+
"code.gitea.io/gitea/modules/json"
13+
1314
"code.gitea.io/gitea/models"
1415
api "code.gitea.io/gitea/modules/structs"
1516
"github.com/stretchr/testify/assert"

integrations/api_repo_lfs_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package integrations
66

77
import (
88
"bytes"
9-
"encoding/json"
9+
10+
"code.gitea.io/gitea/modules/json"
1011

1112
"net/http"
1213
"path"

integrations/create_no_session_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
package integrations
66

77
import (
8-
"encoding/json"
98
"io/ioutil"
109
"net/http"
1110
"net/http/httptest"
1211
"os"
1312
"path/filepath"
1413
"testing"
1514

15+
"code.gitea.io/gitea/modules/json"
16+
1617
"code.gitea.io/gitea/modules/setting"
1718
"code.gitea.io/gitea/modules/util"
1819
"code.gitea.io/gitea/routers"

integrations/integration_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import (
88
"bytes"
99
"context"
1010
"database/sql"
11-
"encoding/json"
11+
12+
"code.gitea.io/gitea/modules/json"
1213

1314
"fmt"
1415
"hash"

integrations/oauth_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package integrations
66

77
import (
88
"bytes"
9-
"encoding/json"
9+
10+
"code.gitea.io/gitea/modules/json"
1011

1112
"io/ioutil"
1213
"testing"

integrations/repo_commits_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
package integrations
66

77
import (
8-
"encoding/json"
98
"net/http"
109
"net/http/httptest"
1110
"path"
1211
"testing"
1312

13+
"code.gitea.io/gitea/modules/json"
14+
1415
"code.gitea.io/gitea/modules/setting"
1516
api "code.gitea.io/gitea/modules/structs"
1617

integrations/testlogger.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package integrations
66

77
import (
88
"context"
9-
"encoding/json"
9+
10+
"code.gitea.io/gitea/modules/json"
1011

1112
"fmt"
1213
"os"

models/issue_comment.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ package models
88

99
import (
1010
"container/list"
11-
"encoding/json"
11+
12+
"code.gitea.io/gitea/modules/json"
1213

1314
"fmt"
1415
"regexp"

models/migrations/testlogger_test.go

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

77
import (
88
"context"
9-
"encoding/json"
9+
10+
"code.gitea.io/gitea/modules/json"
1011

1112
"fmt"
1213
"os"

models/migrations/v130.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package migrations
66

77
import (
8-
"encoding/json"
8+
"code.gitea.io/gitea/modules/json"
99

1010
"code.gitea.io/gitea/modules/setting"
1111

models/migrations/v180.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package migrations
66

77
import (
8-
"encoding/json"
8+
"code.gitea.io/gitea/modules/json"
99

1010
"code.gitea.io/gitea/modules/util"
1111

models/repo_unit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
package models
66

77
import (
8-
"encoding/json"
98
"fmt"
109

10+
"code.gitea.io/gitea/modules/json"
11+
1112
"code.gitea.io/gitea/modules/timeutil"
1213

1314
"xorm.io/xorm"

models/task.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
package models
66

77
import (
8-
"encoding/json"
98
"fmt"
109

10+
"code.gitea.io/gitea/modules/json"
11+
1112
migration "code.gitea.io/gitea/modules/migrations/base"
1213
"code.gitea.io/gitea/modules/secret"
1314
"code.gitea.io/gitea/modules/setting"

models/user_heatmap_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
package models
66

77
import (
8-
"encoding/json"
98
"fmt"
109
"testing"
1110

11+
"code.gitea.io/gitea/modules/json"
12+
1213
"github.com/stretchr/testify/assert"
1314
)
1415

models/webhook.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ package models
77

88
import (
99
"context"
10-
"encoding/json"
10+
11+
"code.gitea.io/gitea/modules/json"
1112

1213
"fmt"
1314
"strings"

models/webhook_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package models
66

77
import (
88
"context"
9-
"encoding/json"
9+
10+
"code.gitea.io/gitea/modules/json"
1011

1112
"testing"
1213
"time"

modules/cache/cache_twoqueue.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
package cache
66

77
import (
8-
"encoding/json"
98
"strconv"
109
"sync"
1110
"time"
1211

12+
"code.gitea.io/gitea/modules/json"
13+
1314
mc "gitea.com/go-chi/cache"
1415
lru "github.com/hashicorp/golang-lru"
1516
)

modules/context/context.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99
"context"
1010
"crypto/sha256"
1111
"encoding/hex"
12-
"encoding/json"
12+
13+
"code.gitea.io/gitea/modules/json"
1314

1415
"fmt"
1516
"html"

modules/eventsource/event.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package eventsource
66

77
import (
88
"bytes"
9-
"encoding/json"
9+
10+
"code.gitea.io/gitea/modules/json"
1011

1112
"fmt"
1213
"io"

modules/httplib/httplib.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"context"
1111
"crypto/tls"
1212

13-
"encoding/json"
1413
"encoding/xml"
1514
"io"
1615
"io/ioutil"
@@ -25,6 +24,8 @@ import (
2524
"strings"
2625
"sync"
2726
"time"
27+
28+
"code.gitea.io/gitea/modules/json"
2829
)
2930

3031
var defaultSetting = Settings{false, "GiteaServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false}

modules/indexer/code/elastic_search.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ package code
77
import (
88
"bufio"
99
"context"
10-
"encoding/json"
10+
11+
"code.gitea.io/gitea/modules/json"
1112

1213
"fmt"
1314
"io"

modules/json/json.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,22 @@ func NewDecoder(reader io.Reader) Decoder {
121121
func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {
122122
return DefaultJSONHandler.Indent(dst, src, prefix, indent)
123123
}
124+
125+
// MarshalIndent copied from encoding/json
126+
func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
127+
b, err := Marshal(v)
128+
if err != nil {
129+
return nil, err
130+
}
131+
var buf bytes.Buffer
132+
err = Indent(&buf, b, prefix, indent)
133+
if err != nil {
134+
return nil, err
135+
}
136+
return buf.Bytes(), nil
137+
}
138+
139+
// Valid proxy to json.Valid
140+
func Valid(data []byte) bool {
141+
return json.Valid(data)
142+
}

modules/log/conn.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
package log
77

88
import (
9-
"encoding/json"
109
"fmt"
1110
"io"
1211
"net"
12+
13+
"code.gitea.io/gitea/modules/json"
1314
)
1415

1516
type connWriter struct {

modules/log/console.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
package log
77

88
import (
9-
"encoding/json"
109
"fmt"
1110
"io"
1211
"os"
12+
13+
"code.gitea.io/gitea/modules/json"
1314
)
1415

1516
// CanColorStdout reports if we can color the Stdout

modules/log/file.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ package log
77
import (
88
"bufio"
99
"compress/gzip"
10-
"encoding/json"
10+
11+
"code.gitea.io/gitea/modules/json"
1112

1213
"errors"
1314
"fmt"

modules/log/level.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package log
66

77
import (
88
"bytes"
9-
"encoding/json"
9+
10+
"code.gitea.io/gitea/modules/json"
1011

1112
"fmt"
1213
"os"

modules/log/level_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
package log
66

77
import (
8-
"encoding/json"
98
"fmt"
109
"testing"
1110

11+
"code.gitea.io/gitea/modules/json"
12+
1213
"github.com/stretchr/testify/assert"
1314
)
1415

modules/log/smtp.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
package log
77

88
import (
9-
"encoding/json"
109
"fmt"
1110
"net/smtp"
1211
"strings"
12+
13+
"code.gitea.io/gitea/modules/json"
1314
)
1415

1516
type smtpWriter struct {

0 commit comments

Comments
 (0)