Skip to content

Develop #17

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

Merged
merged 12 commits into from
Jul 11, 2025
Merged

Develop #17

merged 12 commits into from
Jul 11, 2025

Conversation

mingcheng
Copy link
Owner

@mingcheng mingcheng commented Jul 11, 2025

Summary by CodeRabbit

  • New Features

    • Added a new command-line option to check the availability of the OpenAI API key and model name.
    • Enhanced commit functionality to support optional sign-off lines in commit messages.
  • Bug Fixes

    • Improved model validation by checking for specific model availability when verifying OpenAI API access.
  • Documentation

    • Improved README formatting and whitespace for better readability.
  • Chores

    • Updated package metadata and keywords.
    • Commented out unused dependencies for cleaner configuration.

mingcheng and others added 12 commits July 11, 2025 17:41
- Add signoff option to CLI arguments in `cli.rs`
- Implement author name and email retrieval in `git.rs`
- Append signoff to commit message in `main.rs` if enabled
- Add tests for author name and email functions in `git.rs`

Signed-off-by: mingcheng <[email protected]>
- Implement detection of GIT_AUTO_SIGNOFF environment variable
- Enable signoff if environment variable is set to true or 1
- Update logic to combine CLI signoff option with environment variable check

Signed-off-by: mingcheng <[email protected]>
- Add `AIGITCOMMIT_SIGNOFF` environment variable to README
- Mention auto sign-off feature when variable is set to true

Signed-off-by: mingcheng <[email protected]>
- Replace static string formatting with variable interpolation in log messages
- Apply consistent formatting for trace logs across `git.rs` and `openai.rs`

Signed-off-by: mingcheng <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Update `AIGITCOMMIT_SIGNOFF` to `GIT_AUTO_SIGNOFF` in README for consistency
- Reflect the correct variable used in the code for auto signoff feature

Signed-off-by: mingcheng <[email protected]>
- Replace static string formatting with variable interpolation in log messages
- Apply consistent formatting for trace logs across `git.rs` and `openai.rs`

Signed-off-by: mingcheng <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Update `AIGITCOMMIT_SIGNOFF` to `GIT_AUTO_SIGNOFF` in README for consistency
- Reflect the correct variable used in the code for auto signoff feature

Signed-off-by: mingcheng <[email protected]>
- Adjust last modified timestamps in `main.rs` and `openai.rs` for accuracy
- Resolve merge conflict timestamp in `main.rs` to reflect latest update

Signed-off-by: mingcheng <[email protected]>
- Bump version from 1.3.2 to 1.3.3 in Cargo.toml
- Add "grok" to keywords list in package metadata
- Introduce --check flag in CLI to verify API key and model
- Implement check_model function to list and validate available models
- Integrate check logic in main.rs with error handling
- Comment out unused dependencies in Cargo.toml
- Update package categories in Cargo.toml
- Update error message formatting in main.rs to use direct variable interpolation
- Simplify debug and error messages in openai.rs with consistent string formatting
- Remove redundant string concatenation for cleaner code readability

Signed-off-by: mingcheng <[email protected]>
- Add support for signed-off-by line in commit messages with configurable option
- Refactor commit function to accept signoff parameter in git.rs
- Retrieve author name and email from repository config for signoff
- Remove redundant signoff logic from main.rs and centralize in git.rs
- Update commit call in main.rs to pass signoff requirement

Signed-off-by: mingcheng <[email protected]>
Copy link

coderabbitai bot commented Jul 11, 2025

Walkthrough

This update introduces a new --check CLI flag to verify OpenAI API key and model availability, refactors the commit signoff logic to be handled within the Git struct, and enhances model checking functionality. Several new methods are added, and some dependencies are commented out. Minor documentation and formatting improvements are also included.

Changes

File(s) Change Summary
Cargo.toml Version bumped, keywords/categories updated, and some dependencies commented out.
README.md Whitespace and formatting corrections only.
src/cli.rs Added check boolean CLI argument to the Cli struct.
src/git.rs Refactored commit to accept need_signoff parameter; added get_author_email and get_author_name.
src/main.rs Added logic for --check flag; refactored commit signoff handling; minor logging/error tweaks.
src/openai.rs Refactored check to check_model for model availability; improved logging and error reporting.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Main
    participant OpenAI
    participant Git

    User->>CLI: Run command with --check
    CLI->>Main: Parse CLI args
    Main->>OpenAI: check_model(model_name)
    OpenAI->>OpenAI: Fetch available models
    OpenAI-->>Main: Return success/failure
    Main-->>User: Output check result

    User->>CLI: Run commit command
    CLI->>Main: Parse CLI args (with/without signoff)
    Main->>Git: commit(message, need_signoff)
    Git->>Git: Append signoff if needed
    Git-->>Main: Return commit result
    Main-->>User: Output commit message
