mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 16:43:59 +01:00
Mirror updates
This commit is contained in:
parent
57f84fb051
commit
c36e7d322e
8 changed files with 56 additions and 19 deletions
|
@ -120,7 +120,10 @@ func NewEngine() (err error) {
|
||||||
|
|
||||||
type Statistic struct {
|
type Statistic struct {
|
||||||
Counter struct {
|
Counter struct {
|
||||||
User, PublicKey, Repo, Watch, Action, Access int64
|
User, PublicKey, Repo,
|
||||||
|
Watch, Action, Access,
|
||||||
|
Issue, Comment,
|
||||||
|
Mirror, Oauth, Release int64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,5 +134,10 @@ func GetStatistic() (stats Statistic) {
|
||||||
stats.Counter.Watch, _ = orm.Count(new(Watch))
|
stats.Counter.Watch, _ = orm.Count(new(Watch))
|
||||||
stats.Counter.Action, _ = orm.Count(new(Action))
|
stats.Counter.Action, _ = orm.Count(new(Action))
|
||||||
stats.Counter.Access, _ = orm.Count(new(Access))
|
stats.Counter.Access, _ = orm.Count(new(Access))
|
||||||
|
stats.Counter.Issue, _ = orm.Count(new(Issue))
|
||||||
|
stats.Counter.Comment, _ = orm.Count(new(Comment))
|
||||||
|
stats.Counter.Mirror, _ = orm.Count(new(Mirror))
|
||||||
|
stats.Counter.Oauth, _ = orm.Count(new(Oauth2))
|
||||||
|
stats.Counter.Release, _ = orm.Count(new(Release))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ func NewRepoContext() {
|
||||||
type Repository struct {
|
type Repository struct {
|
||||||
Id int64
|
Id int64
|
||||||
OwnerId int64 `xorm:"unique(s)"`
|
OwnerId int64 `xorm:"unique(s)"`
|
||||||
|
Owner *User `xorm:"-"`
|
||||||
ForkId int64
|
ForkId int64
|
||||||
LowerName string `xorm:"unique(s) index not null"`
|
LowerName string `xorm:"unique(s) index not null"`
|
||||||
Name string `xorm:"index not null"`
|
Name string `xorm:"index not null"`
|
||||||
|
@ -364,24 +365,21 @@ func initRepoCommit(tmpPath string, sig *git.Signature) (err error) {
|
||||||
var stderr string
|
var stderr string
|
||||||
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "add", "--all"); err != nil {
|
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "add", "--all"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
} else if strings.Contains(stderr, "fatal:") {
|
||||||
if len(stderr) > 0 {
|
return errors.New("git add: " + stderr)
|
||||||
log.Trace("stderr(1): %s", stderr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email),
|
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email),
|
||||||
"-m", "Init commit"); err != nil {
|
"-m", "Init commit"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
} else if strings.Contains(stderr, "fatal:") {
|
||||||
if len(stderr) > 0 {
|
return errors.New("git commit: " + stderr)
|
||||||
log.Trace("stderr(2): %s", stderr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "push", "origin", "master"); err != nil {
|
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "push", "origin", "master"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
} else if strings.Contains(stderr, "fatal:") {
|
||||||
if len(stderr) > 0 {
|
return errors.New("git push: " + stderr)
|
||||||
log.Trace("stderr(3): %s", stderr)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -439,9 +437,8 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
||||||
_, stderr, err := com.ExecCmd("git", "clone", repoPath, tmpDir)
|
_, stderr, err := com.ExecCmd("git", "clone", repoPath, tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
} else if strings.Contains(stderr, "fatal:") {
|
||||||
if len(stderr) > 0 {
|
return errors.New("git clone: " + stderr)
|
||||||
log.Trace("repo.initRepository(git clone): %s", stderr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// README
|
// README
|
||||||
|
@ -725,6 +722,13 @@ func GetRepositories(user *User, private bool) ([]Repository, error) {
|
||||||
return repos, err
|
return repos, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRecentUpdatedRepositories returns the list of repositories that are recently updated.
|
||||||
|
func GetRecentUpdatedRepositories() (repos []*Repository, err error) {
|
||||||
|
err = orm.Where("is_private=?", false).Limit(5).Desc("updated").Find(&repos)
|
||||||
|
return repos, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRepositoryCount returns the total number of repositories of user.
|
||||||
func GetRepositoryCount(user *User) (int64, error) {
|
func GetRepositoryCount(user *User) (int64, error) {
|
||||||
return orm.Count(&Repository{OwnerId: user.Id})
|
return orm.Count(&Repository{OwnerId: user.Id})
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ type OauthInfo struct {
|
||||||
|
|
||||||
// Oauther represents oauth service.
|
// Oauther represents oauth service.
|
||||||
type Oauther struct {
|
type Oauther struct {
|
||||||
GitHub, Google, Tencent bool
|
GitHub, Google, Tencent,
|
||||||
Twitter, Weibo bool
|
Twitter, Weibo bool
|
||||||
OauthInfos map[string]*OauthInfo
|
OauthInfos map[string]*OauthInfo
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package routers
|
package routers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
"github.com/gogits/gogs/routers/user"
|
"github.com/gogits/gogs/routers/user"
|
||||||
|
@ -23,6 +24,11 @@ func Home(ctx *middleware.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repos, _ := models.GetRecentUpdatedRepositories()
|
||||||
|
for _, repo := range repos {
|
||||||
|
repo.Owner, _ = models.GetUserById(repo.OwnerId)
|
||||||
|
}
|
||||||
|
ctx.Data["Repos"] = repos
|
||||||
ctx.Data["PageIsHome"] = true
|
ctx.Data["PageIsHome"] = true
|
||||||
ctx.HTML(200, "home")
|
ctx.HTML(200, "home")
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
Gogs database has <b>{{.Stats.Counter.User}}</b> users, <b>{{.Stats.Counter.PublicKey}}</b> SSH keys, <b>{{.Stats.Counter.Repo}}</b> repositories, <b>{{.Stats.Counter.Watch}}</b> watches, <b>{{.Stats.Counter.Action}}</b> actions, and <b>{{.Stats.Counter.Access}}</b> accesses.
|
Gogs database has <b>{{.Stats.Counter.User}}</b> users, <b>{{.Stats.Counter.PublicKey}}</b> SSH keys, <b>{{.Stats.Counter.Repo}}</b> repositories, <b>{{.Stats.Counter.Watch}}</b> watches, <b>{{.Stats.Counter.Action}}</b> actions, <b>{{.Stats.Counter.Access}}</b> accesses, <b>{{.Stats.Counter.Issue}}</b> issues, <b>{{.Stats.Counter.Comment}}</b> comments, <b>{{.Stats.Counter.Mirror}}</b> mirrors, <b>{{.Stats.Counter.Oauth}}</b> oauthes, <b>{{.Stats.Counter.Release}}</b> releases.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<meta name="keywords" content="go, git">
|
<meta name="keywords" content="go, git">
|
||||||
<meta name="_csrf" content="{{.CsrfToken}}" />
|
<meta name="_csrf" content="{{.CsrfToken}}" />
|
||||||
{{if .Repository.IsGoget}}<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">{{end}}
|
{{if .Repository.IsGoget}}<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">{{end}}
|
||||||
|
<meta property="qc:admins" content="34543312371436727" />
|
||||||
|
|
||||||
<!-- Stylesheets -->
|
<!-- Stylesheets -->
|
||||||
{{if IsProdMode}}
|
{{if IsProdMode}}
|
||||||
|
|
|
@ -1,8 +1,27 @@
|
||||||
{{template "base/head" .}}
|
{{template "base/head" .}}
|
||||||
{{template "base/navbar" .}}
|
{{template "base/navbar" .}}
|
||||||
<div id="body" class="container">
|
<div id="body" class="container">
|
||||||
|
{{if not .Repos}}
|
||||||
<h4>Hey there, welcome to the land of Gogs!</h4>
|
<h4>Hey there, welcome to the land of Gogs!</h4>
|
||||||
<p>If you just get your Gogs server running, go <a href="/install">install</a> guide page will help you setup things for your first-time run.</p>
|
<p>If you just get your Gogs server running, go <a href="/install">install</a> guide page will help you setup things for your first-time run.</p>
|
||||||
<img src="http://gowalker.org/public/gogs_demo.gif">
|
<img src="http://gowalker.org/public/gogs_demo.gif">
|
||||||
|
{{else}}
|
||||||
|
<h4>Hey there, welcome to the land of Gogs!</h4>
|
||||||
|
<h5>Here are some recent updated repositories:</h5>
|
||||||
|
<div class="tab-pane active">
|
||||||
|
<ul class="list-unstyled repo-list">
|
||||||
|
{{range .Repos}}
|
||||||
|
<li>
|
||||||
|
<div class="meta pull-right"><!-- <i class="fa fa-star"></i> {{.NumStars}} --> <i class="fa fa-code-fork"></i> {{.NumForks}}</div>
|
||||||
|
<h4>
|
||||||
|
<a href="/{{.Owner.Name}}/{{.Name}}">{{.Name}}</a>
|
||||||
|
</h4>
|
||||||
|
<p class="desc">{{.Description}}</p>
|
||||||
|
<div class="info">Last updated {{.Updated|TimeSince}}</div>
|
||||||
|
</li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{template "base/footer" .}}
|
{{template "base/footer" .}}
|
||||||
|
|
|
@ -58,14 +58,13 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$owner := .Owner}}
|
|
||||||
<div class="tab-pane active">
|
<div class="tab-pane active">
|
||||||
<ul class="list-unstyled repo-list">
|
<ul class="list-unstyled repo-list">
|
||||||
{{range .Repos}}
|
{{range .Repos}}
|
||||||
<li>
|
<li>
|
||||||
<div class="meta pull-right"><!-- <i class="fa fa-star"></i> {{.NumStars}} --> <i class="fa fa-code-fork"></i> {{.NumForks}}</div>
|
<div class="meta pull-right"><!-- <i class="fa fa-star"></i> {{.NumStars}} --> <i class="fa fa-code-fork"></i> {{.NumForks}}</div>
|
||||||
<h4>
|
<h4>
|
||||||
<a href="/{{$owner.Name}}/{{.Name}}">{{.Name}}{{if .IsPrivate}} <span class="label label-default">Private</span>{{end}}</a>
|
<a href="/{{$.Owner.Name}}/{{.Name}}">{{.Name}}{{if .IsPrivate}} <span class="label label-default">Private</span>{{end}}</a>
|
||||||
</h4>
|
</h4>
|
||||||
<p class="desc">{{.Description}}</p>
|
<p class="desc">{{.Description}}</p>
|
||||||
<div class="info">Last updated {{.Updated|TimeSince}}</div>
|
<div class="info">Last updated {{.Updated|TimeSince}}</div>
|
||||||
|
|
Loading…
Reference in a new issue