mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 08:57:54 +01:00
Fixing bug
This commit is contained in:
parent
f219ddcf4e
commit
932f717adb
@ -79,6 +79,16 @@ func CommitRepoAction(userId int64, userName string,
|
|||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update repository last update time.
|
||||||
|
repo, err := GetRepositoryByName(userId, repoName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
repo.Updated = time.Now()
|
||||||
|
if err = UpdateRepository(repo); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,6 +358,11 @@ func RepoPath(userName, repoName string) string {
|
|||||||
return filepath.Join(UserPath(userName), repoName+".git")
|
return filepath.Join(UserPath(userName), repoName+".git")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateRepository(repo *Repository) error {
|
||||||
|
_, err := orm.Id(repo.Id).UseBool().Update(repo)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteRepository deletes a repository for a user or orgnaztion.
|
// DeleteRepository deletes a repository for a user or orgnaztion.
|
||||||
func DeleteRepository(userId, repoId int64, userName string) (err error) {
|
func DeleteRepository(userId, repoId int64, userName string) (err error) {
|
||||||
repo := &Repository{Id: repoId, OwnerId: userId}
|
repo := &Repository{Id: repoId, OwnerId: userId}
|
||||||
@ -402,9 +407,9 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetRepositoryByName returns the repository by given name under user if exists.
|
// 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{
|
repo := &Repository{
|
||||||
OwnerId: user.Id,
|
OwnerId: userId,
|
||||||
LowerName: strings.ToLower(repoName),
|
LowerName: strings.ToLower(repoName),
|
||||||
}
|
}
|
||||||
has, err := orm.Get(repo)
|
has, err := orm.Get(repo)
|
||||||
|
@ -279,9 +279,7 @@ func GetUserByName(name string) (*User, error) {
|
|||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
return nil, ErrUserNotExist
|
return nil, ErrUserNotExist
|
||||||
}
|
}
|
||||||
user := &User{
|
user := &User{LowerName: strings.ToLower(name)}
|
||||||
LowerName: strings.ToLower(name),
|
|
||||||
}
|
|
||||||
has, err := orm.Get(user)
|
has, err := orm.Get(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -54,7 +54,7 @@ func RepoAssignment(redirect bool) martini.Handler {
|
|||||||
ctx.Repo.Owner = user
|
ctx.Repo.Owner = user
|
||||||
|
|
||||||
// get repository
|
// get repository
|
||||||
repo, err := models.GetRepositoryByName(user, params["reponame"])
|
repo, err := models.GetRepositoryByName(user.Id, params["reponame"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if redirect {
|
if redirect {
|
||||||
ctx.Redirect("/")
|
ctx.Redirect("/")
|
||||||
|
2
serve.go
2
serve.go
@ -86,7 +86,7 @@ func runServ(*cli.Context) {
|
|||||||
|
|
||||||
os.Setenv("userName", user.Name)
|
os.Setenv("userName", user.Name)
|
||||||
os.Setenv("userId", strconv.Itoa(int(user.Id)))
|
os.Setenv("userId", strconv.Itoa(int(user.Id)))
|
||||||
repo, err := models.GetRepositoryByName(user, repoName)
|
repo, err := models.GetRepositoryByName(user.Id, repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Unavilable repository", err)
|
println("Unavilable repository", err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user