MCPcopy Create free account
hub / github.com/decaporg/decap-cms / parseCommentToNote

Method parseCommentToNote

packages/decap-cms-backend-github/src/API.ts:1579–1602  ·  view source on GitHub ↗

* Parse a GitHub comment into a Note object

(comment: GitHubIssue)

Source from the content-addressed store, hash-verified

1577 * Parse a GitHub comment into a Note object
1578 */
1579 parseCommentToNote(comment: GitHubIssue): Note {
1580 if (!comment || !comment.body || !comment.user) {
1581 throw new Error('Invalid comment structure');
1582 }
1583
1584 const structuredMatch = comment.body.match(API.NOTE_REGEX);
1585
1586 const content = structuredMatch ? structuredMatch[2].trim() : comment.body;
1587 const resolved = structuredMatch ? structuredMatch[1] === API.NOTE_STATUS_RESOLVED : false;
1588
1589 if (!content.trim()) {
1590 throw new Error('Empty note content');
1591 }
1592
1593 return {
1594 id: comment.id.toString(),
1595 author: comment.user.login,
1596 avatarUrl: comment.user.avatar_url,
1597 timestamp: comment.created_at,
1598 content,
1599 resolved,
1600 entrySlug: '',
1601 };
1602 }
1603
1604 /**
1605 * Create a GitHub issue for storing notes for a specific entry

Callers 1

getEntryNotesMethod · 0.95

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected