Skip to content

Refactor/default command: updated default tool call command - #16

Merged
rohansen856 merged 4 commits into
masterfrom
refactor/default-command
Sep 26, 2025
Merged

rohansen856 merged 4 commits into
masterfrom
refactor/default-command

Conversation

@rohansen856

Copy link
Copy Markdown
Owner

This pull request improves the user experience for providing author information by automatically fetching the user's name and email from their Git configuration, and refactors the argument handling logic accordingly. It also introduces new utilities for reading Git config files cross-platform and removes the previous "help request" detection logic.

Enhancements to argument handling and user experience:

  • When prompting for missing name or email arguments, the application now tries to fetch defaults from the user's Git configuration (via git config or directly from .gitconfig), and displays these as suggested defaults in the prompt. (src/args.rs, src/utils/prompt.rs, src/utils/git_config.rs) [1] [2] [3]
  • Added a new utility function prompt_with_default to prompt the user with a suggested default value, improving usability. (src/utils/prompt.rs)

Utilities for Git configuration:

  • Introduced a new module git_config that provides cross-platform functions to retrieve the user's Git name and email, including direct parsing of .gitconfig files. (src/utils/git_config.rs, src/utils/mod.rs) [1] [2]

Refactoring and cleanup:

  • Removed the is_help_request logic and all related test cases, simplifying how the CLI determines when to prompt for arguments. (src/args.rs, src/main.rs, tests/integration_tests.rs) [1] [2] [3] [4] [5] [6]

Testing improvements:

  • Added comprehensive tests for the new Git config parsing and cross-platform home directory detection logic. (src/utils/git_config.rs)
  • Updated prompt utility tests to cover prompt_with_default. (src/utils/prompt.rs)

Signed-off-by: rohansen856 <rohansen856@gmail.com>
Signed-off-by: rohansen856 <rohansen856@gmail.com>
@rohansen856
rohansen856 requested a review from Copilot September 26, 2025 10:42
@rohansen856 rohansen856 self-assigned this Sep 26, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors argument handling to improve user experience by automatically fetching Git configuration defaults and removes the help request detection logic to simplify CLI behavior.

  • Introduced Git configuration utilities to fetch user name and email from Git config
  • Enhanced prompting to show Git config values as suggested defaults
  • Removed help request detection logic and related test cases

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/git_config.rs New module with cross-platform Git config parsing and retrieval functions
src/utils/prompt.rs Added prompt_with_default function for enhanced user prompting
src/utils/mod.rs Added git_config module export
src/args.rs Updated argument handling to use Git config defaults and removed help detection
src/main.rs Removed help request check from main execution flow
tests/integration_tests.rs Removed help request assertions from integration tests

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/utils/git_config.rs
let config = r#"
# This is a comment
[user]
name = John Doe # inline comment

Copilot AI Sep 26, 2025

Copy link

Choose a reason for hiding this comment

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

The gitconfig parser doesn't handle inline comments correctly. It includes the comment as part of the value instead of stripping it. The parser should split on '#' or ';' and only use the part before the comment.

Copilot uses AI. Check for mistakes.
Comment thread src/utils/git_config.rs Outdated

// We can't assert specific values since they depend on the environment
// but we can ensure the functions execute without panicking
assert!(true);

Copilot AI Sep 26, 2025

Copy link

Choose a reason for hiding this comment

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

Using assert!(true) is a no-op assertion that doesn't test anything meaningful. Consider removing this assertion or replacing it with a more specific test that validates the functions don't panic.

Suggested change
assert!(true);

Copilot uses AI. Check for mistakes.
Comment thread src/utils/git_config.rs Outdated

// We can't test the actual path since it depends on the OS and Git installation
// but we can ensure the function doesn't panic
assert!(true);

Copilot AI Sep 26, 2025

Copy link

Choose a reason for hiding this comment

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

Using assert!(true) is a no-op assertion that doesn't test anything meaningful. Consider removing this assertion or replacing it with a more specific test that validates the function doesn't panic.

Suggested change
assert!(true);

Copilot uses AI. Check for mistakes.
Signed-off-by: rohansen856 <rohansen856@gmail.com>
@rohansen856
rohansen856 requested a review from Copilot September 26, 2025 10:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/utils/git_config.rs
Signed-off-by: rohansen856 <rohansen856@gmail.com>
@rohansen856
rohansen856 merged commit e9dffcc into master Sep 26, 2025
18 checks passed
@rohansen856
rohansen856 deleted the refactor/default-command branch September 26, 2025 17:21
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.

2 participants