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

git storage: handle file renames between folders #6020

Merged
merged 2 commits into from
Jan 30, 2023

Conversation

EricFromCanada
Copy link
Contributor

I've discovered that my implementation of handling moved or renamed files for git storage in #4307 was incomplete. It turns out that if the old and new file paths have common elements, git diff --stat -M <hash-before> <hash-after> (called by this.git.diffSummary) will display them in a compressed format using braces. This commit updates the logic to handle all the non-renaming, simple renaming, and compressed renaming formats that I was able to find. Examples are below:

// edit top level file
file.md
// rename top level file
file.md => index.md
// move file to folder
index.md => folder/index.md
// rename folder, or move file between folders
{folder => directory}/index.md
// rename file in folder
directory/{index.md => subindex.md}
// move file to subfolder
directory/{ => subdir}/subindex.md
// rename subfolder, or move file between subfolders
directory/{subdir => subdirectory}/subindex.md
// move file from subfolder
directory/{subdirectory => }/subindex.md
// move and rename file to subfolder
directory/{subindex.md => subdirectory/sub-index.md}
// move and rename file between subfolders
directory/{subdirectory/sub-index.md => subdir/subdir-index.md}
// move and rename file from subfolder
directory/{subdir/subdir-index.md => dir-index.md}
// move and rename file between folders
directory/dir-index.md => other/other-index.md
// move and rename file to top level
other/other-index.md => home.md

This also updates the destinationTitle logic to better detect and update page titles that have not been updated since being auto-generated from the page's path, which originally worked only for top-level pages.

This should fix the behaviour observed in #4701 and potentially #4677.

@NGPixel NGPixel added the under review Acknowledged, awaiting further review label Jan 17, 2023
@NGPixel NGPixel merged commit 2e85854 into requarks:main Jan 30, 2023
@EricFromCanada EricFromCanada deleted the git-file-relocation branch February 8, 2023 16:00
davidflypei pushed a commit to davidflypei/wiki that referenced this pull request Jun 13, 2023
* git storage: handle file renames between folders

---------

Co-authored-by: Nicolas Giard <github@ngpixel.com>
jionggyu pushed a commit to jionggyu/wiki-2.5.302-patch that referenced this pull request Jul 9, 2024
* git storage: handle file renames between folders

---------

Co-authored-by: Nicolas Giard <github@ngpixel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
under review Acknowledged, awaiting further review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants