-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Idea: --skip-errors
option for skipping commits that rase an exception in the convert function
#34
Comments
I'd like to get rid of this code, this feature could help there: git-history/git_history/cli.py Lines 264 to 266 in 8857ce1
|
Options for the name:
The related existing options (that this should be consistent with) are:
Maybe add a separate small section to the README about ways of skipping bad commits too. |
--skip-error-commits
option--skip-errors
option for skipping commits that rase an exception in the convert function
Here's a prototype diff for this feature (though it should also capture exceptions raised by diff --git a/git_history/cli.py b/git_history/cli.py
index b119004..08a2f04 100644
--- a/git_history/cli.py
+++ b/git_history/cli.py
@@ -74,6 +74,9 @@ def cli():
@click.option(
"skip_hashes", "--skip", multiple=True, help="Skip specific commit hashes"
)
+@click.option(
+ "--skip-errors", is_flag=True, help="If a version has a parse error, skip it"
+)
@click.option(
"--full-versions",
is_flag=True,
@@ -134,6 +137,7 @@ def file(
start_at,
start_after,
skip_hashes,
+ skip_errors,
full_versions,
csv_,
dialect,
@@ -255,7 +259,13 @@ def file(
).keys()
)
# Validate all items in the commit have ID columns - raises ClickException if not
- validate_items_have_id_columns(items, ids, git_hash)
+ try:
+ validate_items_have_id_columns(items, ids, git_hash)
+ except click.ClickException:
+ if skip_errors:
+ continue
+ else:
+ raise
# Use this to detect IDs that are duplicated in the same commit
item_ids_seen_in_this_commit = set() |
It would be good if this was caught and the commit hash was shown in the error message. |
I could add an option that skips any commits that don't parse correctly with the provided conversion function. This would be the quickest possible way of parsing a history where all but a few commits work.
The text was updated successfully, but these errors were encountered: