Skip to content

Commit 3ff5d22

Browse files
committed
private some package variables
1 parent 086960c commit 3ff5d22

File tree

8 files changed

+21
-26
lines changed

8 files changed

+21
-26
lines changed

modules/git/command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var (
2323
GlobalCommandArgs []string
2424

2525
// DefaultCommandExecutionTimeout default command execution timeout duration
26-
DefaultCommandExecutionTimeout = 360 * time.Second
26+
defaultCommandExecutionTimeout = 360 * time.Second
2727
)
2828

2929
// DefaultLocale is the default LC_ALL to run git commands in.
@@ -133,7 +133,7 @@ type RunContext struct {
133133
// RunWithContext run the command with context
134134
func (c *Command) RunWithContext(rc *RunContext) error {
135135
if rc.Timeout == -1 {
136-
rc.Timeout = DefaultCommandExecutionTimeout
136+
rc.Timeout = defaultCommandExecutionTimeout
137137
}
138138

139139
if len(rc.Dir) == 0 {

modules/git/git.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func VersionInfo() string {
140140
func Init(ctx context.Context) error {
141141
DefaultContext = ctx
142142

143-
DefaultCommandExecutionTimeout = time.Duration(setting.Git.Timeout.Default) * time.Second
143+
defaultCommandExecutionTimeout = time.Duration(setting.Git.Timeout.Default) * time.Second
144144

145145
if err := SetExecutablePath(setting.Git.Path); err != nil {
146146
return err
@@ -159,9 +159,6 @@ func Init(ctx context.Context) error {
159159
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "protocol.version=2")
160160
}
161161

162-
CommitsRangeSize = setting.Git.CommitsRangeSize
163-
BranchesRangeSize = setting.Git.BranchesRangeSize
164-
165162
// Save current git version on init to gitVersion otherwise it would require an RWMutex
166163
if err := LoadGitVersion(); err != nil {
167164
return err

modules/git/repo_commit.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"io/ioutil"
1313
"strconv"
1414
"strings"
15+
16+
"code.gitea.io/gitea/modules/setting"
1517
)
1618

1719
// GetBranchCommitID returns last commit ID string of given branch.
@@ -113,12 +115,6 @@ func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) {
113115
return commits.Front().Value.(*Commit), nil
114116
}
115117

116-
// CommitsRangeSize the default commits range size
117-
var CommitsRangeSize = 50
118-
119-
// BranchesRangeSize the default branches range size
120-
var BranchesRangeSize = 20
121-
122118
func (repo *Repository) commitsByRange(id SHA1, page, pageSize int) (*list.List, error) {
123119
stdout, err := NewCommand("log", id.String(), "--skip="+strconv.Itoa((page-1)*pageSize),
124120
"--max-count="+strconv.Itoa(pageSize), prettyLogFormat).RunInDirBytes(repo.Path)
@@ -234,7 +230,7 @@ func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) {
234230

235231
// CommitsByFileAndRange return the commits according revison file and the page
236232
func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) {
237-
skip := (page - 1) * CommitsRangeSize
233+
skip := (page - 1) * setting.Git.CommitsRangeSize
238234

239235
stdoutReader, stdoutWriter := io.Pipe()
240236
defer func() {
@@ -244,7 +240,7 @@ func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (
244240
go func() {
245241
stderr := strings.Builder{}
246242
err := NewCommand("log", revision, "--follow",
247-
"--max-count="+strconv.Itoa(CommitsRangeSize*page),
243+
"--max-count="+strconv.Itoa(setting.Git.CommitsRangeSize*page),
248244
prettyLogFormat, "--", file).
249245
RunInDirPipeline(repo.Path, stdoutWriter, &stderr)
250246
if err != nil {
@@ -275,7 +271,7 @@ func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (
275271
// CommitsByFileAndRangeNoFollow return the commits according revison file and the page
276272
func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page int) (*list.List, error) {
277273
stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*50),
278-
"--max-count="+strconv.Itoa(CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path)
274+
"--max-count="+strconv.Itoa(setting.Git.CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path)
279275
if err != nil {
280276
return nil, err
281277
}

modules/setting/git.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ var (
1818
MaxGitDiffLines int
1919
MaxGitDiffLineCharacters int
2020
MaxGitDiffFiles int
21-
CommitsRangeSize int
22-
BranchesRangeSize int
21+
CommitsRangeSize int // CommitsRangeSize the default commits range size
22+
BranchesRangeSize int // BranchesRangeSize the default branches range size
2323
VerbosePush bool
2424
VerbosePushDelay time.Duration
2525
GCArgs []string `ini:"GC_ARGS" delim:" "`

routers/api/v1/repo/commits.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ func GetAllCommits(ctx *context.APIContext) {
143143
listOptions.Page = 1
144144
}
145145

146-
if listOptions.PageSize > git.CommitsRangeSize {
147-
listOptions.PageSize = git.CommitsRangeSize
146+
if listOptions.PageSize > setting.Git.CommitsRangeSize {
147+
listOptions.PageSize = setting.Git.CommitsRangeSize
148148
}
149149

150150
sha := ctx.Query("sha")

routers/repo/branch.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"code.gitea.io/gitea/modules/log"
1818
"code.gitea.io/gitea/modules/repofiles"
1919
repo_module "code.gitea.io/gitea/modules/repository"
20+
"code.gitea.io/gitea/modules/setting"
2021
"code.gitea.io/gitea/modules/util"
2122
"code.gitea.io/gitea/modules/web"
2223
"code.gitea.io/gitea/routers/utils"
@@ -61,8 +62,8 @@ func Branches(ctx *context.Context) {
6162
}
6263

6364
limit := ctx.QueryInt("limit")
64-
if limit <= 0 || limit > git.BranchesRangeSize {
65-
limit = git.BranchesRangeSize
65+
if limit <= 0 || limit > setting.Git.BranchesRangeSize {
66+
limit = setting.Git.BranchesRangeSize
6667
}
6768

6869
skip := (page - 1) * limit
@@ -72,7 +73,7 @@ func Branches(ctx *context.Context) {
7273
return
7374
}
7475
ctx.Data["Branches"] = branches
75-
pager := context.NewPagination(int(branchesCount), git.BranchesRangeSize, page, 5)
76+
pager := context.NewPagination(int(branchesCount), setting.Git.BranchesRangeSize, page, 5)
7677
pager.SetDefaultParams(ctx)
7778
ctx.Data["Page"] = pager
7879

routers/repo/commit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func Commits(ctx *context.Context) {
6363

6464
pageSize := ctx.QueryInt("limit")
6565
if pageSize <= 0 {
66-
pageSize = git.CommitsRangeSize
66+
pageSize = setting.Git.CommitsRangeSize
6767
}
6868

6969
// Both `git log branchName` and `git log commitId` work.
@@ -82,7 +82,7 @@ func Commits(ctx *context.Context) {
8282
ctx.Data["CommitCount"] = commitsCount
8383
ctx.Data["Branch"] = ctx.Repo.BranchName
8484

85-
pager := context.NewPagination(int(commitsCount), git.CommitsRangeSize, page, 5)
85+
pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5)
8686
pager.SetDefaultParams(ctx)
8787
ctx.Data["Page"] = pager
8888

@@ -250,7 +250,7 @@ func FileHistory(ctx *context.Context) {
250250
ctx.Data["CommitCount"] = commitsCount
251251
ctx.Data["Branch"] = branchName
252252

253-
pager := context.NewPagination(int(commitsCount), git.CommitsRangeSize, page, 5)
253+
pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5)
254254
pager.SetDefaultParams(ctx)
255255
ctx.Data["Page"] = pager
256256

routers/repo/wiki.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"code.gitea.io/gitea/modules/log"
2121
"code.gitea.io/gitea/modules/markup"
2222
"code.gitea.io/gitea/modules/markup/markdown"
23+
"code.gitea.io/gitea/modules/setting"
2324
"code.gitea.io/gitea/modules/timeutil"
2425
"code.gitea.io/gitea/modules/util"
2526
"code.gitea.io/gitea/modules/web"
@@ -292,7 +293,7 @@ func renderRevisionPage(ctx *context.Context) (*git.Repository, *git.TreeEntry)
292293

293294
ctx.Data["Commits"] = commitsHistory
294295

295-
pager := context.NewPagination(int(commitsCount), git.CommitsRangeSize, page, 5)
296+
pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5)
296297
pager.SetDefaultParams(ctx)
297298
ctx.Data["Page"] = pager
298299

0 commit comments

Comments
 (0)