Browse Source

Fix user search on gitea api.

gitea
pebles 5 months ago
parent
commit
c1f77c5422
Signed by: pebles
GPG Key ID: 4501C52A9268B49C
  1. 11
      gitea/gitea.go

11
gitea/gitea.go

@ -69,16 +69,21 @@ func (g *Gitea) Repo(user string, repo string) (*Repo, error) {
// UserID check users exists and return user id
func (r *Repo) UserID() (int, error) {
userexist, err := r.client.SearchUsers(r.user, 1)
userexist, err := r.client.SearchUsers(r.user, 0)
if err != nil {
return -1, err
}
uid := -2
emptyuser := []*gitea.User{}
if reflect.DeepEqual(userexist, emptyuser) == true {
return -2, err
return uid, err
}
uid := int(userexist[0].ID)
for i := 0; i < len(userexist); i++ {
if userexist[i].UserName == r.user {
uid = int(userexist[i].ID)
}
}
return uid, nil
}

Loading…
Cancel
Save