Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Follow file symlinks in the UI to their target#28835

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
wxiaoguang merged 15 commits intogo-gitea:mainfromdelvh:link-to-symlink
Jun 30, 2025

Conversation

@delvh
Copy link
Member

@delvhdelvh commentedJan 17, 2024
edited
Loading

Description

Previously, when you clicked on a symlink, a document was opened that only displayed<target>.
While this follows git's behavior of implementing symlinks, it is not user-friendly for users using the web UI to access a file.
Now, symlinks are resolved when you click on a link next to them, either until a file has been found or until we know that the link is dead.
When the link cannot be accessed, we fall back to the current behavior of showing the document containing the target.

Before

Screenshots

before

After

after

silverwind reacted with thumbs up emojia1012112796 reacted with eyes emoji
Only problem at the moment is that `git.TreeEntry` does not store thefull path of the entry, only the actual filename without directory.
@delvhdelvh added type/enhancementAn improvement of existing functionality topic/ui-interactionChange the process how users use Gitea instead of the visual appearance labelsJan 17, 2024
@GiteaBotGiteaBot added the lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelJan 17, 2024
@delvhdelvh added type/featureCompletely new functionality. Can only be merged if feature freeze is not active. and removed type/enhancementAn improvement of existing functionality labelsJan 17, 2024
@delvh
Copy link
MemberAuthor

Trivia: If we merge this, we are even ahead of GitHub in terms of behavior as GitHub still shows the<target> document instead of the linked location.

@delvhdelvh changed the titleLink to the symlinked file directlyFollow symlinks in the UI to their targetJan 18, 2024
@delvhdelvh changed the titleFollow symlinks in the UI to their targetFollow file symlinks in the UI to their targetJan 18, 2024
@KN4CK3R
Copy link
Member

Could you add a test forTryFollowingLinks()? (valid link, link outside repo, ...)

@delvh
Copy link
MemberAuthor

delvh commentedJan 19, 2024
edited
Loading

And the test promptly caught a bug.
Welp.
I understand what the problem is, but I have no idea how to fix it adequately:
The problem is that I usefullPath = cleanedRelativePath ingetTreeEntryByPath:

link points to../nar/hello infoo/bar/link_to_hello

Expectedfoo/nar/hello, gotnar/hello

However, I have no idea how to implementfullPath = tree.BasePath + normalizedRelativePath.
Does the tree already store this information?

KN4CK3R reacted with hooray emoji

@delvh
Copy link
MemberAuthor

delvh commentedJan 20, 2024
edited
Loading

Does the tree already store this information?

As expected, it doesn't 😒
What would be the most maintainable way to get the tree to store this information reliably?

@wxiaoguang
Copy link
Contributor

wxiaoguang commentedMar 2, 2024
edited
Loading

After reading the code, I have some new ideas, maybe more simple to do: backend does nothing, but let frontend navigate.

For example:

  • There is a link in repo:/foo/bar/link =>../aaa/bbb
  • The UI just renders<a href="/org/repo/src/branch/main/foo/bar/../aaa/bbb">link</a>. Then when user clicks the link, they should be navigated tohttps://.../src/branch/main/foo/aaa/bbb

Otherwise, if we really would like to resolve the link in backend, I guess it needs some big refactoring to make things clear.

@delvh
Copy link
MemberAuthor

@wxiaoguang the problem with the frontend approach is that the frontend cannot recursively resolve links (latest-changelog ->/b-dir/current.txt ->/doc/internal/changes-2.30.2.md).
Apart from that, yes, it would be possible.

@wxiaoguang
Copy link
Contributor

wxiaoguang commentedMar 2, 2024
edited
Loading

@wxiaoguang the problem with the frontend approach is that the frontend cannot recursively resolve links (latest-changelog ->/b-dir/current.txt ->/doc/internal/changes-2.30.2.md). Apart from that, yes, it would be possible.

For me, I would like to see the direct link target on the UI, instead of recursively resolving the links ahead. For example: suppose there is a link/foo ->/bar ->/aaa ->/bbb. As an end user, I would like to see/foo points to/bar, that's also the real filesystem shows to end users (eg:ls -l). I don't expect it shows/foo points to/bbb directly, that's somewhat counter-intuitive IMO.


If an end user would like to follow, the frontend approach could also work: use a href like/bar?follow_symlink=1, then if backend readsfollow_symlink, it redirects to the next target/aaa?follow_symbol=1 and again and agian.

delvh reacted with thumbs up emoji

