mirror of
https://github.com/go-gitea/gitea
synced 2024-12-26 02:24:27 +00:00
Backport #31712 by @lunny Fix #31708 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
0fb1c1fbfd
commit
7e9a895007
@ -741,17 +741,18 @@ func GetRepositoryByOwnerAndName(ctx context.Context, ownerName, repoName string
|
|||||||
|
|
||||||
// GetRepositoryByName returns the repository by given name under user if exists.
|
// GetRepositoryByName returns the repository by given name under user if exists.
|
||||||
func GetRepositoryByName(ctx context.Context, ownerID int64, name string) (*Repository, error) {
|
func GetRepositoryByName(ctx context.Context, ownerID int64, name string) (*Repository, error) {
|
||||||
repo := &Repository{
|
var repo Repository
|
||||||
OwnerID: ownerID,
|
has, err := db.GetEngine(ctx).
|
||||||
LowerName: strings.ToLower(name),
|
Where("`owner_id`=?", ownerID).
|
||||||
}
|
And("`lower_name`=?", strings.ToLower(name)).
|
||||||
has, err := db.GetEngine(ctx).Get(repo)
|
NoAutoCondition().
|
||||||
|
Get(&repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrRepoNotExist{0, ownerID, "", name}
|
return nil, ErrRepoNotExist{0, ownerID, "", name}
|
||||||
}
|
}
|
||||||
return repo, err
|
return &repo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// getRepositoryURLPathSegments returns segments (owner, reponame) extracted from a url
|
// getRepositoryURLPathSegments returns segments (owner, reponame) extracted from a url
|
||||||
|
Loading…
Reference in New Issue
Block a user