From ade0ec54cb14b73460bce2db051c8dccb642223e Mon Sep 17 00:00:00 2001 From: Omer Zidkoni Date: Tue, 12 Sep 2023 10:42:20 +0300 Subject: [PATCH] fix bitbucket server --- vcsclient/bitbucketserver.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vcsclient/bitbucketserver.go b/vcsclient/bitbucketserver.go index 1397ed50..5ae7c4a8 100644 --- a/vcsclient/bitbucketserver.go +++ b/vcsclient/bitbucketserver.go @@ -424,9 +424,9 @@ func (client *BitbucketServerClient) addPullRequestComment(ctx context.Context, return err } bitbucketClient := client.buildBitbucketClient(ctx) - anchor := &bitbucketv1.Anchor{} - filePath := vcsutils.GetPullRequestFilePath(comment.NewFilePath) - if filePath != "" { + // Determine the file path and anchor + var anchor *bitbucketv1.Anchor + if filePath := vcsutils.GetPullRequestFilePath(comment.NewFilePath); filePath != "" { anchor = &bitbucketv1.Anchor{ Line: comment.NewStartLine, LineType: "CONTEXT", @@ -435,11 +435,13 @@ func (client *BitbucketServerClient) addPullRequestComment(ctx context.Context, SrcPath: filePath, } } - _, err = bitbucketClient.CreatePullRequestComment(owner, repository, pullRequestID, bitbucketv1.Comment{ + + // Create the pull request comment + commentData := bitbucketv1.Comment{ Text: comment.Content, Anchor: anchor, - }, []string{"application/json"}) - + } + _, err = bitbucketClient.CreatePullRequestComment(owner, repository, pullRequestID, commentData, []string{"application/json"}) return err }