From e279f0e904197d6ad7278cfa6dcea505742b2c48 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 16 Jul 2025 11:21:44 -0700 Subject: [PATCH] Rename --- models/issues/comment.go | 2 +- services/issue/comments.go | 2 +- services/issue/issue.go | 2 +- services/pull/review.go | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/models/issues/comment.go b/models/issues/comment.go index 72546b89371..3d70a8c1bd2 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -764,7 +764,7 @@ func (c *Comment) CodeCommentLink(ctx context.Context) string { return fmt.Sprintf("%s/files#%s", c.Issue.Link(), c.HashTag()) } -func GetCodeCommentRef(prIndex, commentID int64) string { +func GetCodeCommentRefName(prIndex, commentID int64) string { return fmt.Sprintf("refs/pull/%d/code-comment-%d", prIndex, commentID) } diff --git a/services/issue/comments.go b/services/issue/comments.go index ba18099db7b..54d6a429cb0 100644 --- a/services/issue/comments.go +++ b/services/issue/comments.go @@ -159,7 +159,7 @@ func DeleteComment(ctx context.Context, doer *user_model.User, comment *issues_m if err := comment.Issue.LoadPullRequest(ctx); err != nil { return err } - if err := git.RemoveRef(ctx, comment.Issue.Repo.RepoPath(), issues_model.GetCodeCommentRef(comment.Issue.PullRequest.Index, comment.ID)); err != nil { + if err := git.RemoveRef(ctx, comment.Issue.Repo.RepoPath(), issues_model.GetCodeCommentRefName(comment.Issue.PullRequest.Index, comment.ID)); err != nil { log.Error("Unable to remove ref in base repository for PR[%d] Error: %v", comment.Issue.PullRequest.ID, err) // We should not return error here, because the comment has been removed from database. // users have to delete this ref manually or we should have a synchronize between diff --git a/services/issue/issue.go b/services/issue/issue.go index 332eb5c674a..8df9bdc9307 100644 --- a/services/issue/issue.go +++ b/services/issue/issue.go @@ -344,7 +344,7 @@ func deleteIssue(ctx context.Context, issue *issues_model.Issue) ([]string, erro } if comment.ReviewID > 0 { - if err := git.RemoveRef(ctx, issue.Repo.RepoPath(), issues_model.GetCodeCommentRef(issue.PullRequest.Index, comment.ID)); err != nil { + if err := git.RemoveRef(ctx, issue.Repo.RepoPath(), issues_model.GetCodeCommentRefName(issue.PullRequest.Index, comment.ID)); err != nil { log.Error("Unable to remove ref in base repository for PR[%d] Error: %v", issue.PullRequest.ID, err) // We should not return error here, because the comment has been removed from database. // users have to delete this ref manually or we should have a synchronize between diff --git a/services/pull/review.go b/services/pull/review.go index d1b5ef86062..2fc9c917ac0 100644 --- a/services/pull/review.go +++ b/services/pull/review.go @@ -289,8 +289,8 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo } // The line commit ID Must be referenced in the git repository, because the branch maybe rebased or force-pushed. - // If the review commit is GC, the position will not be calculated dynamically. - if err := git.UpdateRef(ctx, pr.BaseRepo.RepoPath(), issues_model.GetCodeCommentRef(pr.Index, comment.ID), lineCommitID); err != nil { + // If the review commit is GC, the position can not be calculated dynamically. + if err := git.UpdateRef(ctx, pr.BaseRepo.RepoPath(), issues_model.GetCodeCommentRefName(pr.Index, comment.ID), lineCommitID); err != nil { log.Error("Unable to update ref in base repository for PR[%d] Error: %v", pr.ID, err) return nil, err }