-
-
Notifications
You must be signed in to change notification settings - Fork 522
[BUGFIX] Allow use of trailing slash for cp/mv command #3080
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @GLobyNew, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request addresses issue #3075, allowing the use of a trailing slash in cp
and mv
commands. The changes modify the directMove
functions in internal/store/leaf/move.go
and internal/store/root/move.go
to handle trailing slashes in the destination path. Specifically, if the destination path ends with a slash, the code now appends the base name of the source file to the destination path, effectively creating a new directory and moving/copying the source file into it. Additionally, the store prefix removal logic in internal/store/root/move.go
was adjusted to avoid removing the prefix from the destination path, as it might represent a new folder.
Highlights
- Bug Fix: Fixes issue #3075, enabling the use of trailing slashes with
cp
andmv
commands. - Trailing Slash Handling: Implements logic to interpret a trailing slash in the destination path as a request to create a new directory and move/copy the source file into it.
- Store Prefix Handling: Adjusts store prefix removal logic in
internal/store/root/move.go
to correctly handle destination paths that may represent new folders.
Changelog
- internal/store/leaf/move.go
- Added a check for a trailing slash in the destination path (
to
). - If a trailing slash is present, the base name of the source file is appended to the destination path.
- This ensures that the file is moved/copied into a new directory with the same name.
- Added a check for a trailing slash in the destination path (
- internal/store/root/move.go
- Modified the
directMove
function to handle trailing slashes in the destination path. - The store prefix is no longer removed from the destination path (
to
) to allow for creating new folders. - Adjusted the
getStore
call to only remove the store prefix from the source path (from
).
- Modified the
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A trailing slash, a simple sign,
To move a file, a new design.
In gopass code, the fix takes hold,
A folder made, a story told.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request introduces a fix to allow the use of a trailing slash for the cp
and mv
commands. This change modifies the directMove
functions in both the leaf
and root
store implementations to handle destinations with trailing slashes, treating them as requests to create a new folder and move/copy the source file into it. The changes also adjust how the destination path is handled in the root
store to accommodate this new behavior. Overall, the changes seem reasonable, but there are a few areas that could be improved for clarity and robustness.
Summary of Findings
- Inconsistent destination path handling: The
root
store'sdirectMove
function modifies how the destination path is processed, potentially leading to inconsistencies in how paths are handled across different store types. This could introduce unexpected behavior or bugs in other parts of the application. - Lack of input validation: The code does not explicitly validate the destination path to ensure it's a valid directory name. This could lead to issues if the destination contains invalid characters or is otherwise malformed.
- Potential for directory creation failure: The code assumes that the destination directory will be created successfully. However, there is no explicit error handling for the case where directory creation fails, which could lead to unexpected behavior or data loss.
Merge Readiness
The pull request addresses a specific issue and includes passing tests, suggesting it resolves the reported problem. However, the potential inconsistencies in destination path handling and the lack of explicit error handling for directory creation failures raise concerns. I recommend addressing these issues before merging. I am unable to approve this pull request, and users should have others review and approve this code before merging.
Holy, this gemini is annoying. |
I understand your frustration, GLobyNew. Is there something specific about my feedback that you find annoying? Knowing what's bothering you will help me improve and provide more useful reviews in the future. |
Signed-off-by: Ilya Eryomenko <ilya@eryomenko.com>
7d1f51f
to
bcab83c
Compare
Forced-pushed a few new conditions, to make sure everything works fine even if folder/file already exist |
Is something wrong with pull request? |
@GLobyNew sorry, I couldn't get around to do a proper review, yet. Some PRs look trivial but others I want to try myself first and I don't always have the setup to do that. You should get proper feedback in a few days at most. |
This doesn't seem to break anything, but I wonder if it has the intended effects. Please help me understand your intentions @GLobyNew . I did try to reproduce the issue and the fix and don't see any difference between moving with or without a trailing slash. Also I couldn't spot the difference between head and this PR. |
@dominikschulz That's really strange. Have you tried it in REPL mode? For me issue is still persist in current HEAD/master branch. Take a loot of this:
I had Now lets try my PR:
Now it moves entry1 to desired folder2. Basically my code only changes 2 things:
I hope this clears things out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot. I was missing two key pieces: (a) that it old affects REPL and (b) that we were trying to move to a non-existing folder.
This should fix #3075
Not an elegant solution, but all tests are passed and works as expected