Skip to content

Preserve Phabricator diff author on patch updates - #6430

Open
ayoubdiourin7 wants to merge 2 commits into
mozilla:masterfrom
ayoubdiourin7:preserve-phab-diff-author
Open

Preserve Phabricator diff author on patch updates#6430
ayoubdiourin7 wants to merge 2 commits into
mozilla:masterfrom
ayoubdiourin7:preserve-phab-diff-author

Conversation

@ayoubdiourin7

Copy link
Copy Markdown
Collaborator

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

@ayoubdiourin7
ayoubdiourin7 requested a review from a team as a code owner July 30, 2026 09:08

@suhaibmujahid suhaibmujahid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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

Successfully merging this pull request may close these issues.

Hackbot should not change the commit author when updating a patch

2 participants