summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-04-14 04:11:33 -0400
committerUnknown <joe2010xtmf@163.com>2014-04-14 04:11:33 -0400
commitc36e7d322e74a55749ce2c2934c6fcfa82cff274 (patch)
treedbd2c05336815be91f1c59d654ce6f6f24d72872 /models
parent57f84fb0516d46b27c60554730956f0c9dff68dd (diff)
downloadgitea-c36e7d322e74a55749ce2c2934c6fcfa82cff274.tar.gz
gitea-c36e7d322e74a55749ce2c2934c6fcfa82cff274.zip
Mirror updates
Diffstat (limited to 'models')
-rw-r--r--models/models.go10
-rw-r--r--models/repo.go28
2 files changed, 25 insertions, 13 deletions
diff --git a/models/models.go b/models/models.go
index 0e20a1ab2f..d485489586 100644
--- a/models/models.go
+++ b/models/models.go
@@ -120,7 +120,10 @@ func NewEngine() (err error) {
type Statistic 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.Action, _ = orm.Count(new(Action))
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
}
diff --git a/models/repo.go b/models/repo.go
index bb0c164e24..6943d05e0b 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -66,6 +66,7 @@ func NewRepoContext() {
type Repository struct {
Id int64
OwnerId int64 `xorm:"unique(s)"`
+ Owner *User `xorm:"-"`
ForkId int64
LowerName string `xorm:"unique(s) 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
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "add", "--all"); err != nil {
return err
- }
- if len(stderr) > 0 {
- log.Trace("stderr(1): %s", stderr)
+ } else if strings.Contains(stderr, "fatal:") {
+ return errors.New("git add: " + stderr)
}
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email),
"-m", "Init commit"); err != nil {
return err
- }
- if len(stderr) > 0 {
- log.Trace("stderr(2): %s", stderr)
+ } else if strings.Contains(stderr, "fatal:") {
+ return errors.New("git commit: " + stderr)
}
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "push", "origin", "master"); err != nil {
return err
- }
- if len(stderr) > 0 {
- log.Trace("stderr(3): %s", stderr)
+ } else if strings.Contains(stderr, "fatal:") {
+ return errors.New("git push: " + stderr)
}
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)
if err != nil {
return err
- }
- if len(stderr) > 0 {
- log.Trace("repo.initRepository(git clone): %s", stderr)
+ } else if strings.Contains(stderr, "fatal:") {
+ return errors.New("git clone: " + stderr)
}
// README
@@ -725,6 +722,13 @@ func GetRepositories(user *User, private bool) ([]Repository, error) {
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) {
return orm.Count(&Repository{OwnerId: user.Id})
}