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

[Q] Can't match git diff output #1118

Open
zaufi opened this issue Oct 9, 2024 · 1 comment
Open

[Q] Can't match git diff output #1118

zaufi opened this issue Oct 9, 2024 · 1 comment

Comments

@zaufi
Copy link

zaufi commented Oct 9, 2024

I want to exclude some lines from Git commit message files (see #1117) and have this in my .typos.toml for now:

[default]
extend-ignore-re = [ "(?Rm)^index [0-9a-f]{9}\\.\\.[0-9a-f]{9} [0-9]+$" ]

However, the COMMIT_EDITMSG like this does not match and causes an error:

test: `typos` exclude check
# NOTE: Leave the next line empty to separate the title from the body

# Explain why this change is being made below... (max 120 chars per line)
Playing w/ `extend-ignore-re`

#---[The diff inserted by Git is shown below]-------------------------
…
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git a/tests/010-simple-secret.sh b/tests/010-simple-secret.sh
index 7f5ba185f..0ebe349ef 100644
--- a/tests/010-simple-secret.sh
+++ b/tests/010-simple-secret.sh
…

result in the error:

error: `ba` should be `by`, `be`
  --> path/to/my/repo/.git/worktrees/my-work-tree/COMMIT_EDITMSG:12:10
   |
12 | index 7f5ba185f..0ebe349ef 100644
   |          ^^

It doesn't match even if I reduce regex to the trivial as ^index .*$!

Please help…

@epage
Copy link
Collaborator

epage commented Oct 9, 2024

I put that config in a directory with that block of text in a file and typos succeeded. To test my setup, I removed the config and it failed.

The only thin I can think of is that typos isn't finding the config. If you could run typos with -vvv that might provide some things.

We determine where to load the config based on the file or directory path passed to typos

// Note paths are passed through stdin, `-` is treated like a normal path
let cwd = if path == std::path::Path::new("-") {
if args.file_list.is_some() {
return Err(proc_exit::sysexits::USAGE_ERR.with_message(
"Can't use `-` (stdin) while using `--file_list` provided paths",
));
};
global_cwd.clone()
} else if path.is_file() {
let mut cwd = path
.canonicalize()
.map_err(|err| {
let kind = err.kind();
std::io::Error::new(kind, format!("argument `{}` is not found", path.display()))
})
.with_code(proc_exit::sysexits::USAGE_ERR)?;
cwd.pop();
cwd
} else {
path.canonicalize()
.map_err(|err| {
let kind = err.kind();
std::io::Error::new(kind, format!("argument `{}` is not found", path.display()))
})
.with_code(proc_exit::sysexits::USAGE_ERR)?
};
engine
.init_dir(&cwd)
.with_code(proc_exit::sysexits::CONFIG_ERR)?;

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

No branches or pull requests

2 participants