* Let package git depend on setting but not opposite * private some package variablestags/v1.15.0-rc1
"time" | "time" | ||||
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
gitea_git "code.gitea.io/gitea/modules/git" | |||||
"code.gitea.io/gitea/modules/markup" | "code.gitea.io/gitea/modules/markup" | ||||
"code.gitea.io/gitea/modules/markup/external" | "code.gitea.io/gitea/modules/markup/external" | ||||
"code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
setting.RunUser = curUser.Username | setting.RunUser = curUser.Username | ||||
log.Printf("[PR] Loading fixtures data ...\n") | log.Printf("[PR] Loading fixtures data ...\n") | ||||
setting.CheckLFSVersion() | |||||
gitea_git.CheckLFSVersion() | |||||
//models.LoadConfigs() | //models.LoadConfigs() | ||||
/* | /* | ||||
setting.Database.Type = "sqlite3" | setting.Database.Type = "sqlite3" |
func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS string) { | func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS string) { | ||||
t.Run("LFS", func(t *testing.T) { | t.Run("LFS", func(t *testing.T) { | ||||
defer PrintCurrentTest(t)() | defer PrintCurrentTest(t)() | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
if !setting.LFS.StartServer { | if !setting.LFS.StartServer { | ||||
t.Skip() | t.Skip() | ||||
return | return | ||||
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | ||||
assert.Equal(t, littleSize, resp.Length) | assert.Equal(t, littleSize, resp.Length) | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
if setting.LFS.StartServer { | if setting.LFS.StartServer { | ||||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", littleLFS)) | req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", littleLFS)) | ||||
resp := session.MakeRequest(t, req, http.StatusOK) | resp := session.MakeRequest(t, req, http.StatusOK) | ||||
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | ||||
assert.Equal(t, littleSize, resp.Length) | assert.Equal(t, littleSize, resp.Length) | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
if setting.LFS.StartServer { | if setting.LFS.StartServer { | ||||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", littleLFS)) | req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", littleLFS)) | ||||
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) |
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
"code.gitea.io/gitea/modules/base" | "code.gitea.io/gitea/modules/base" | ||||
"code.gitea.io/gitea/modules/git" | |||||
"code.gitea.io/gitea/modules/graceful" | "code.gitea.io/gitea/modules/graceful" | ||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/queue" | "code.gitea.io/gitea/modules/queue" | ||||
setting.SetCustomPathAndConf("", "", "") | setting.SetCustomPathAndConf("", "", "") | ||||
setting.NewContext() | setting.NewContext() | ||||
util.RemoveAll(models.LocalCopyPath()) | util.RemoveAll(models.LocalCopyPath()) | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
setting.InitDBConfig() | setting.InitDBConfig() | ||||
if err := storage.Init(); err != nil { | if err := storage.Init(); err != nil { | ||||
fmt.Printf("Init storage failed: %v", err) | fmt.Printf("Init storage failed: %v", err) |
"testing" | "testing" | ||||
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
"code.gitea.io/gitea/modules/git" | |||||
"code.gitea.io/gitea/modules/lfs" | "code.gitea.io/gitea/modules/lfs" | ||||
"code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
"code.gitea.io/gitea/routers/web" | "code.gitea.io/gitea/routers/web" | ||||
func TestGetLFSSmall(t *testing.T) { | func TestGetLFSSmall(t *testing.T) { | ||||
defer prepareTestEnv(t)() | defer prepareTestEnv(t)() | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
if !setting.LFS.StartServer { | if !setting.LFS.StartServer { | ||||
t.Skip() | t.Skip() | ||||
return | return | ||||
func TestGetLFSLarge(t *testing.T) { | func TestGetLFSLarge(t *testing.T) { | ||||
defer prepareTestEnv(t)() | defer prepareTestEnv(t)() | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
if !setting.LFS.StartServer { | if !setting.LFS.StartServer { | ||||
t.Skip() | t.Skip() | ||||
return | return | ||||
func TestGetLFSGzip(t *testing.T) { | func TestGetLFSGzip(t *testing.T) { | ||||
defer prepareTestEnv(t)() | defer prepareTestEnv(t)() | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
if !setting.LFS.StartServer { | if !setting.LFS.StartServer { | ||||
t.Skip() | t.Skip() | ||||
return | return | ||||
func TestGetLFSZip(t *testing.T) { | func TestGetLFSZip(t *testing.T) { | ||||
defer prepareTestEnv(t)() | defer prepareTestEnv(t)() | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
if !setting.LFS.StartServer { | if !setting.LFS.StartServer { | ||||
t.Skip() | t.Skip() | ||||
return | return | ||||
func TestGetLFSRangeNo(t *testing.T) { | func TestGetLFSRangeNo(t *testing.T) { | ||||
defer prepareTestEnv(t)() | defer prepareTestEnv(t)() | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
if !setting.LFS.StartServer { | if !setting.LFS.StartServer { | ||||
t.Skip() | t.Skip() | ||||
return | return | ||||
func TestGetLFSRange(t *testing.T) { | func TestGetLFSRange(t *testing.T) { | ||||
defer prepareTestEnv(t)() | defer prepareTestEnv(t)() | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
if !setting.LFS.StartServer { | if !setting.LFS.StartServer { | ||||
t.Skip() | t.Skip() | ||||
return | return |
"code.gitea.io/gitea/models/migrations" | "code.gitea.io/gitea/models/migrations" | ||||
"code.gitea.io/gitea/modules/base" | "code.gitea.io/gitea/modules/base" | ||||
"code.gitea.io/gitea/modules/charset" | "code.gitea.io/gitea/modules/charset" | ||||
"code.gitea.io/gitea/modules/git" | |||||
"code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
"code.gitea.io/gitea/modules/util" | "code.gitea.io/gitea/modules/util" | ||||
assert.NoError(t, util.RemoveAll(setting.RepoRootPath)) | assert.NoError(t, util.RemoveAll(setting.RepoRootPath)) | ||||
assert.NoError(t, util.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath)) | assert.NoError(t, util.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath)) | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
setting.InitDBConfig() | setting.InitDBConfig() | ||||
setting.NewLogServices(true) | setting.NewLogServices(true) | ||||
return deferFn | return deferFn |
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
"code.gitea.io/gitea/modules/base" | "code.gitea.io/gitea/modules/base" | ||||
"code.gitea.io/gitea/modules/git" | |||||
"code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
"code.gitea.io/gitea/modules/timeutil" | "code.gitea.io/gitea/modules/timeutil" | ||||
"code.gitea.io/gitea/modules/util" | "code.gitea.io/gitea/modules/util" | ||||
setting.SetCustomPathAndConf("", "", "") | setting.SetCustomPathAndConf("", "", "") | ||||
setting.NewContext() | setting.NewContext() | ||||
setting.CheckLFSVersion() | |||||
git.CheckLFSVersion() | |||||
setting.InitDBConfig() | setting.InitDBConfig() | ||||
setting.NewLogServices(true) | setting.NewLogServices(true) | ||||
// GlobalCommandArgs global command args for external package setting | // GlobalCommandArgs global command args for external package setting | ||||
GlobalCommandArgs []string | GlobalCommandArgs []string | ||||
// DefaultCommandExecutionTimeout default command execution timeout duration | |||||
DefaultCommandExecutionTimeout = 360 * time.Second | |||||
// defaultCommandExecutionTimeout default command execution timeout duration | |||||
defaultCommandExecutionTimeout = 360 * time.Second | |||||
) | ) | ||||
// DefaultLocale is the default LC_ALL to run git commands in. | // DefaultLocale is the default LC_ALL to run git commands in. | ||||
// it pipes stdout and stderr to given io.Writer and passes in an io.Reader as stdin. Between cmd.Start and cmd.Wait the passed in function is run. | // it pipes stdout and stderr to given io.Writer and passes in an io.Reader as stdin. Between cmd.Start and cmd.Wait the passed in function is run. | ||||
func (c *Command) RunInDirTimeoutEnvFullPipelineFunc(env []string, timeout time.Duration, dir string, stdout, stderr io.Writer, stdin io.Reader, fn func(context.Context, context.CancelFunc) error) error { | func (c *Command) RunInDirTimeoutEnvFullPipelineFunc(env []string, timeout time.Duration, dir string, stdout, stderr io.Writer, stdin io.Reader, fn func(context.Context, context.CancelFunc) error) error { | ||||
if timeout == -1 { | if timeout == -1 { | ||||
timeout = DefaultCommandExecutionTimeout | |||||
timeout = defaultCommandExecutionTimeout | |||||
} | } | ||||
if len(dir) == 0 { | if len(dir) == 0 { |
"time" | "time" | ||||
"code.gitea.io/gitea/modules/process" | "code.gitea.io/gitea/modules/process" | ||||
"code.gitea.io/gitea/modules/setting" | |||||
"github.com/hashicorp/go-version" | "github.com/hashicorp/go-version" | ||||
) | ) | ||||
return nil | return nil | ||||
} | } | ||||
// VersionInfo returns git version information | |||||
func VersionInfo() string { | |||||
var format = "Git Version: %s" | |||||
var args = []interface{}{gitVersion.Original()} | |||||
// Since git wire protocol has been released from git v2.18 | |||||
if setting.Git.EnableAutoGitWireProtocol && CheckGitVersionAtLeast("2.18") == nil { | |||||
format += ", Wire Protocol %s Enabled" | |||||
args = append(args, "Version 2") // for focus color | |||||
} | |||||
return fmt.Sprintf(format, args...) | |||||
} | |||||
// Init initializes git module | // Init initializes git module | ||||
func Init(ctx context.Context) error { | func Init(ctx context.Context) error { | ||||
DefaultContext = ctx | DefaultContext = ctx | ||||
defaultCommandExecutionTimeout = time.Duration(setting.Git.Timeout.Default) * time.Second | |||||
if err := SetExecutablePath(setting.Git.Path); err != nil { | |||||
return err | |||||
} | |||||
// force cleanup args | |||||
GlobalCommandArgs = []string{} | |||||
if CheckGitVersionAtLeast("2.9") == nil { | |||||
// Explicitly disable credential helper, otherwise Git credentials might leak | |||||
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "credential.helper=") | |||||
} | |||||
// Since git wire protocol has been released from git v2.18 | |||||
if setting.Git.EnableAutoGitWireProtocol && CheckGitVersionAtLeast("2.18") == nil { | |||||
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "protocol.version=2") | |||||
} | |||||
// Save current git version on init to gitVersion otherwise it would require an RWMutex | // Save current git version on init to gitVersion otherwise it would require an RWMutex | ||||
if err := LoadGitVersion(); err != nil { | if err := LoadGitVersion(); err != nil { | ||||
return err | return err |
// Copyright 2021 The Gitea Authors. All rights reserved. | |||||
// Use of this source code is governed by a MIT-style | |||||
// license that can be found in the LICENSE file. | |||||
package git | |||||
import ( | |||||
"sync" | |||||
logger "code.gitea.io/gitea/modules/log" | |||||
"code.gitea.io/gitea/modules/setting" | |||||
) | |||||
var once sync.Once | |||||
// CheckLFSVersion will check lfs version, if not satisfied, then disable it. | |||||
func CheckLFSVersion() { | |||||
if setting.LFS.StartServer { | |||||
//Disable LFS client hooks if installed for the current OS user | |||||
//Needs at least git v2.1.2 | |||||
err := LoadGitVersion() | |||||
if err != nil { | |||||
logger.Fatal("Error retrieving git version: %v", err) | |||||
} | |||||
if CheckGitVersionAtLeast("2.1.2") != nil { | |||||
setting.LFS.StartServer = false | |||||
logger.Error("LFS server support needs at least Git v2.1.2") | |||||
} else { | |||||
once.Do(func() { | |||||
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "filter.lfs.required=", | |||||
"-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=") | |||||
}) | |||||
} | |||||
} | |||||
} |
"io/ioutil" | "io/ioutil" | ||||
"strconv" | "strconv" | ||||
"strings" | "strings" | ||||
"code.gitea.io/gitea/modules/setting" | |||||
) | ) | ||||
// GetBranchCommitID returns last commit ID string of given branch. | // GetBranchCommitID returns last commit ID string of given branch. | ||||
return commits.Front().Value.(*Commit), nil | return commits.Front().Value.(*Commit), nil | ||||
} | } | ||||
// CommitsRangeSize the default commits range size | |||||
var CommitsRangeSize = 50 | |||||
// BranchesRangeSize the default branches range size | |||||
var BranchesRangeSize = 20 | |||||
func (repo *Repository) commitsByRange(id SHA1, page, pageSize int) (*list.List, error) { | func (repo *Repository) commitsByRange(id SHA1, page, pageSize int) (*list.List, error) { | ||||
stdout, err := NewCommand("log", id.String(), "--skip="+strconv.Itoa((page-1)*pageSize), | stdout, err := NewCommand("log", id.String(), "--skip="+strconv.Itoa((page-1)*pageSize), | ||||
"--max-count="+strconv.Itoa(pageSize), prettyLogFormat).RunInDirBytes(repo.Path) | "--max-count="+strconv.Itoa(pageSize), prettyLogFormat).RunInDirBytes(repo.Path) | ||||
// CommitsByFileAndRange return the commits according revison file and the page | // CommitsByFileAndRange return the commits according revison file and the page | ||||
func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) { | func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) { | ||||
skip := (page - 1) * CommitsRangeSize | |||||
skip := (page - 1) * setting.Git.CommitsRangeSize | |||||
stdoutReader, stdoutWriter := io.Pipe() | stdoutReader, stdoutWriter := io.Pipe() | ||||
defer func() { | defer func() { | ||||
go func() { | go func() { | ||||
stderr := strings.Builder{} | stderr := strings.Builder{} | ||||
err := NewCommand("log", revision, "--follow", | err := NewCommand("log", revision, "--follow", | ||||
"--max-count="+strconv.Itoa(CommitsRangeSize*page), | |||||
"--max-count="+strconv.Itoa(setting.Git.CommitsRangeSize*page), | |||||
prettyLogFormat, "--", file). | prettyLogFormat, "--", file). | ||||
RunInDirPipeline(repo.Path, stdoutWriter, &stderr) | RunInDirPipeline(repo.Path, stdoutWriter, &stderr) | ||||
if err != nil { | if err != nil { | ||||
// CommitsByFileAndRangeNoFollow return the commits according revison file and the page | // CommitsByFileAndRangeNoFollow return the commits according revison file and the page | ||||
func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page int) (*list.List, error) { | func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page int) (*list.List, error) { | ||||
stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*50), | stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*50), | ||||
"--max-count="+strconv.Itoa(CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path) | |||||
"--max-count="+strconv.Itoa(setting.Git.CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path) | |||||
if err != nil { | if err != nil { | ||||
return nil, err | return nil, err | ||||
} | } |
import ( | import ( | ||||
"time" | "time" | ||||
"code.gitea.io/gitea/modules/git" | |||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
) | ) | ||||
MaxGitDiffLines int | MaxGitDiffLines int | ||||
MaxGitDiffLineCharacters int | MaxGitDiffLineCharacters int | ||||
MaxGitDiffFiles int | MaxGitDiffFiles int | ||||
CommitsRangeSize int | |||||
BranchesRangeSize int | |||||
CommitsRangeSize int // CommitsRangeSize the default commits range size | |||||
BranchesRangeSize int // BranchesRangeSize the default branches range size | |||||
VerbosePush bool | VerbosePush bool | ||||
VerbosePushDelay time.Duration | VerbosePushDelay time.Duration | ||||
GCArgs []string `ini:"GC_ARGS" delim:" "` | GCArgs []string `ini:"GC_ARGS" delim:" "` | ||||
Pull int | Pull int | ||||
GC int `ini:"GC"` | GC int `ini:"GC"` | ||||
}{ | }{ | ||||
Default: int(git.DefaultCommandExecutionTimeout / time.Second), | |||||
Default: 360, | |||||
Migrate: 600, | Migrate: 600, | ||||
Mirror: 300, | Mirror: 300, | ||||
Clone: 300, | Clone: 300, | ||||
if err := Cfg.Section("git").MapTo(&Git); err != nil { | if err := Cfg.Section("git").MapTo(&Git); err != nil { | ||||
log.Fatal("Failed to map Git settings: %v", err) | log.Fatal("Failed to map Git settings: %v", err) | ||||
} | } | ||||
if err := git.SetExecutablePath(Git.Path); err != nil { | |||||
log.Fatal("Failed to initialize Git settings: %v", err) | |||||
} | |||||
git.DefaultCommandExecutionTimeout = time.Duration(Git.Timeout.Default) * time.Second | |||||
version, err := git.LocalVersion() | |||||
if err != nil { | |||||
log.Fatal("Error retrieving git version: %v", err) | |||||
} | |||||
// force cleanup args | |||||
git.GlobalCommandArgs = []string{} | |||||
if git.CheckGitVersionAtLeast("2.9") == nil { | |||||
// Explicitly disable credential helper, otherwise Git credentials might leak | |||||
git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=") | |||||
} | |||||
var format = "Git Version: %s" | |||||
var args = []interface{}{version.Original()} | |||||
// Since git wire protocol has been released from git v2.18 | |||||
if Git.EnableAutoGitWireProtocol && git.CheckGitVersionAtLeast("2.18") == nil { | |||||
git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "protocol.version=2") | |||||
format += ", Wire Protocol %s Enabled" | |||||
args = append(args, "Version 2") // for focus color | |||||
} | |||||
git.CommitsRangeSize = Git.CommitsRangeSize | |||||
git.BranchesRangeSize = Git.BranchesRangeSize | |||||
log.Info(format, args...) | |||||
} | } |
"time" | "time" | ||||
"code.gitea.io/gitea/modules/generate" | "code.gitea.io/gitea/modules/generate" | ||||
"code.gitea.io/gitea/modules/git" | |||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
ini "gopkg.in/ini.v1" | ini "gopkg.in/ini.v1" | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// CheckLFSVersion will check lfs version, if not satisfied, then disable it. | |||||
func CheckLFSVersion() { | |||||
if LFS.StartServer { | |||||
//Disable LFS client hooks if installed for the current OS user | |||||
//Needs at least git v2.1.2 | |||||
err := git.LoadGitVersion() | |||||
if err != nil { | |||||
log.Fatal("Error retrieving git version: %v", err) | |||||
} | |||||
if git.CheckGitVersionAtLeast("2.1.2") != nil { | |||||
LFS.StartServer = false | |||||
log.Error("LFS server support needs at least Git v2.1.2") | |||||
} else { | |||||
git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "filter.lfs.required=", | |||||
"-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=") | |||||
} | |||||
} | |||||
} |
listOptions.Page = 1 | listOptions.Page = 1 | ||||
} | } | ||||
if listOptions.PageSize > git.CommitsRangeSize { | |||||
listOptions.PageSize = git.CommitsRangeSize | |||||
if listOptions.PageSize > setting.Git.CommitsRangeSize { | |||||
listOptions.PageSize = setting.Git.CommitsRangeSize | |||||
} | } | ||||
sha := ctx.Query("sha") | sha := ctx.Query("sha") |
if err := git.Init(ctx); err != nil { | if err := git.Init(ctx); err != nil { | ||||
log.Fatal("Git module init failed: %v", err) | log.Fatal("Git module init failed: %v", err) | ||||
} | } | ||||
setting.CheckLFSVersion() | |||||
log.Info(git.VersionInfo()) | |||||
git.CheckLFSVersion() | |||||
log.Trace("AppPath: %s", setting.AppPath) | log.Trace("AppPath: %s", setting.AppPath) | ||||
log.Trace("AppWorkPath: %s", setting.AppWorkPath) | log.Trace("AppWorkPath: %s", setting.AppWorkPath) | ||||
log.Trace("Custom path: %s", setting.CustomPath) | log.Trace("Custom path: %s", setting.CustomPath) |
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/repofiles" | "code.gitea.io/gitea/modules/repofiles" | ||||
repo_module "code.gitea.io/gitea/modules/repository" | repo_module "code.gitea.io/gitea/modules/repository" | ||||
"code.gitea.io/gitea/modules/setting" | |||||
"code.gitea.io/gitea/modules/util" | "code.gitea.io/gitea/modules/util" | ||||
"code.gitea.io/gitea/modules/web" | "code.gitea.io/gitea/modules/web" | ||||
"code.gitea.io/gitea/routers/utils" | "code.gitea.io/gitea/routers/utils" | ||||
} | } | ||||
limit := ctx.QueryInt("limit") | limit := ctx.QueryInt("limit") | ||||
if limit <= 0 || limit > git.BranchesRangeSize { | |||||
limit = git.BranchesRangeSize | |||||
if limit <= 0 || limit > setting.Git.BranchesRangeSize { | |||||
limit = setting.Git.BranchesRangeSize | |||||
} | } | ||||
skip := (page - 1) * limit | skip := (page - 1) * limit | ||||
return | return | ||||
} | } | ||||
ctx.Data["Branches"] = branches | ctx.Data["Branches"] = branches | ||||
pager := context.NewPagination(int(branchesCount), git.BranchesRangeSize, page, 5) | |||||
pager := context.NewPagination(int(branchesCount), setting.Git.BranchesRangeSize, page, 5) | |||||
pager.SetDefaultParams(ctx) | pager.SetDefaultParams(ctx) | ||||
ctx.Data["Page"] = pager | ctx.Data["Page"] = pager | ||||
pageSize := ctx.QueryInt("limit") | pageSize := ctx.QueryInt("limit") | ||||
if pageSize <= 0 { | if pageSize <= 0 { | ||||
pageSize = git.CommitsRangeSize | |||||
pageSize = setting.Git.CommitsRangeSize | |||||
} | } | ||||
// Both `git log branchName` and `git log commitId` work. | // Both `git log branchName` and `git log commitId` work. | ||||
ctx.Data["CommitCount"] = commitsCount | ctx.Data["CommitCount"] = commitsCount | ||||
ctx.Data["Branch"] = ctx.Repo.BranchName | ctx.Data["Branch"] = ctx.Repo.BranchName | ||||
pager := context.NewPagination(int(commitsCount), git.CommitsRangeSize, page, 5) | |||||
pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5) | |||||
pager.SetDefaultParams(ctx) | pager.SetDefaultParams(ctx) | ||||
ctx.Data["Page"] = pager | ctx.Data["Page"] = pager | ||||
ctx.Data["CommitCount"] = commitsCount | ctx.Data["CommitCount"] = commitsCount | ||||
ctx.Data["Branch"] = branchName | ctx.Data["Branch"] = branchName | ||||
pager := context.NewPagination(int(commitsCount), git.CommitsRangeSize, page, 5) | |||||
pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5) | |||||
pager.SetDefaultParams(ctx) | pager.SetDefaultParams(ctx) | ||||
ctx.Data["Page"] = pager | ctx.Data["Page"] = pager | ||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/markup" | "code.gitea.io/gitea/modules/markup" | ||||
"code.gitea.io/gitea/modules/markup/markdown" | "code.gitea.io/gitea/modules/markup/markdown" | ||||
"code.gitea.io/gitea/modules/setting" | |||||
"code.gitea.io/gitea/modules/timeutil" | "code.gitea.io/gitea/modules/timeutil" | ||||
"code.gitea.io/gitea/modules/util" | "code.gitea.io/gitea/modules/util" | ||||
"code.gitea.io/gitea/modules/web" | "code.gitea.io/gitea/modules/web" | ||||
ctx.Data["Commits"] = commitsHistory | ctx.Data["Commits"] = commitsHistory | ||||
pager := context.NewPagination(int(commitsCount), git.CommitsRangeSize, page, 5) | |||||
pager := context.NewPagination(int(commitsCount), setting.Git.CommitsRangeSize, page, 5) | |||||
pager.SetDefaultParams(ctx) | pager.SetDefaultParams(ctx) | ||||
ctx.Data["Page"] = pager | ctx.Data["Page"] = pager | ||||