Loading

Possibly related PRs

Suggested labels

enhancement

Poem

In the warren of code, a new flag hops in—
“--check” sniffs the air, ensures models begin.
Git’s signoff now handled with care,
Author and email—rabbits everywhere!
Dependencies burrowed, whitespace made neat,
This bunny’s update is tidy and sweet.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
Cargo.toml (1)

30-34: Remove unused dependencies from Cargo.toml

Searches for serde, serde_json, strum, and strum_macros in code (including derive macros and fully qualified references) yielded no matches. You can safely delete these commented‐out entries to clean up the manifest. Before merging, please double-check that no tests, examples, or documentation snippets still rely on them.

• Cargo.toml (lines 30–34): remove

#serde = { version = "1.0", features = ["derive"] }
#serde_json = "1.0"
#strum = "0.27.1"
#strum_macros = "0.27.1"
src/openai.rs (1)

91-108: LGTM: Enhanced model validation with improved specificity.

The refactored method now properly validates both API connectivity and model availability, which is much more useful than the previous simple connectivity check. The debug logging of available models is helpful for troubleshooting.

Consider optimizing the model check if the API supports querying a specific model directly instead of fetching the entire list, especially for APIs with many models.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2b5989 and 9ba9e4f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • Cargo.toml (2 hunks)
  • README.md (4 hunks)
  • src/cli.rs (1 hunks)
  • src/git.rs (6 hunks)
  • src/main.rs (5 hunks)
  • src/openai.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Rust project - latest (nightly)
  • GitHub Check: Rust project - latest (stable)
  • GitHub Check: Rust project - latest (beta)
🔇 Additional comments (12)
README.md (1)

22-22: LGTM: Clean formatting improvements.

The whitespace and formatting corrections improve document readability without affecting content.

Also applies to: 52-52, 67-67, 99-99

src/cli.rs (1)

42-48: LGTM: Well-implemented CLI flag.

The new --check flag follows the existing pattern and provides clear functionality for validating OpenAI API configuration.

src/main.rs (2)

88-99: LGTM: Well-implemented model validation check.

The conditional model checking logic is properly implemented with good error handling and logging. The check only runs when the --check flag is enabled, which is appropriate.


166-166: Commit method signature confirmed
The Git::commit method in src/git.rs (line 40) is defined as:

pub fn commit(&self, message: &str, need_signoff: bool) -> Result<(), Box<dyn Error>>

which matches the call in src/main.rs (repository.commit(&result, need_signoff)). No further changes required.

src/git.rs (8)

15-15: LGTM: Import addition is correct.

The addition of Signature to the imports is appropriate for the new signature creation functionality.


43-67: LGTM: Signoff logic implementation is correct.

The signoff logic is well-implemented with proper formatting and conditional application. The signoff format follows the conventional "Signed-off-by" standard, and the logic correctly appends it only when needed.


54-58: Verify the impact of changing signature source.

The change from using HEAD commit's author/committer signatures to using repository configuration values is a significant behavioral change. This ensures commits use the current user's configured identity rather than inheriting from the previous commit.

This change improves consistency by using the repository's configured user identity, but verify that this aligns with the expected behavior for your use case.


69-76: LGTM: Commit creation logic is correct.

The commit creation now properly uses the new signature for both author and committer, which is the standard practice for most Git operations.


88-105: LGTM: Author email retrieval is well-implemented.

The method includes proper error handling, logging, and follows the same pattern as other methods in the struct. The configuration access is correct.


107-123: LGTM: Author name retrieval is well-implemented.

The method mirrors the email retrieval implementation with consistent error handling and logging patterns.


125-125: LGTM: Documentation comments improve code clarity.

The addition of documentation comments for the get_diff and get_logs methods enhances code readability and maintainability.

Also applies to: 173-173


40-40: All commit calls include the new need_signoff parameter

Verified that every usage of your commit(&str, bool) wrapper has been updated:

  • src/main.rs: repository.commit(&result, need_signoff)

No further updates are needed.

@mingcheng mingcheng merged commit 06fb81c into main Jul 11, 2025
17 checks passed
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