MCPcopy Create free account
hub / github.com/github/gh-aw / extractCommentID

Function extractCommentID

pkg/cli/outcome_eval_comment.go:99–117  ·  view source on GitHub ↗

extractCommentID extracts the numeric comment ID from a GitHub comment URL. Handles formats like: https://github.com/owner/repo/issues/123#issuecomment-456789 https://github.com/owner/repo/pull/123#issuecomment-456789

(url string)

Source from the content-addressed store, hash-verified

97// https://github.com/owner/repo/issues/123#issuecomment-456789
98// https://github.com/owner/repo/pull/123#issuecomment-456789
99func extractCommentID(url string) string {
100 if _, after, found := strings.Cut(url, "#issuecomment-"); found {
101 return after
102 }
103 // Fallback: look for /comments/ID pattern
104 const commentsPrefix = "/comments/"
105 if idx := strings.LastIndex(url, commentsPrefix); idx >= 0 {
106 rest := url[idx+len(commentsPrefix):]
107 // Take only digits
108 end := 0
109 for end < len(rest) && rest[end] >= '0' && rest[end] <= '9' {
110 end++
111 }
112 if end > 0 {
113 return rest[:end]
114 }
115 }
116 return ""
117}

Callers 2

TestExtractCommentIDFunction · 0.85
evalAddCommentFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestExtractCommentIDFunction · 0.68