MCPcopy Index your code
hub / github.com/cli/cli / ResolveCommentNodeID

Method ResolveCommentNodeID

pkg/cmd/discussion/client/client.go:1293–1311  ·  view source on GitHub ↗

ResolveCommentNodeID constructs a discussion comment node ID from a repository and a comment database ID. It fetches the repository's database ID via the API, then encodes the data into a "DC_" prefixed node ID.

(repo ghrepo.Interface, commentDatabaseID int64)

Source from the content-addressed store, hash-verified

1291// repository and a comment database ID. It fetches the repository's database
1292// ID via the API, then encodes the data into a "DC_" prefixed node ID.
1293func (c *discussionClient) ResolveCommentNodeID(repo ghrepo.Interface, commentDatabaseID int64) (string, error) {
1294 meta, err := c.getRepositoryMeta(repo)
1295 if err != nil {
1296 return "", err
1297 }
1298
1299 buf := bytes.Buffer{}
1300 parts := []int64{0, meta.DatabaseId, commentDatabaseID}
1301
1302 encoder := msgpack.NewEncoder(&buf)
1303 encoder.UseCompactInts(true)
1304
1305 if err := encoder.Encode(parts); err != nil {
1306 return "", fmt.Errorf("encoding comment node ID: %w", err)
1307 }
1308
1309 encoded := base64.RawURLEncoding.EncodeToString(buf.Bytes())
1310 return "DC_" + encoded, nil
1311}

Callers

nothing calls this directly

Calls 2

getRepositoryMetaMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected