-
Notifications
You must be signed in to change notification settings - Fork 1
feature/cli optimize #25
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
- add build.rs script to generate build-time metadata - replace hardcoded constants with built_info module data - update CLI command metadata to use generated package info - fix missing closing bracket in authors field in Cargo.toml - add built crate dependency for build-time information Signed-off-by: mingcheng <[email protected]>
- include OpenSSF scorecard badge for security compliance visibility - position badge alongside existing CI/CD status indicators Signed-off-by: mingcheng <[email protected]>
Reviewer's GuideThis PR refactors core Git operations into a dedicated repository module, introduces a GitMessage abstraction for commit content and signoff logic, wires in build-time metadata via built_info for consistent CLI and OpenAI client configuration, adds a table-printing feature to the CLI, and updates dependencies, tests, and docs to support these changes. Sequence diagram for commit flow with GitMessage and signoff logicsequenceDiagram
participant Main
participant Cli
participant GitMessage
participant Git
participant Author
Main->>Cli: Parse CLI args
Main->>Git: Open repository
Main->>Git: get_author()
Git->>Author: Return author info
Main->>GitMessage: new(&Git, title, content, signoff)
GitMessage->>Git: get_author() (if signoff)
Git->>Author: Return author info
GitMessage-->>Main: Return GitMessage
Main->>Git: commit(&GitMessage)
Git->>Author: get_author()
Git->>Git: commit with signature
Git-->>Main: Return result
Class diagram for refactored Git and new GitMessage typesclassDiagram
class Git {
-repository: Repository
+new(path: &str): Result<Git, Box<dyn Error>>
+commit(message: &GitMessage): Result<(), Box<dyn Error>>
+get_author(): Result<Author, Box<dyn Error>>
+get_diff(): Result<String, Box<dyn Error>>
}
class Author {
+name: String
+email: String
}
class GitMessage {
+title: String
+content: String
+new(repository: &Git, title: &str, content: &str, signoff: bool): Result<GitMessage, Box<dyn Error>>
+is_empty(): bool
+to_string(): String
}
Git --> Author : uses
GitMessage --> Git : uses
Class diagram for updated CLI struct and print_table functionclassDiagram
class Cli {
+print_table: bool
+copy: bool
+save: String
+signoff: bool
+yes: bool
+other args...
}
class built_info {
+PKG_NAME
+PKG_DESCRIPTION
+PKG_VERSION
+PKG_AUTHORS
+PKG_HOMEPAGE
}
class print_table {
+print_table(title: &str, content: &str)
}
Cli --> built_info : uses
print_table --> Cli : uses
Class diagram for OpenAI client refactored to use built_infoclassDiagram
class OpenAI {
+new(...): OpenAI
+create_chat(...): ...
-client
}
class built_info {
+PKG_NAME
+PKG_DESCRIPTION
+PKG_VERSION
+PKG_AUTHORS
+PKG_HOMEPAGE
}
OpenAI --> built_info : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
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.
Pull Request Overview
This PR refactors the CLI tool to optimize code organization and enhance functionality. The changes focus on modularizing the codebase by separating concerns into dedicated modules and integrating build-time metadata.
- Restructured code by introducing new modules (
message.rs,repository.rs) and removing hardcoded constants - Added table-formatted output option and integrated build-time metadata using the
builtcrate - Simplified author handling by consolidating name and email retrieval into a single method
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/repository.rs | Renamed from git.rs, consolidated author methods, refactored commit signature handling |
| src/message.rs | New module for commit message handling with signoff functionality |
| src/openai.rs | Updated imports and integrated build-time metadata for package info |
| src/main.rs | Updated to use new modules and added table formatting support |
| src/cli.rs | Integrated build-time metadata and added table printing functionality |
| src/lib.rs | Updated module exports to reflect new structure |
| build.rs | New build script for generating build-time metadata |
| Cargo.toml | Fixed author email format and added new dependencies |
| README.md | Added OpenSSF Best Practices badge |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
New security issues found
| - name: Log in to the Container registry | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 |
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.
security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
Source: opengrep
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 |
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.
security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
Source: opengrep
|
|
||
| - name: Generate SBOM | ||
| if: github.event_name != 'pull_request' | ||
| uses: anchore/sbom-action@v0 |
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.
security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
Source: opengrep
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable |
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.
security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
Source: opengrep
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable |
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.
security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
Source: opengrep
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Rust toolchain (${{ matrix.toolchain }}) | ||
| uses: dtolnay/rust-toolchain@master |
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.
security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
Source: opengrep
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable |
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.
security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
Source: opengrep
- add tabled dependency for structured output formatting - implement print_table function with rounded styling and text wrapping - add print_table CLI flag with default true value - include comprehensive test case for table display functionality - set table width limit to 120 characters with left alignment Signed-off-by: mingcheng <[email protected]>
- update ghcr.yml to support multi-platform builds and add SBOM generation - improve rust.yml with linting, security audit, and toolchain matrix testing - add caching for faster builds and artifact attestations - expand triggers for feature branches and semantic versioning tags - optimize workflow steps for better error handling and performance Signed-off-by: mingcheng <[email protected]>
beecf99 to
c28908f
Compare
Summary by Sourcery
Refactor Git handling into a repository module, introduce structured commit message management, and optimize CLI and OpenAI integrations using build-time metadata
New Features:
Enhancements:
Build:
Documentation:
Tests: