@@ -8,23 +8,33 @@ import (
88 "strconv"
99)
1010
11+ // GHIssueFinder is a struct type that implements the issue.Finder interface
1112type GHIssueFinder struct {}
1213
14+ // This provides a compile-safe way of making sure GHIssueFinder implements the issue.Finder interface
15+ var _ Finder = GHIssueFinder {}
16+
17+ // _GhIssueInfo is a struct used to unmarshal GitHub API responses.
18+ // It needs to be exported but is not intended to be used directly.
1319type _GhIssueInfo struct {
14- Number int `json:"number"`
15- Title string `json:"title"`
20+ // Number is the GitHub issue number
21+ Number int `json:"number"`
22+ // Title is the GitHub issue title
23+ Title string `json:"title"`
1624}
1725
26+ // NewGHIssueFinder returns a new object of type GHIssueFinder
1827func NewGHIssueFinder () * GHIssueFinder {
1928 return & GHIssueFinder {}
2029}
2130
31+ // FindById allows to retrieve an issue given its identifier.
32+ // It optionally writes any relevant warnings or messages to eventually output into the io.Writer object specified.
2233func (g GHIssueFinder ) FindById (w io.Writer , repo string , id string ) (Info , error ) {
2334 args := []string {"issue" , "view" , id , "--json" , "number,title" }
2435 if repo != "" {
2536 args = append (args , "-R" , repo )
2637 }
27- var issueInfo _GhIssueInfo
2838 stdOut , stdErr , err := gh .Exec (args ... )
2939 if err != nil {
3040 return Info {}, err
@@ -33,6 +43,7 @@ func (g GHIssueFinder) FindById(w io.Writer, repo string, id string) (Info, erro
3343 //goland:noinspection GoUnhandledErrorResult
3444 fmt .Fprintln (w , stdErrStr )
3545 }
46+ var issueInfo _GhIssueInfo
3647 err = json .Unmarshal (stdOut .Bytes (), & issueInfo )
3748 return Info {
3849 Id : strconv .Itoa (issueInfo .Number ),
0 commit comments