Preserve Phabricator diff author on patch updates - #6430
Open
ayoubdiourin7 wants to merge 2 commits into
Open
Conversation
suhaibmujahid
requested changes
Jul 30, 2026
suhaibmujahid
left a comment
Member
There was a problem hiding this comment.
Thank you! Please see my comments.
BTW. you could test it live with the dev instance (i.e., https://phabricator-dev.allizom.org)
Comment on lines
+312
to
+322
| try: | ||
| _preserve_local_commit_authors( | ||
| submission["local_commits"], | ||
| await _diff_commits(previous_diff_id), | ||
| ) | ||
| except Exception: | ||
| log.warning( | ||
| "Could not preserve local commit author from previous diff %s", | ||
| previous_diff_id, | ||
| exc_info=True, | ||
| ) |
Member
There was a problem hiding this comment.
I would avoid nested try-except.
Comment on lines
+130
to
+132
| def _preserve_local_commit_authors( | ||
| local_commits: dict, previous_commits: list[dict] | ||
| ) -> None: |
Member
There was a problem hiding this comment.
I would prefer returning the final values as a dict instead of mutating in place. That would be better for debugging.
Comment on lines
+143
to
+144
| if not author_fields: | ||
| return |
Member
There was a problem hiding this comment.
We should avoid partial info updates. It is either all or nothing.
I do not think that would happen, but since this is a definitive measure, I would log a warning for that.
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
Preserve the original patch author when Hackbot updates an existing Phabricator revision.
Before this change, updating a patch could replace the reconstructed commit author with Hackbot's synthetic author. Now, updates keep the author name and email from the previous diff instead.
Tests
Added a test that covers updating an existing Phabricator revision and verifies the new diff keeps the previous author metadata.
Resolves #6411