@delvh
Copy link
MemberAuthor

delvh commentedMar 2, 2024
edited
Loading

But what is it you want to achieve when you click on a (symlinked) file?
In 99,9% of cases, you want to see/edit the content that is linked, not go on a journey to find the actual file.

@wxiaoguang
Copy link
Contributor

But what is it you want to achieve when you click on a (symlinked) file?
In 99,9% of cases, you want to see/edit the content that is linked, not go on a journey to find the actual file.

I updated the previous comment, a "/bar?follow_symlink=1" trick could work IMO.

delvh reacted with thumbs up emoji

@wxiaoguang
Copy link
Contributor

Are you working on this at the moment?

# Conflicts:#templates/repo/view_list.tmpl
@GiteaBotGiteaBot added lgtm/need 1This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelsJun 28, 2025
@GiteaBotGiteaBot added lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1This PR needs approval from one additional maintainer to be merged. labelsJun 28, 2025
@wxiaoguang
Copy link
Contributor

@delvh is there still anything to improve?

@delvh
Copy link
MemberAuthor

A quick skim over your changes looked good.
Will need to test it when I find the time, which should be tomorrow.
If the PR isn't merged until then, I'll update the description once I've re-tested it with up-to-date screenshots.
But yeah, nothing holding the PR back from my side.

@delvh
Copy link
MemberAuthor

So, I tested it out now and pushed a small fix.
It works as expected for now.
However, I can imagine a couple of improvements further down the line in future PRs:

  1. Display some sort of error when the link does not work
  2. Enhance the tooltip to show exactly where the link will lead
  3. Also add the same button when viewing the symlink directly or in a PR diff
wxiaoguang reacted with thumbs up emoji

@delvhdelvh added the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelJun 30, 2025
@GiteaBot
Copy link
Collaborator

@delvh please fix the merge conflicts. 🍵

@GiteaBotGiteaBot removed the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelJun 30, 2025
@delvhdelvh added the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelJun 30, 2025
@wxiaoguangwxiaoguang merged commit8dbf13b intogo-gitea:mainJun 30, 2025
26 checks passed
@GiteaBotGiteaBot removed the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelJun 30, 2025
zjjhot added a commit to zjjhot/gitea that referenced this pull requestJul 1, 2025
* giteaofficial/main:  Fix modal + form abuse (go-gitea#34921)  [skip ci] Updated translations via Crowdin  Follow file symlinks in the UI to their target (go-gitea#28835)  Fix issue filter (go-gitea#34914)  Fix: RPM package download routing & missing package version count (go-gitea#34909)  Add support for 3D/CAD file formats preview (go-gitea#34794)
@delvhdelvh deleted the link-to-symlink branchJuly 1, 2025 07:52
bdruth added a commit to bdruth/gitea that referenced this pull requestJul 4, 2025
…h/gitea into feature/enhanced-workflow-runs-api* 'feature/enhanced-workflow-runs-api' of github.com:bdruth/gitea:  [skip ci] Updated translations via Crowdin  Follow file symlinks in the UI to their target (go-gitea#28835)  Fix issue filter (go-gitea#34914)  Fix: RPM package download routing & missing package version count (go-gitea#34909)  Add support for 3D/CAD file formats preview (go-gitea#34794)  Add a `login`/`login-name`/`username` disambiguation to affected endpoint parameters and response/request models (go-gitea#34901)  Improve tags list page (go-gitea#34898)  [skip ci] Updated translations via Crowdin  docs: fix typo in pull request merge warning message text (go-gitea#34899)  Refactor container package (go-gitea#34877)  [skip ci] Updated translations via Crowdin
@go-giteago-gitea locked asresolvedand limited conversation to collaboratorsSep 29, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@lunnylunnylunny approved these changes

@wxiaoguangwxiaoguangwxiaoguang approved these changes

@KN4CK3RKN4CK3RAwaiting requested review from KN4CK3R

+2 more reviewers

@kerwin612kerwin612kerwin612 approved these changes

@hiifonghiifonghiifong approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.modifies/goPull requests that update Go codemodifies/templatesThis PR modifies the template filesmodifies/translationtopic/ui-interactionChange the process how users use Gitea instead of the visual appearancetype/featureCompletely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Milestone

1.25.0

Development

Successfully merging this pull request may close these issues.

8 participants

@delvh@KN4CK3R@wxiaoguang@GiteaBot@lunny@kerwin612@hiifong@techknowlogick

[8]ページ先頭

©2009-2025 Movatter.jp