Giter Club home page Giter Club logo

Comments (5)

kubukoz avatar kubukoz commented on August 24, 2024 6

hey @mshick, have you made any progress on that? Happy to help if you don't have the bandwidth.

from add-pr-comment.

mshick avatar mshick commented on August 24, 2024 3

Interesting issue. I intend to address this by checking the message size and breaking the message into parts if we hit the limit.

I'll make this behavior optional, the default will be to truncate the message with ... to avoid the error.

from add-pr-comment.

kishaningithub avatar kishaningithub commented on August 24, 2024

It seems that this 65536 chars is a hard limit https://github.com/orgs/community/discussions/41331 on the gh api

one very interesting this is that this is actually misleading, if you see the following run in the same repo of mine, i am able to pass a 200 KB txt file inside which is higher than 65536 chars (~65 KB)

Links

Screenshot

image

from add-pr-comment.

kishaningithub avatar kishaningithub commented on August 24, 2024

We can probably have a function like below to splits the comment into multiple comments based on maxSize which can be 65536(though in actuality it seems to extend till ~200 KB) and sepEnd and sepStart variables can say what must be the separator when the comment gets split into multiple comments

example of sepStart - Continued from previous comment
example of sepEnd - Output length greater than max comment size. Continued in next comment.

The return value of this can be used to make multiple calls to the create comment API. Same can also probably bedone for the message-path and message-paths variants

function SplitComment(comment, maxSize, sepEnd, sepStart) {
  if (comment.length <= maxSize) {
    return [comment];
  }

  const maxWithSep = maxSize - sepEnd.length - sepStart.length;
  const comments = [];
  const numComments = Math.ceil(comment.length / maxWithSep);

  for (let i = 0; i < numComments; i++) {
    const start = i * maxWithSep;
    const end = Math.min(comment.length, (i + 1) * maxWithSep);
    let portion = comment.substring(start, end);

    if (i < numComments - 1) {
      portion += sepEnd;
    }
    if (i > 0) {
      portion = sepStart + portion;
    }

    comments.push(portion);
  }

  return comments;
}

from add-pr-comment.

ljetten avatar ljetten commented on August 24, 2024

Oops, this looks misleading due to me merging a PR on a fork I made to check the tests would pass.
The one line above this comment is the PR I submitted to the actual repository..

from add-pr-comment.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.