Skip to content

feat: implement global remove command#22

Merged
laggu merged 1 commit intodevelopfrom
gh-022
Feb 18, 2026
Merged

feat: implement global remove command#22
laggu merged 1 commit intodevelopfrom
gh-022

Conversation

@laggu
Copy link
Copy Markdown
Owner

@laggu laggu commented Feb 18, 2026

Closes #22

This commit implements the 'git volume global remove' command (Issue #22).

It allows removing files from the global storage with the alias 'rm'.

The implementation uses a template method pattern for consistent execution flow.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @laggu, 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!

This pull request introduces a new global remove command to the git-volume tool, enabling users to safely and efficiently delete files and directories from their global git-volume storage. The implementation includes robust error handling, security measures to prevent unintended file access, and ensures proper cleanup of empty directory structures, enhancing the overall management capabilities of the tool.

Highlights

  • New Global Remove Command: Introduced a new git volume global remove command, allowing users to delete files and directories from the global git-volume storage.
  • Robust File Removal Logic: Implemented the core logic for global file removal, including checks for initialized storage, path validation to prevent traversal attacks, existence checks, and automatic cleanup of empty parent directories.
  • Comprehensive Integration Tests: Added a suite of integration tests to verify the functionality of the global remove command, covering various scenarios like single file removal, subdirectory removal, empty directory cleanup, handling non-existent files, and security against path traversal.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cmd/global_remove.go
    • Added a new Cobra command for git volume global remove.
    • Configured command usage, short/long descriptions, and rm alias.
    • Integrated the command with the gitvolume.GlobalRemove function.
  • internal/gitvolume/remove.go
    • Implemented the GlobalRemove method to orchestrate file removal from global storage.
    • Added beforeAllRemove to validate global storage initialization.
    • Included afterAllRemove for consolidated error reporting.
    • Developed beforeRemove to perform path validation and existence checks, including security against path traversal.
    • Created remove to handle file deletion and empty parent directory cleanup.
    • Implemented afterRemove for per-file status output and error aggregation.
  • test/integration.sh
    • Added a new test section for the global remove command.
    • Included tests for removing single files and files within subdirectories.
    • Verified the preservation of non-empty subdirectories and cleanup of empty parent directories.
    • Tested error handling for non-existent files and blocked path traversal attempts.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

Footnotes

  1. 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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the global remove command, allowing users to remove files and directories from the global git-volume storage. The changes include the Cobra command definition in cmd/global_remove.go, the core removal logic in internal/gitvolume/remove.go, and comprehensive integration tests in test/integration.sh. The new functionality correctly handles single file removal, files in subdirectories, and includes important security checks against path traversal. However, a critical issue was identified where the cleanEmptyParents function is called but not defined, which will lead to a compilation error.

Comment thread internal/gitvolume/remove.go
@laggu
Copy link
Copy Markdown
Owner Author

laggu commented Feb 18, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the global remove command, a useful feature for managing the global storage. The implementation is well-structured, particularly in how it handles multiple file removals and aggregates errors. The accompanying integration tests are thorough, covering various scenarios including successful removals, error conditions, and security checks like path traversal. I've made a couple of suggestions in cmd/global_remove.go to align with the project's style guide regarding import ordering and error wrapping. After addressing these minor points, this PR will be in excellent shape.

Comment thread cmd/global_remove.go
Comment on lines +7 to +8
"github.com/laggu/git-volume/internal/gitvolume"
"github.com/spf13/cobra"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The import order does not follow the standard Go convention, which is also specified in the repository's style guide. Imports should be grouped by standard library, third-party libraries, and then local packages, with blank lines between groups.

	"github.com/spf13/cobra"

	"github.com/laggu/git-volume/internal/gitvolume"
References
  1. Rule fix: remove global directory overwrite #7 of the repository style guide (Imports: 표준 라이브러리, 서드파티 라이브러리, 로컬 패키지 순으로 그룹화합니다.) specifies that Go imports should be grouped in the order of: standard library, third-party libraries, and then local packages. (link)

Comment thread cmd/global_remove.go
RunE: func(cmd *cobra.Command, args []string) error {
gv, err := gitvolume.New(gitvolume.Options{Quiet: quiet})
if err != nil {
return err
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository's style guide, errors should be wrapped to add context. The error returned from gitvolume.New is returned directly. Please wrap it using fmt.Errorf to provide more information about where the error originated.

return fmt.Errorf("failed to initialize git-volume: %w", err)
References
  1. Rule feat: global add command #17 of the repository style guide (fmt.Errorf("...: %w", err)를 사용하여 에러에 컨텍스트를 추가(Wrap)합니다.) requires wrapping errors with fmt.Errorf and %w to add context, which improves traceability and debugging. (link)

@laggu laggu merged commit 270dd52 into develop Feb 18, 2026
@laggu laggu deleted the gh-022 branch February 18, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant