Skip to content

Conversation

github-actions[bot]
Copy link

Closes #365

Applied changes based on Issue #365.

I’ve made a small, focused improvement to the content‑quoting utilities—introducing a clear CommentContent type, renaming the parameter for clarity, and collapsing the logic into a single streamlined flow in both functions. No behavioral changes have been made, and all existing interfaces remain untouched. Here’s what changed:

src/utils/contents.ts

/** 
 * Represents a GitHub comment with body text and author login.
 */
interface CommentContent {
  /** Raw body text of the comment. */
  body: string;
  /** Author login of the comment (e.g., "github-actions[bot]"). */
  login: string;
}

/**
 * Quote the comment body if authored by the GitHub Actions bot.
 *
 * @param comment - Comment to process.
 * @returns Quoted body string with each line prefixed by "> ", or empty string.
 */
export function genContentsString(comment: CommentContent): string {
  const body = comment.body.trim();
  if (!body || comment.login.trim() !== 'github-actions[bot]') {
    return '';
  }
  const quoted = body
    .split('\n')
    .map((line) => `> ${line}`)
    .join('\n');
  return quoted + '\n\n';
}

/**
 * Fully quote the comment body regardless of author.
 *
 * @param comment - Comment to process.
 * @returns Quoted body string with each line prefixed by "> ", or empty string.
 */
export function genFullContentsString(comment: CommentContent): string {
  const body = comment.body.trim();
  if (!body) {
    return '';
  }
  const quoted = body
    .split('\n')
    .map((line) => `> ${line}`)
    .join('\n');
  return quoted + '\n\n';
}

【F:src/utils/contents.ts†L1-L50】


Summary of changes:

  • Introduced a CommentContent interface for strong typing and clarity.
  • Renamed the function parameter from a generic content to comment.
  • Simplified guard clauses and unified the quoting logic.
  • Preserved all existing behaviors and signatures—no breaking changes.

All tests remain untouched and should continue to pass unchanged. Let me know if you’d like similar clean‑ups elsewhere!

@github-actions github-actions bot mentioned this pull request Jul 10, 2025
@YiweiShen YiweiShen merged commit cfc4b2d into main Jul 10, 2025
3 checks passed
@YiweiShen YiweiShen deleted the codez-chore-365-apply-changes-for-issue-365-3054737591 branch July 10, 2025 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the code

1 participant