parseRepoID parses the github-repo-id metadata value. A missing value returns 0, as skills installed by earlier versions don't record it.
(v any)
| 697 | // parseRepoID parses the github-repo-id metadata value. A missing value |
| 698 | // returns 0, as skills installed by earlier versions don't record it. |
| 699 | func parseRepoID(v any) (int64, error) { |
| 700 | var id int64 |
| 701 | switch v := v.(type) { |
| 702 | case nil: |
| 703 | return 0, nil |
| 704 | case int: |
| 705 | id = int64(v) |
| 706 | case string: |
| 707 | parsed, err := strconv.ParseInt(v, 10, 64) |
| 708 | if err != nil { |
| 709 | return 0, fmt.Errorf("invalid github-repo-id %q", v) |
| 710 | } |
| 711 | id = parsed |
| 712 | default: |
| 713 | return 0, fmt.Errorf("invalid github-repo-id %v", v) |
| 714 | } |
| 715 | if id <= 0 { |
| 716 | return 0, fmt.Errorf("invalid github-repo-id %d", id) |
| 717 | } |
| 718 | return id, nil |
| 719 | } |
| 720 | |
| 721 | // promptForSkillOrigin asks the user for the source repository of a skill |
| 722 | // that has no GitHub metadata. |
no test coverage detected