Skip to content
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

fix: Fixed a naming bug and added emoji_skip in sc.toml #13

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ scopes = ["app", "lib", "docs"]
# By default the skip preview flag is setted to false because we know
# It's a dangerous action.
skip_preview = true

skip_emoji = true

# Customize your commit template as you want
commit_template = ["git", "commit", "-m", "{{message}}", "&&", "git", "push"]
```
Expand Down
1 change: 1 addition & 0 deletions sc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ scopes = [

[git]
skip_preview = false
skip_emojis = false
4 changes: 2 additions & 2 deletions src/config/mod.rs
Copy link
Owner

Choose a reason for hiding this comment

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

Why you renamed skip_preview?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I got this error:

thread 'main' panicked at ./.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.2/src/builder/debug_asserts.rs:112:17:
Command simple-commits: Short option names must be unique for each argument, but '-s' is in use by both 'skip_preview' and 'skip_emojis'
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

where it clarifies that the variables cannot have the same short name. But another solution is to change the file src/config/mod.rs:50 with the following code:

pub struct GitConfig {
    /// Confirm before to run git commit
    #[arg(short = 'p', long = "skip-preview")]
    pub skip_preview: bool,

    /// Confirm before to run git commit
    #[arg(short = 'e', long = "skip-emojis")]
    pub skip_emojis: bool,

    /// Command to run after generate commit message
    #[clap(long, short)]
    #[merge(strategy = swap_option)]
    pub commit_template: Option<Vec<String>>,
}

and in this way maintain the name of the variables.

Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ pub struct SimpleCommitsConfig {
#[derive(Clone, Default, Serialize, Deserialize, Parser, Merge)]
pub struct GitConfig {
/// Confirm before to run git commit
#[clap(long, short)]
#[arg(short = 'p', long = "skip-preview")]
pub skip_preview: bool,

/// Confirm before to run git commit
#[clap(long, short)]
#[arg(short = 'e', long = "skip-emojis")]
pub skip_emojis: bool,

/// Command to run after generate commit message
Expand Down
Loading