Skip to content

Fix multiple renames bug in follow-file-renames - #4677

Merged
yakov116 merged 12 commits into
refined-github:mainfrom
shinenelson:fix/follow-file-renames-link-both-buttons
Aug 19, 2021
Merged

yakov116 merged 12 commits into
refined-github:mainfrom
shinenelson:fix/follow-file-renames-link-both-buttons

Conversation

@shinenelson

Copy link
Copy Markdown
Contributor

When a file is renamed too often and there are not many commits in between, both buttons for follow-file-renames is supposed to be active, ideally.

However, in the current implementation, the global URL object from init is being passed and mutated in linkify which would mislead the linking logic in the subsequent runs of the loop for the disabledPagination buttons.

This change modifies linkify to add a new GitHubURL object within linkify context which is used to linkify the disabledPagination buttons. The global URL object is retained since it carries the URL / name of the current file which is required to match the file in comparison.

Test URLs

The following URLs point to the life-cycle of a single file called site.rb in https://github.com/ForkAwesome/Fork-Awesome.

The first URL should have only the Older button linkified, the second and third URLs should have both buttons linkified and the last URL should have only the Newer button linkified.

sindresorhus and others added 5 commits August 16, 2021 14:26
The global URL object from `init` is being passed and mutated in
`linkify` which would mislead the linking logic in the subsequent run of
the loop for the `disabledPagination` buttons.
Comment thread source/features/follow-file-renames.tsx Resolved
@fregante fregante added the bug label Aug 18, 2021
@fregante

Copy link
Copy Markdown
Member

heh I tried reverting those 3 changes but I found another bug: restore-file does not work with force-pushes. 😅

Can you rebase this PR or exclude those changes? If too difficult it's best to just open a new PR from main

@fregante

Copy link
Copy Markdown
Member

Thanks @yakov116

@shinenelson
shinenelson requested a review from fregante August 18, 2021 23:05
@fregante fregante changed the title fix follow-file-renames to work simultaneously Fix bug around multiple renames in follow-file-renames Aug 19, 2021

@fregante fregante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

Unrelated to this PR: One thing I'm not seeing is that we should probably skip the feature when we are on folder commit list. Folders can't be renamed and don't appear in commits so I think the feature will never work there.

@shinenelson

Copy link
Copy Markdown
Contributor Author

we should probably skip the feature when we are on folder commit list

I agree. However, I could not find a detection that is specific for files ( or folders ). I created refined-github/github-url-detection#89 for it.

Comment thread source/features/follow-file-renames.tsx Resolved

@yakov116 yakov116 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Untested, LGTM

@yakov116 yakov116 changed the title Fix bug around multiple renames in follow-file-renames Fix multiple renames bug in follow-file-renames Aug 19, 2021
@yakov116
yakov116 merged commit 3262b37 into refined-github:main Aug 19, 2021
@yakov116

Copy link
Copy Markdown
Member

@fregante merged since it is blocking another PR

route: 'commits',
filePath: file[toKey],
// Clear the search from the URL
// Clear the search from the url, so it does not get passed to the rename link

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why url tho

@fregante

Copy link
Copy Markdown
Member

Tested and it works 🎉 thanks Shiiiine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants