Skip to content

Files are viewed on too new commits #24813

Closed
@delvh

Description

@delvh

Description

Apparently, the I've viewed this file implementation is half broken now.
It's still working without complaint because it's "dangling on a single thread that hasn't been destroyed yet":
I've put in a safe-guard that apparently is the only reason it's still working:

if data.HeadCommitSHA == "" {
data.HeadCommitSHA = pull.HeadCommitID
}

For some reason, the head commit SHA isn't set (anymore?), so reviews always get assigned to the newest commit which isn't necessarily the commit someone has reviewed (in case they had their tab open for long enough that other commits were pushed)
I've traced this bug back to
<label data-link="{{$.Issue.Link}}/viewed-files" data-headcommit="{{$.PullHeadCommitID}}" class="viewed-file-form unselectable{{if $file.IsViewed}} viewed-file-checked-form{{end}}">

as apparently PullHeadCommitID is empty/not present.
However, I have no idea why this would be the case or if it has always been that way, and simply no one noticed.
(I doubt it, I remember testing the whole functionality, and I would have probably noticed it if the head-commit was always empty)

Gitea Version

1.20.0+dev-833-g040970c32

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

try.gitea.io/ gitea.com and from compiled from source

Database

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions