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

feat: support init-templatedir #101

Merged
merged 3 commits into from
Nov 22, 2024
Merged

Conversation

XmchxUp
Copy link
Contributor

@XmchxUp XmchxUp commented Nov 22, 2024

Closed #32

src/cli/mod.rs Outdated
#[derive(Debug, Args)]
pub(crate) struct InitTemplateDirArgs {
/// The directory in which to write the hook script.
pub(crate) directory: String,
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pub(crate) directory: String,
pub(crate) directory: PathBuf,

src/cli/mod.rs Outdated
pub(crate) directory: String,

/// Assume cloned repos should have a `pre-commit` config.
#[arg(long, default_value_t = false)]
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
#[arg(long, default_value_t = false)]
#[arg(long)]

src/cli/mod.rs Outdated
Comment on lines 353 to 354
#[arg(long, short = 't', default_value_t = HookType::PreCommit)]
pub(crate) hook_type: HookType,
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
#[arg(long, short = 't', default_value_t = HookType::PreCommit)]
pub(crate) hook_type: HookType,
#[arg(short = 't', long = "hook-type", value_name = "HOOK_TYPE", value_enum)]
pub(crate) hook_types: Vec<HookType>,

@j178
Copy link
Owner

j178 commented Nov 22, 2024

Thanks! Could you add a test case too?

@XmchxUp
Copy link
Contributor Author

XmchxUp commented Nov 22, 2024

Thanks! Could you add a test case too?

Thanks for the review, will add it later.

@XmchxUp
Copy link
Contributor Author

XmchxUp commented Nov 22, 2024

@j178

Should init-templatedir, which is based on install, use a mock library to simulate the behavior of install for testing, or is there another method?

@j178
Copy link
Owner

j178 commented Nov 22, 2024

We don’t need to use mocks in integration tests. You can refer to other tests in the tests folder for guidance.

@j178 j178 merged commit 81455fb into j178:master Nov 22, 2024
15 checks passed
@j178
Copy link
Owner

j178 commented Nov 22, 2024

I made some tweaks and added a test, thanks for your contribution!

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.

Implement pre-commit init-templatedir
2 participants