@@ -8,23 +8,33 @@ import (
8
8
"strconv"
9
9
)
10
10
11
+ // GHIssueFinder is a struct type that implements the issue.Finder interface
11
12
type GHIssueFinder struct {}
12
13
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.
13
19
type _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"`
16
24
}
17
25
26
+ // NewGHIssueFinder returns a new object of type GHIssueFinder
18
27
func NewGHIssueFinder () * GHIssueFinder {
19
28
return & GHIssueFinder {}
20
29
}
21
30
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.
22
33
func (g GHIssueFinder ) FindById (w io.Writer , repo string , id string ) (Info , error ) {
23
34
args := []string {"issue" , "view" , id , "--json" , "number,title" }
24
35
if repo != "" {
25
36
args = append (args , "-R" , repo )
26
37
}
27
- var issueInfo _GhIssueInfo
28
38
stdOut , stdErr , err := gh .Exec (args ... )
29
39
if err != nil {
30
40
return Info {}, err
@@ -33,6 +43,7 @@ func (g GHIssueFinder) FindById(w io.Writer, repo string, id string) (Info, erro
33
43
//goland:noinspection GoUnhandledErrorResult
34
44
fmt .Fprintln (w , stdErrStr )
35
45
}
46
+ var issueInfo _GhIssueInfo
36
47
err = json .Unmarshal (stdOut .Bytes (), & issueInfo )
37
48
return Info {
38
49
Id : strconv .Itoa (issueInfo .Number ),
0 commit comments