diff options
author | Kerwin Bryant <kerwin612@qq.com> | 2025-04-15 22:35:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-15 22:35:22 +0800 |
commit | 2b99a58f540a15a04b48cba507ace8abf3c52014 (patch) | |
tree | aa14c105285455352ba37ed386f3cfab83b4eccf /services/gitdiff/gitdiff.go | |
parent | 18a673bad1d036502baca4491a16679692c42320 (diff) | |
download | gitea-2b99a58f540a15a04b48cba507ace8abf3c52014.tar.gz gitea-2b99a58f540a15a04b48cba507ace8abf3c52014.zip |
Mark parent directory as viewed when all files are viewed (#33958)
Fix #25644
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'services/gitdiff/gitdiff.go')
-rw-r--r-- | services/gitdiff/gitdiff.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 9ee86d9dfc..a859945378 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -1337,10 +1337,13 @@ func GetDiffShortStat(gitRepo *git.Repository, beforeCommitID, afterCommitID str // SyncUserSpecificDiff inserts user-specific data such as which files the user has already viewed on the given diff // Additionally, the database is updated asynchronously if files have changed since the last review -func SyncUserSpecificDiff(ctx context.Context, userID int64, pull *issues_model.PullRequest, gitRepo *git.Repository, diff *Diff, opts *DiffOptions, files ...string) error { +func SyncUserSpecificDiff(ctx context.Context, userID int64, pull *issues_model.PullRequest, gitRepo *git.Repository, diff *Diff, opts *DiffOptions) (*pull_model.ReviewState, error) { review, err := pull_model.GetNewestReviewState(ctx, userID, pull.ID) - if err != nil || review == nil || review.UpdatedFiles == nil { - return err + if err != nil { + return nil, err + } + if review == nil || len(review.UpdatedFiles) == 0 { + return review, nil } latestCommit := opts.AfterCommitID @@ -1393,11 +1396,11 @@ outer: err := pull_model.UpdateReviewState(ctx, review.UserID, review.PullID, review.CommitSHA, filesChangedSinceLastDiff) if err != nil { log.Warn("Could not update review for user %d, pull %d, commit %s and the changed files %v: %v", review.UserID, review.PullID, review.CommitSHA, filesChangedSinceLastDiff, err) - return err + return nil, err } } - return nil + return review, err } // CommentAsDiff returns c.Patch as *Diff |