-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for including specific files in git diff
This commit adds support for including specific files in the `git diff` command. It introduces a new `include` option in the `Cmd` struct, which allows users to specify a list of files to include in the diff. The `include` option is then passed to the `git::diff` function, which appends the included files to the `git diff` command. The motivation behind this change is to provide more flexibility in generating the diff. Users can now choose to include only specific files in the diff, rather than seeing the changes for all files in the repository. This can be useful in scenarios where users are only interested in reviewing changes in a subset of files. The `include` option accepts a list of `PathBuf` objects, representing the paths of the files to include in the diff. These paths are then converted to strings and passed as arguments to the `git diff` command. This commit also includes a new `pre_commit` module in the `external` module, which contains a `run` function. This function executes the `pre-commit` command with the `run` argument. If the command succeeds, the function returns `Ok(())`. Otherwise, an error is returned. The `pre-commit` command is a popular tool for managing and enforcing pre-commit hooks in Git repositories. By running the `pre-commit` command before committing changes, users can ensure that their code adheres to certain standards and guidelines. This change is part of an ongoing effort to improve the commit workflow and provide a more streamlined experience for users.
- Loading branch information
Showing
6 changed files
with
107 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod bitwarden; | ||
pub mod git; | ||
pub mod pre_commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::io::IsTerminal; | ||
use std::process::Command; | ||
|
||
use crate::common::log::LogResult; | ||
use anyhow::Result; | ||
|
||
pub fn run() -> Result<()> { | ||
let mut cmd = Command::new("pre-commit"); | ||
cmd.arg("run"); | ||
if std::io::stdout().is_terminal() { | ||
cmd.arg("--color=always"); | ||
} | ||
let status = cmd.status()?; | ||
crate::ensure!(status.success()); | ||
Ok(()) | ||
} |