Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files are viewed on too new commits #24813

Closed
delvh opened this issue May 19, 2023 · 6 comments · Fixed by #25529
Closed

Files are viewed on too new commits #24813

delvh opened this issue May 19, 2023 · 6 comments · Fixed by #25529
Labels

Comments

@delvh
Copy link
Member

delvh commented May 19, 2023

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

@delvh delvh added the type/bug label May 19, 2023
@sebastian-sauer
Copy link
Contributor

I just checked this on my local machine and on gitea.com - for both 1.20 versions the headcommit is set.

image

I've checked this PR: https://gitea.com/xorm/xorm/pulls/2241/files

@delvh
Copy link
Member Author

delvh commented May 25, 2023

Now I'm confused…
How can this happen?


For me, it still isn't set for a private repo under my own user.
But yes, I can confirm that your link indeed displays the headcommit.

Could it be that (private?) user repos have this problem?
Or under what circumstances is the headcommit not set?

@lunny
Copy link
Member

lunny commented May 29, 2023

Now I'm confused… How can this happen?

For me, it still isn't set for a private repo under my own user. But yes, I can confirm that your link indeed displays the headcommit.

Could it be that (private?) user repos have this problem? Or under what circumstances is the headcommit not set?

Which repositories could you paste here as an example?

@delvh
Copy link
Member Author

delvh commented May 29, 2023

Well… I've just published my previously private test repo on gitea.com where I can reproduce this issue:
https://gitea.com/delvh/test/pulls/1/files
grafik
I don't know, however, how long I'll leave it public.

@sebastian-sauer
Copy link
Contributor

sebastian-sauer commented Jun 26, 2023

Steps to reproduce:

  • Create a PR with a branch that changed one file X
  • when opening the files tab the headcommit is set.
  • Merge the PR and delete the source branch of the PR
  • Open the PR files tab again
  • --> Now the headcommit of the file X will be empty.

@sebastian-sauer
Copy link
Contributor

@delvh Looks like the context variable "PullHeadCommitID" is not set.
When using "AfterCommitID" it looks like it's working - but i'm not sure if this covers all cases. Any opinions?

https://github.com/go-gitea/gitea/blob/main/templates/repo/diff/box.tmpl#L150

lunny pushed a commit that referenced this issue Jun 30, 2023
the PullHeadCommitID is not always available when the PR is merged.

Not sure if this is the best solution but in my simple tests it looks
like this fixes the problem - happy to get any feedback.

hopefully fixes #24813
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Jun 30, 2023
)

the PullHeadCommitID is not always available when the PR is merged.

Not sure if this is the best solution but in my simple tests it looks
like this fixes the problem - happy to get any feedback.

hopefully fixes go-gitea#24813
lunny pushed a commit that referenced this issue Jun 30, 2023
…5612)

Backport #25529 by @sebastian-sauer

the PullHeadCommitID is not always available when the PR is merged.

Not sure if this is the best solution but in my simple tests it looks
like this fixes the problem - happy to get any feedback.

hopefully fixes #24813

Co-authored-by: sebastian-sauer <sauer.sebastian@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants