mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 23:58:19 +00:00
feat: Add --max-comments-per-command configuration (#3905)
Co-authored-by: PePe Amengual <jose.amengual@gmail.com> Co-authored-by: Benoit Toulme <benoit.toulme@gmail.com>
This commit is contained in:
@@ -41,11 +41,12 @@ var (
|
||||
|
||||
// GithubClient is used to perform GitHub actions.
|
||||
type GithubClient struct {
|
||||
user string
|
||||
client *github.Client
|
||||
v4Client *githubv4.Client
|
||||
ctx context.Context
|
||||
config GithubConfig
|
||||
user string
|
||||
client *github.Client
|
||||
v4Client *githubv4.Client
|
||||
ctx context.Context
|
||||
config GithubConfig
|
||||
maxCommentsPerCommand int
|
||||
}
|
||||
|
||||
// GithubAppTemporarySecrets holds app credentials obtained from github after creation.
|
||||
@@ -76,7 +77,8 @@ type GithubPRReviewSummary struct {
|
||||
}
|
||||
|
||||
// NewGithubClient returns a valid GitHub client.
|
||||
func NewGithubClient(hostname string, credentials GithubCredentials, config GithubConfig, logger logging.SimpleLogging) (*GithubClient, error) {
|
||||
|
||||
func NewGithubClient(hostname string, credentials GithubCredentials, config GithubConfig, maxCommentsPerCommand int, logger logging.SimpleLogging) (*GithubClient, error) {
|
||||
logger.Debug("Creating new GitHub client for host: %s", hostname)
|
||||
transport, err := credentials.Client()
|
||||
if err != nil {
|
||||
@@ -108,11 +110,12 @@ func NewGithubClient(hostname string, credentials GithubCredentials, config Gith
|
||||
return nil, errors.Wrap(err, "getting user")
|
||||
}
|
||||
return &GithubClient{
|
||||
user: user,
|
||||
client: client,
|
||||
v4Client: v4Client,
|
||||
ctx: context.Background(),
|
||||
config: config,
|
||||
user: user,
|
||||
client: client,
|
||||
v4Client: v4Client,
|
||||
ctx: context.Background(),
|
||||
config: config,
|
||||
maxCommentsPerCommand: maxCommentsPerCommand,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -191,7 +194,10 @@ func (g *GithubClient) CreateComment(logger logging.SimpleLogging, repo models.R
|
||||
"```diff\n"
|
||||
}
|
||||
|
||||
comments := common.SplitComment(comment, maxCommentLength, sepEnd, sepStart)
|
||||
truncationHeader := "\n```\n</details>" +
|
||||
"\n<br>\n\n**Warning**: Command output is larger than the maximum number of comments per command. Output truncated.\n\n[..]\n"
|
||||
|
||||
comments := common.SplitComment(comment, maxCommentLength, sepEnd, sepStart, g.maxCommentsPerCommand, truncationHeader)
|
||||
for i := range comments {
|
||||
_, resp, err := g.client.Issues.CreateComment(g.ctx, repo.Owner, repo.Name, pullNum, &github.IssueComment{Body: &comments[i]})
|
||||
if resp != nil {
|
||||
|
||||
Reference in New Issue
Block a user