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

Use git diff-tree for DiffFileTree on diff pages #33514

Merged
merged 8 commits into from
Feb 28, 2025

Conversation

McRaeAlex
Copy link
Contributor

@McRaeAlex McRaeAlex commented Feb 6, 2025

Modify Diff View FileTree to show all files

Changes

  • removes Show Status button on diff
  • uses git diff-tree to generate the file tree for the diff
  • doesn't reload the diff tree each time we load more files in the preview
  • selecting and unloaded file will keep loading until that file is loaded
  • removes DiffFileList.vue and "Show Stats" in diff options

Open Questions

  • selecting and unloaded file will keep loading until that file is loaded. Is this behaviour okay? It matches what github does.

Demo

In this demo I set git.MAX_GIT_DIFF_FILES=1 in my app.ini to demonstrate a worst case example. In most cases the behaviour isn't nearly as jarring as we load a bunch of files at a time.

Screen.Recording.2025-02-06.at.6.51.03.PM.mov

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 6, 2025
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 6, 2025
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/frontend labels Feb 6, 2025
@McRaeAlex McRaeAlex changed the title [WIP] Stacked on https://github.com/go-gitea/gitea/pull/33369 Use git diff-tree for DiffFileTree on diff pages Feb 7, 2025
@McRaeAlex McRaeAlex force-pushed the gitea/am/file-tab-diff-tree branch from 4799444 to 5752410 Compare February 7, 2025 03:31
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 7, 2025
@McRaeAlex
Copy link
Contributor Author

@delvh @lunny I taken this out of draft so we can discuss the open question and any other behaviour you want to go over.

@McRaeAlex McRaeAlex marked this pull request as ready for review February 7, 2025 03:38
@lunny lunny requested review from silverwind and kerwin612 February 7, 2025 03:45
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 7, 2025
@lunny lunny requested a review from wxiaoguang February 7, 2025 07:59
@lunny
Copy link
Member

lunny commented Feb 7, 2025

I think you don't need to update all the language files except en_US.

@lunny lunny added this to the 1.24.0 milestone Feb 7, 2025
@McRaeAlex
Copy link
Contributor Author

I think you don't need to update all the language files except en_US.

I am not sure I understand, If I remove it from en_US then why wouldn't I also remove it from every other language?

@lunny
Copy link
Member

lunny commented Feb 7, 2025

I think you don't need to update all the language files except en_US.

I am not sure I understand, If I remove it from en_US then why wouldn't I also remove it from every other language?

Because other language files will be synced from translate.gitea.com, so basicaly you just need to change the en_US file.

@McRaeAlex McRaeAlex force-pushed the gitea/am/file-tab-diff-tree branch from b50105b to 0982492 Compare February 8, 2025 00:27
@lunny
Copy link
Member

lunny commented Feb 8, 2025

I did a test manually, looks like a modified file can not be selected.

@McRaeAlex
Copy link
Contributor Author

@lunny Apologizes for the delay.

I wasn't able to reproduce your issue. Could you provide some more details?

Screen.Recording.2025-02-24.at.1.47.47.PM.mov

@McRaeAlex McRaeAlex force-pushed the gitea/am/file-tab-diff-tree branch from 0982492 to 705f380 Compare February 24, 2025 22:00
@McRaeAlex McRaeAlex force-pushed the gitea/am/file-tab-diff-tree branch from 705f380 to dbd2c36 Compare February 25, 2025 00:18
@McRaeAlex McRaeAlex requested a review from silverwind February 25, 2025 19:58
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 25, 2025
@wxiaoguang
Copy link
Contributor

Still have question about the script block. Are these variables used? Is the comment correct?

image

@wxiaoguang
Copy link
Contributor

ps: no need to force-push when review starts, the final merge is a squash merge. Force-push makes the review difficult because every-line needs to be re-reviewed since everything is in a commit.

@McRaeAlex
Copy link
Contributor Author

ps: no need to force-push when review starts, the final merge is a squash merge. Force-push makes the review difficult because every-line needs to be re-reviewed since everything is in a commit.

I use jj which makes this behaviour automatic and keeps my "stacked" changes up to date. I can switch to using the git cli and adding commits if its preferred.

Still have question about the script block. Are these variables used? Is the comment correct?

I have updated the comment. window.config.pageData.diffFileInfo is used in web_src/js/modules/stores.ts. I cannot find any place where diffData is used (other than diffData.isIncomplete) for example diffData.statisticsMessage seems to be dead code, I have removed it.

diffFileInfo.files.push(...diffDataFiles);
window.config.pageData.diffFileInfo = diffFileInfo;
</script>
<div id="diff-file-list"></div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this removal, will it not flash wrong content on page load when diff tree is visible?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I may be misunderstanding and this was just some data modification that has no reason to be in templates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's not related to "content flash" (and this block was marked as "module", it only executes after DOM ready).

Some old PRs used very tricky methods to make the Vue work, now it's the time to make code overall right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we should remove all such template js, except those cases that serve the purpose of avoiding flash, but those are better migrated to web components.

@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 28, 2025
@silverwind silverwind enabled auto-merge (squash) February 28, 2025 00:22
@silverwind silverwind merged commit aba96f6 into go-gitea:main Feb 28, 2025
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 28, 2025
@McRaeAlex McRaeAlex deleted the gitea/am/file-tab-diff-tree branch February 28, 2025 16:11
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 3, 2025
* giteaofficial/main:
  Use pullrequestlist instead of []*pullrequest (go-gitea#33765)
  Upgrade act to 0.261.4 and actions-proto-go to v0.4.1 (go-gitea#33760)
  Webhook add X-Gitea-Hook-Installation-Target-Type Header (go-gitea#33752)
  Fix dynamic content loading init problem (go-gitea#33748)
  [skip ci] Updated translations via Crowdin
  Add composor source field (go-gitea#33502)
  upgrade go-crypto from 1.1.5 to 1.1.6 (go-gitea#33745)
  Disable go license generation as part of `make tidy` (go-gitea#33747)
  Refactor repo-diff.ts (go-gitea#33746)
  Use `git diff-tree` for `DiffFileTree` on diff pages (go-gitea#33514)
  [skip ci] Updated translations via Crowdin
  Improve "generate new access token" form (go-gitea#33730)
  Remove superflous tw-content-center (go-gitea#33741)
  Clone repository with Tea CLI (go-gitea#33725)
  allow filtering /repos/{owner}/{repo}/pulls by target base branch queryparam (go-gitea#33684)
  Show info about maintainers are allowed to edit a PR (go-gitea#33738)
  Improve admin user view page (go-gitea#33735)
  [skip ci] Updated translations via Crowdin
  Align sidebar gears to the right (go-gitea#33721)
@wxiaoguang
Copy link
Contributor

Found a bug:

Now the file tree doesn't follow the selected commit:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/translation size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants