Skip to content

Conversation

@HoelzelJon
Copy link

This should address the issue described in #8006

This is my first contribution; please let me know if there's anything I've overlooked here. Thanks!

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/) -- N/A
  • I have updated the config schema (cli/src/config-schema.json) -- N/A
  • I have added/updated tests to cover my changes

@HoelzelJon HoelzelJon requested a review from a team as a code owner December 4, 2025 20:20
@google-cla
Copy link

google-cla bot commented Dec 4, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@HoelzelJon HoelzelJon force-pushed the push-zppnpxxynnpz branch 2 times, most recently from e677fe6 to f085f39 Compare December 4, 2025 20:34
@martinvonz
Copy link
Member

Can you review this one, @thoughtpolice?

@martinvonz
Copy link
Member

And maybe @matts1 also wants to take a look

"},
)
.unwrap();
let output = local_dir.run_jj(["describe", "c"]);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can use describe c -m instead of the edit script.

Copy link
Author

Choose a reason for hiding this comment

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

oh, I can! For some reason, I had thought that using -m wouldn't work for a multiline description string. thanks!

if trailers.is_empty() { "\n\n" } else { "\n" },
gerrit_change_id
)
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test that will upload series that contains all preset Change-Id trailers? In that case, the temporarily rewritten commits should be identical to the original ones. That would probably work because we reset committer timestamps, but it seems we don't have tests.

Copy link
Author

Choose a reason for hiding this comment

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

I've added a pre-commit that splits out two separate tests for all-preset and all-implied Change-Ids, and then in the main commit, I've added a new test case for the relevant mixed case

@HoelzelJon
Copy link
Author

Also, let me know if it's reasonable that I've added myself to the paid_contributors.md. I've implemented this during work hours and with approval from my employer, but since this is a one-off sidequest of mine, I'm not sure if it's best to characterize it as a "compan[y] paying for contributions to Jujutsu". I'm going to leave the addition unless told otherwise, but I just want to make clear what the situation is

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

The following commits do not follow our format for subject lines:

Commits should have a subject line following the format <topic>: <description>. Please review the commit guidelines for more information.

The 'gerrit upload' command has logic to handle commits with the
"Change-Id" explicitly set within the commit message, and commits
without the Change-Id explicitly set. This commit adds a test for the
behavior when all commits have the Change-Id explicitly set.

Also fix typo in existing test comment
@github-actions github-actions bot dismissed their stale review December 5, 2025 17:10

All commits are now correctly formatted. Thank you for your contribution!

The 'gerrit upload' cli command is meant to support uploading commits
that have an explicit "Change-Id: ..." footer, and those that don't. In
the latter case, a temporary copy of the commit being uploaded will be
created, with the Change-Id set based on the jj change id.

Prior to this commit, there was a bug in this implementation when a
chain of commits contained some with Change-Id footers and some without.

Say we have commits a->b->c, where b has no Change-Id footer but c does
(this case is what's now tested in the test_gerrit_upload_local case).

The old logic would:
- create a new version of b (let's call it b*), with a CommitId footer,
  and populate the 'old_to_new' map with 'b -> b*'
- not create a new version of c, and populate the 'old_to_new' map with
  'c -> c'
- push the 'new' version of c, which is c itself. However, c has b as a
  parent, not b*, so this fails to send to gerrit because b has no
  Commit-Id footer!

After this commit, we create a new temporary commit for each commit
being uploaded, so that we can properly point each of them to their
expected parents.

Note that if all commits being pushed already have Commit-Id footers,
then it is theoretically not necessary to create any temporary commits.
However, this would require additional bespoke logic for this case, and
it's not clear that this would lead to any significant benefit
(presumably, the gerrit push itself will be the main performance
bottleneck when running this command). This is covered by the
'test_gerrit_upload_local_explicit_change_ids' case, where we see the
testcase is now uploading different commit hashes to gerrit.
The prior commit in this PR was done of my own accord but during work
hours, so adding myself to this list.
Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

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

Also, let me know if it's reasonable that I've added myself to the paid_contributors.md.

I think that's good because the purpose of this list is to spot conflicts of interest.

BTW, I didn't notice CLA issue isn't resolved yet. Some of the contributors wouldn't be allowed to review this PR.

Change-Id: Idfac1e8c149efddf5c7a286f787b43886a6a6964
commit 887a7016ec03a904835da1059543d8cc34b6ba76
commit 22bbfff17a982c9b8f18cc8cbcd59ec833827c41
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, so this caught the bug. Maybe we need to copy the original predecessors to rewrite to identical commit?

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.

3 participants