Skip to content

feat: add safety warning before initializing a git repository #34

@shatrughantwt

Description

@shatrughantwt

Problem

Currently, running gitx -i/--init will initialize a git repository in the current directory without any additional confirmation.

This can be risky if the command is executed from sensitive or unintended locations (e.g. /, $HOME, /tmp), where initializing a repository is usually not desired.

Proposed Solution

Add a safety warning before running git init when the current directory is considered potentially unsafe.

Suggested behavior:

  • When gitx -i/--init is run in a sensitive directory:
    • Print a clear warning explaining the risk.
    • Ask the user for confirmation (e.g. Continue? [y/N]:).
    • Abort the operation if the user does not explicitly confirm.
  • When run in a normal project directory:
    • Proceed without any additional prompt.

Notes

  • This check would only apply when using the -i/--init flag.
  • The TUI should only open after successful initialization.
  • Happy to adjust the scope or behavior based on maintainer feedback.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestlanguage/goRequires the knowledge of "Go"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions