Update config, add manual cache unlocking
This commit is contained in:
@ -31,6 +31,7 @@ type Project struct {
|
||||
AvatarURL string
|
||||
LastActivityAt time.Time
|
||||
Readme string
|
||||
Language *string
|
||||
gitRepo *git.Repository
|
||||
}
|
||||
|
||||
@ -196,12 +197,33 @@ func (c *Client) handleProjects(projects []*gitlab.Project) []*Project {
|
||||
AvatarURL: project.AvatarURL,
|
||||
LastActivityAt: *project.LastActivityAt,
|
||||
Readme: project.ReadmeURL,
|
||||
Language: c.GetProjectLanguage(project),
|
||||
}
|
||||
pList = append(pList, p)
|
||||
}
|
||||
return pList
|
||||
}
|
||||
|
||||
// A nil return indicates an API error or GitLab doesn't know what
|
||||
// language the project uses.
|
||||
func (c *Client) GetProjectLanguage(project *gitlab.Project) *string {
|
||||
l, _, e := c.gitlab.Projects.GetProjectLanguages(project.ID, gitlab.WithContext(c.Ctx))
|
||||
if e != nil {
|
||||
pterm.Error.Printfln("Failed requesting project languages: %s", e.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
var mainLang *string
|
||||
var mostUsed float32
|
||||
for name, p := range *l {
|
||||
if p > mostUsed {
|
||||
mainLang = &name
|
||||
}
|
||||
}
|
||||
|
||||
return mainLang
|
||||
}
|
||||
|
||||
func NewGitlabClient(ctx context.Context, host, token string) (*Client, error) {
|
||||
client, err := gitlab.NewClient(token, gitlab.WithBaseURL(host))
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user