fix: prevent -m mode crash on single-label domains#941
Open
shbhmexe wants to merge 1 commit intocncf:masterfrom
Open
fix: prevent -m mode crash on single-label domains#941shbhmexe wants to merge 1 commit intocncf:masterfrom
shbhmexe wants to merge 1 commit intocncf:masterfrom
Conversation
…sing The `-m` (map unknowns to email domain) mode could crash when encountering single-label domains (for example: user@localhost). The crash happens because MapToEmployer() references `addr` even when the domain split loop never runs. Fix this by: - Keeping a safe default `addr` when the domain has no dots. - Making GetHackerDomain() generate a meaningful label for single-label domains (so it won’t collapse to just " *"). Also make logparser's date parsing ignore the `CommitDate:` prefix, which can appear in git logs produced with formats like `--pretty=fuller`, preventing ValueError crashes during date range filtering. Signed-off-by: shbhmexe shubhushukla586@gmail.com
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a crash when mapping unknown affiliations to email domains (
-m) for emails whose domain has no dot (e.g.user@localhost). It also hardens date parsing inlogparser.pyto acceptCommitDate:lines.Background / Reasoning
database.MapToEmployer()iterates domain suffixes to find domain mappings, but for single-label domains the suffix loop never runs, leavingaddrundefined. Whenunknown == 1, this leads to an exception instead of producing a domain-based fallback.logparser.getDate()only skipped theDate:token; if the input containsCommitDate:(possible withgit log --pretty=fuller), date parsing can fail.Changes
src/database.pyaddris always defined before domain suffix iteration.GetHackerDomain()treat single-label domains as a real label (e.g.Localhost *) instead of producing" *".src/logparser.pyCommitDate:token when extracting the date string.Impact
gmail.com,example.co.uk).-mmode for single-label domains.CommitDate:lines are present in the git log input.Compatibility / Non-overlap
master(includes recent merges up throughe5595aa1).Verification