This commit is contained in:
Lunny Xiao 2025-07-16 11:21:44 -07:00
parent 64dec560dc
commit e279f0e904
4 changed files with 5 additions and 5 deletions

View File

@ -764,7 +764,7 @@ func (c *Comment) CodeCommentLink(ctx context.Context) string {
return fmt.Sprintf("%s/files#%s", c.Issue.Link(), c.HashTag()) 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) return fmt.Sprintf("refs/pull/%d/code-comment-%d", prIndex, commentID)
} }

View File

@ -159,7 +159,7 @@ func DeleteComment(ctx context.Context, doer *user_model.User, comment *issues_m
if err := comment.Issue.LoadPullRequest(ctx); err != nil { if err := comment.Issue.LoadPullRequest(ctx); err != nil {
return err 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) 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. // 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 // users have to delete this ref manually or we should have a synchronize between

View File

@ -344,7 +344,7 @@ func deleteIssue(ctx context.Context, issue *issues_model.Issue) ([]string, erro
} }
if comment.ReviewID > 0 { 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) 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. // 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 // users have to delete this ref manually or we should have a synchronize between

View File

@ -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. // 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 the review commit is GC, the position can not be calculated dynamically.
if err := git.UpdateRef(ctx, pr.BaseRepo.RepoPath(), issues_model.GetCodeCommentRef(pr.Index, comment.ID), lineCommitID); err != nil { 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) log.Error("Unable to update ref in base repository for PR[%d] Error: %v", pr.ID, err)
return nil, err return nil, err
} }