Skip to content

Show changes in submodules in PR #25888

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

Closed
mikaeleimantlab opened this issue Jul 14, 2023 · 7 comments
Closed

Show changes in submodules in PR #25888

mikaeleimantlab opened this issue Jul 14, 2023 · 7 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/proposal The new feature has not been accepted yet but needs to be discussed first.
Milestone

Comments

@mikaeleimantlab
Copy link

Feature Description

It would be very useful to be able to see changes made in submodules when reviewing a PR, instead of just seeing the changed submodule commit hash.

This is supported by git using the git diff --submodule=diff main option, which I'm guessing means that the changes needed on the Gitea end would be relatively small: submodule contents would need to be fetched and the diff command tweaked.

I imagine this would be an option to enable (per repo, per org or globally?).

Example (cleaned for readability) output from git diff as it used by Gitea now:

README.md:
+
+And now we've added a sub repo, to see how that works.

sub-repo:
-Subproject commit 773e95df076c02e982bea7eb745866e92e0cfcfb
+Subproject commit 4326ed282c7f5bd49fd4a29c1ac0f414d25d71b9

Example output using git diff --submodule=diff:

README.md:
+
+And now we've added a sub repo, to see how that works.

sub-repo/README.md:
+# Sub repo
+
+Test av hur Gitea hanterar ändringar i sub-repon.

This would make it a lot easier to review all the changes for a PR of the parent repo in a single view, instead of manually having to navigate separate PRs for each submodule. Especially in projects using many submodules, this saves a lot of time and mental effort.

You would still need to create PRs for merging the changes for each submodule into their respective main branches, but at least the review can be performed efficiently for the overall work before performing those PRs.

Screenshots

No response

@mikaeleimantlab mikaeleimantlab added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Jul 14, 2023
@AdamMajer
Copy link
Contributor

I don't believe we would need to fetch submodule content and change the command here. We can just coalesce the diff output between repositories directly.

If there is a submodule, issue a diff to child repository -- it either is on the server, which makes this trivial, or it's not, so we can't do submodule diff then.. We already have the two relevant commit ids from the parent repository. Then replace the paths and append the diffs.

Thing to keep in mind is that these submodules could be recursive and one could even craft an infinite recursion.

I think that having UI option in the diff/commit view to either include the submodule diff or not would be best here.

@delvh
Copy link
Member

delvh commented Jul 3, 2024

Yes, your approach sounds like a good idea.
However, we then need the following adjustments:

  • there is either a timeout, a recursion detection mechanism, or both. The timeout would be the dirty solution. We probably need both.
  • files that changed in a submodule must be visually distinct from all other files to make it immediately clear that you didn't change them yourself
  • the same detection would also be needed when viewing any commit, or any subrange of a PR

@AdamMajer
Copy link
Contributor

Well, you did change them yourself, through updating the commit id for the submodule. But I agree it would be a good idea to have this visually distinct.

If submodule is detected in the diff, we can add a diff submodule menu. For example,

  • no submodule expansion
  • 1-level submodule expansion
  • recursive expansion

Similar to the one we have for whitespace, etc.

@lunny lunny added this to the 1.24.0 milestone Jan 4, 2025
wxiaoguang added a commit that referenced this issue Jan 8, 2025
This adds links to submodules in diffs, similar to the existing link
when viewing a repo at a specific commit. It does this by expanding diff
parsing to recognize changes to submodules, and find the specific refs
that are added, deleted or changed.

Related #25888

---------

Co-authored-by: wxiaoguang <[email protected]>
@lunny
Copy link
Member

lunny commented Jan 29, 2025

After #33097 was merged, reviewing changes has become easier due to submodule reversion improvements. However, since submodules can reference a remote Git server, retrieving the changed files efficiently remains a challenge, as it may introduce network latency and performance issues.

@AdamMajer
Copy link
Contributor

Remote fetching should be out of scope here. It can even introduce vectors for vulnerabilities.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jan 30, 2025

I think we can mark this issue as "completed" because the review UI provides a "compare/...." link for submodules in #33097 .

I also agree that we shouldn't spend time on fetching remote submodules to compare, it would cause many problems including performance regressions.

image

@wxiaoguang wxiaoguang added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Jan 30, 2025
@AdamMajer
Copy link
Contributor

I agree, the minimum requirements looks to be there, so this can be closed as completed. It would be nice to have ability to show these diffs inline without reloading, but that can be done at a later point.

@lunny lunny closed this as completed Jan 30, 2025
@go-gitea go-gitea locked as resolved and limited conversation to collaborators May 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

5 participants