-
Notifications
You must be signed in to change notification settings - Fork 0
Fix: direct commits still misclassified after #337 (compare mode) #339
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
Open
miroslavpojer
wants to merge
5
commits into
master
Choose a base branch
from
bugfix/improve-direct-commit-detection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+303
−24
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1769018
Fix: improve detection of direct commits and enhance PR association f…
miroslavpojer 0406a4c
Fixed black.
miroslavpojer 4b72284
Fix: enhance direct commit detection by refining PR reference checks …
miroslavpojer e1ec4ec
Fix: enhance PR association logic to deduplicate by PR number and imp…
miroslavpojer 057c922
Fix: add handling for missing PRs in direct commit detection and impr…
miroslavpojer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,10 @@ | |
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| # dev note: cap on how many matched commit SHAs are logged at debug level, to keep verbose logs | ||
| # readable for PRs with many commits. | ||
| _MAX_LOGGED_COMMIT_SHAS = 50 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verbose logging should IMO not be limited. If there is a case, when a 50 commits are mined, it is already not readable. Now you delete the information that could be useful. |
||
|
|
||
|
|
||
| class DefaultRecordFactory(RecordFactory): | ||
| """ | ||
|
|
@@ -92,6 +96,8 @@ def generate(self, data: MinedData) -> dict[str, Record]: | |
| logger.info("Registering direct commits to records...") | ||
| for commit, repo in data.commits.items(): | ||
| if commit.sha not in self.__registered_commits: | ||
| subject = commit.commit.message.splitlines()[0] if commit.commit.message else "" | ||
| logger.debug("Direct commit registered: %s ('%s')", commit.sha, subject) | ||
| self._records[get_id(commit, repo)] = CommitRecord(commit) | ||
|
|
||
| # dev note: now we have all PRs and commits registered to issues or as stand-alone records | ||
|
|
@@ -136,6 +142,16 @@ def _register_pull_and_its_commits_to_issue( | |
| pr_commit_shas.add(pull.merge_commit_sha) | ||
| related_commits = [c for c in data.commits if c.sha in pr_commit_shas] | ||
| self.__registered_commits.update(c.sha for c in related_commits) | ||
| related_commit_shas = [c.sha for c in related_commits] | ||
| logger.debug( | ||
| "PR #%d: %d commit SHA(s) via get_commits() + merge_commit_sha, %d matched against mined commits " | ||
| "(showing up to %d): %s", | ||
| pull.number, | ||
| len(pr_commit_shas), | ||
| len(related_commits), | ||
| _MAX_LOGGED_COMMIT_SHAS, | ||
| related_commit_shas[:_MAX_LOGGED_COMMIT_SHAS], | ||
| ) | ||
|
|
||
| pr_repo = target_repository if target_repository is not None else data.home_repository | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just the beautifying, but crucial for clean code for easy readability and review process. I do not think that code should be place, where you explain a logic in 7 rows. In this PR there is many many generated
dev notes:. If every logic row needs two extra comment ones to explain it. It has a bad naming or is just generated extra stuff, that is not adding any extra value.The point is a lot of added stuff in this PR starts to overwhelm the logic itself.