summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go30
1 files changed, 26 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go
index 4972661cb3..e27e99b056 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -10,6 +10,7 @@ import (
"fmt"
"io/ioutil"
"os"
+ "os/exec"
"path"
"path/filepath"
"regexp"
@@ -83,10 +84,11 @@ type Repository struct {
Name string `xorm:"index not null"`
Description string
Website string
- Private bool
NumWatches int
NumStars int
NumForks int
+ IsPrivate bool
+ IsBare bool
Created time.Time `xorm:"created"`
Updated time.Time `xorm:"updated"`
}
@@ -139,7 +141,8 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
Name: repoName,
LowerName: strings.ToLower(repoName),
Description: desc,
- Private: private,
+ IsPrivate: private,
+ IsBare: repoLang == "" && license == "" && !initReadme,
}
repoPath := RepoPath(user.Name, repoName)
@@ -196,6 +199,13 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
return nil, err
}
+ c := exec.Command("git", "update-server-info")
+ c.Dir = repoPath
+ err = c.Run()
+ if err != nil {
+ log.Error("repo.CreateRepository(exec update-server-info): %v", err)
+ }
+
return repo, NewRepoAction(user, repo)
}
@@ -369,6 +379,18 @@ func RepoPath(userName, repoName string) string {
return filepath.Join(UserPath(userName), repoName+".git")
}
+func UpdateRepository(repo *Repository) error {
+ if len(repo.Description) > 255 {
+ repo.Description = repo.Description[:255]
+ }
+ if len(repo.Website) > 255 {
+ repo.Website = repo.Website[:255]
+ }
+
+ _, err := orm.Id(repo.Id).UseBool().Cols("description", "website").Update(repo)
+ return err
+}
+
// DeleteRepository deletes a repository for a user or orgnaztion.
func DeleteRepository(userId, repoId int64, userName string) (err error) {
repo := &Repository{Id: repoId, OwnerId: userId}
@@ -413,9 +435,9 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) {
}
// GetRepositoryByName returns the repository by given name under user if exists.
-func GetRepositoryByName(user *User, repoName string) (*Repository, error) {
+func GetRepositoryByName(userId int64, repoName string) (*Repository, error) {
repo := &Repository{
- OwnerId: user.Id,
+ OwnerId: userId,
LowerName: strings.ToLower(repoName),
}
has, err := orm.Get(repo)