(data []byte, name, dir string, agentHostIDs []string, scope string)
| 395 | } |
| 396 | |
| 397 | func parseInstalledSkill(data []byte, name, dir string, agentHostIDs []string, scope string) (listedSkill, bool) { |
| 398 | s := listedSkill{ |
| 399 | skillName: name, |
| 400 | agentHostIDs: agentHostIDs, |
| 401 | scope: scope, |
| 402 | path: dir, |
| 403 | } |
| 404 | |
| 405 | result, err := frontmatter.Parse(string(data)) |
| 406 | if err != nil { |
| 407 | return s, false |
| 408 | } |
| 409 | |
| 410 | meta := result.Metadata.Meta |
| 411 | if meta == nil { |
| 412 | return s, false |
| 413 | } |
| 414 | installMetadata := hasInstallMetadata(meta) |
| 415 | |
| 416 | if sourcePath, _ := meta["github-path"].(string); sourcePath != "" { |
| 417 | if skillName := skillNameFromSourcePath(sourcePath); skillName != "" { |
| 418 | s.skillName = skillName |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | if repoURL, _ := meta["github-repo"].(string); repoURL != "" { |
| 423 | s.sourceURL = repoURL |
| 424 | s.source = repoURL |
| 425 | if repo, parseErr := source.ParseRepoURL(repoURL); parseErr == nil { |
| 426 | s.source = ghrepo.FullName(repo) |
| 427 | s.sourceURL = source.BuildRepoURL(repo.RepoHost(), repo.RepoOwner(), repo.RepoName()) |
| 428 | } |
| 429 | } else if localPath, _ := meta["local-path"].(string); localPath != "" { |
| 430 | s.sourceURL = localPath |
| 431 | s.source = localPath |
| 432 | } |
| 433 | |
| 434 | if ref, _ := meta["github-ref"].(string); ref != "" { |
| 435 | s.version = discovery.ShortRef(ref) |
| 436 | } |
| 437 | if pinnedRef, _ := meta["github-pinned"].(string); pinnedRef != "" { |
| 438 | s.pinned = true |
| 439 | if s.version == "" { |
| 440 | s.version = pinnedRef |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | return s, installMetadata |
| 445 | } |
| 446 | |
| 447 | func hasInstallMetadata(meta map[string]interface{}) bool { |
| 448 | for _, key := range []string{"github-repo", "github-ref", "github-tree-sha", "github-path", "github-pinned", "local-path"} { |
no test coverage detected