-
Notifications
You must be signed in to change notification settings - Fork 829
Fix gerrit upload with mixed explicit and implicit change-ids #8219
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
HoelzelJon
wants to merge
3
commits into
jj-vcs:main
Choose a base branch
from
HoelzelJon:push-zppnpxxynnpz
base: main
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.
+232
−19
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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 |
|---|---|---|
|
|
@@ -89,7 +89,7 @@ fn test_gerrit_upload_dryrun() { | |
| } | ||
|
|
||
| #[test] | ||
| fn test_gerrit_upload_local() { | ||
| fn test_gerrit_upload_local_implicit_change_ids() { | ||
| let test_env = TestEnvironment::default(); | ||
| test_env | ||
| .run_jj_in(".", ["git", "init", "--colocate", "remote"]) | ||
|
|
@@ -104,7 +104,7 @@ fn test_gerrit_upload_local() { | |
| create_commit(&local_dir, "b", &["a@origin"]); | ||
| create_commit(&local_dir, "c", &["b"]); | ||
|
|
||
| // The output should only mentioned commit IDs from the log output above (no | ||
| // The output should only mention commit IDs from the log output above (no | ||
| // temporary commits) | ||
| let output = local_dir.run_jj(["log", "-r", "all()"]); | ||
| insta::assert_snapshot!(output, @r###" | ||
|
|
@@ -170,3 +170,212 @@ fn test_gerrit_upload_local() { | |
| [EOF] | ||
| "###); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_gerrit_upload_local_explicit_change_ids() { | ||
| let test_env = TestEnvironment::default(); | ||
| test_env | ||
| .run_jj_in(".", ["git", "init", "--colocate", "remote"]) | ||
| .success(); | ||
| let remote_dir = test_env.work_dir("remote"); | ||
| create_commit(&remote_dir, "a", &[]); | ||
|
|
||
| test_env | ||
| .run_jj_in(".", ["git", "clone", "remote", "local"]) | ||
| .success(); | ||
| let local_dir = test_env.work_dir("local"); | ||
| create_commit(&local_dir, "b", &["a@origin"]); | ||
|
|
||
| // Add an explicit Change-Id footer to b | ||
| let output = local_dir.run_jj([ | ||
| "describe", | ||
| "b", | ||
| "-m", | ||
| "b\n\nChange-Id: Id39b308212fe7e0b746d16c13355f3a90712d7f9\n", | ||
| ]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| ------- stderr ------- | ||
| Working copy (@) now at: mzvwutvl 887a7016 b | b | ||
| Parent commit (@-) : rlvkpnrz 7d980be7 a@origin | a | ||
| [EOF] | ||
| "###); | ||
|
|
||
| create_commit(&local_dir, "c", &["b"]); | ||
|
|
||
| // Add an explicit Change-Id footer to c | ||
| let output = local_dir.run_jj([ | ||
| "describe", | ||
| "c", | ||
| "-m", | ||
| "c\n\nChange-Id: Idfac1e8c149efddf5c7a286f787b43886a6a6964\n", | ||
| ]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| ------- stderr ------- | ||
| Working copy (@) now at: vruxwmqv 27c0bdd0 c | c | ||
| Parent commit (@-) : mzvwutvl 887a7016 b | b | ||
| [EOF] | ||
| "###); | ||
|
|
||
| // The output should only mention commit IDs from the log output above (no | ||
| // temporary commits) | ||
| let output = local_dir.run_jj(["log", "-r", "all()"]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| @ vruxwmqv test.user@example.com 2001-02-03 08:05:16 c 27c0bdd0 | ||
| │ c | ||
| ○ mzvwutvl test.user@example.com 2001-02-03 08:05:13 b 887a7016 | ||
| │ b | ||
| ◆ rlvkpnrz test.user@example.com 2001-02-03 08:05:09 a@origin 7d980be7 | ||
| │ a | ||
| ◆ zzzzzzzz root() 00000000 | ||
| [EOF] | ||
| "###); | ||
|
|
||
| let output = local_dir.run_jj(["gerrit", "upload", "-r", "c", "--remote-branch=main"]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| ------- stderr ------- | ||
|
|
||
| Found 1 heads to push to Gerrit (remote 'origin'), target branch 'main' | ||
|
|
||
| Pushing vruxwmqv 27c0bdd0 c | c | ||
| [EOF] | ||
| "###); | ||
|
|
||
| // The output should be unchanged because we only add Change-Id trailers | ||
| // transiently | ||
| let output = local_dir.run_jj(["log", "-r", "all()"]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| @ vruxwmqv test.user@example.com 2001-02-03 08:05:16 c 27c0bdd0 | ||
| │ c | ||
| ○ mzvwutvl test.user@example.com 2001-02-03 08:05:13 b 887a7016 | ||
| │ b | ||
| ◆ rlvkpnrz test.user@example.com 2001-02-03 08:05:09 a@origin 7d980be7 | ||
| │ a | ||
| ◆ zzzzzzzz root() 00000000 | ||
| [EOF] | ||
| "###); | ||
|
|
||
| // There's no particular reason to run this with jj util exec, it's just that | ||
| // the infra makes it easier to run this way. | ||
| let output = remote_dir.run_jj(["util", "exec", "--", "git", "log", "refs/for/main"]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| commit ab2262125f7e2db50ec2646e949beba54219d345 | ||
| Author: Test User <test.user@example.com> | ||
| Date: Sat Feb 3 04:05:14 2001 +0700 | ||
|
|
||
| c | ||
|
|
||
| Change-Id: Idfac1e8c149efddf5c7a286f787b43886a6a6964 | ||
|
|
||
| commit 22bbfff17a982c9b8f18cc8cbcd59ec833827c41 | ||
|
Contributor
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. Oh, so this caught the bug. Maybe we need to copy the original |
||
| Author: Test User <test.user@example.com> | ||
| Date: Sat Feb 3 04:05:11 2001 +0700 | ||
|
|
||
| b | ||
|
|
||
| Change-Id: Id39b308212fe7e0b746d16c13355f3a90712d7f9 | ||
|
|
||
| commit 7d980be7a1d499e4d316ab4c01242885032f7eaf | ||
| Author: Test User <test.user@example.com> | ||
| Date: Sat Feb 3 04:05:08 2001 +0700 | ||
|
|
||
| a | ||
| [EOF] | ||
| "###); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_gerrit_upload_local_mixed_change_ids() { | ||
| let test_env = TestEnvironment::default(); | ||
| test_env | ||
| .run_jj_in(".", ["git", "init", "--colocate", "remote"]) | ||
| .success(); | ||
| let remote_dir = test_env.work_dir("remote"); | ||
| create_commit(&remote_dir, "a", &[]); | ||
|
|
||
| test_env | ||
| .run_jj_in(".", ["git", "clone", "remote", "local"]) | ||
| .success(); | ||
| let local_dir = test_env.work_dir("local"); | ||
| create_commit(&local_dir, "b", &["a@origin"]); | ||
| create_commit(&local_dir, "c", &["b"]); | ||
|
|
||
| // Add an explicit Change-Id footer to c but not b | ||
| let output = local_dir.run_jj([ | ||
| "describe", | ||
| "c", | ||
| "-m", | ||
| "c\n\nChange-Id: Id39b308212fe7e0b746d16c13355f3a90712d7f9\n", | ||
| ]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| ------- stderr ------- | ||
| Working copy (@) now at: yqosqzyt 8d46d915 c | c | ||
| Parent commit (@-) : mzvwutvl 3bcb28c4 b | b | ||
| [EOF] | ||
| "###); | ||
|
|
||
| // The output should only mention commit IDs from the log output above (no | ||
| // temporary commits) | ||
| let output = local_dir.run_jj(["log", "-r", "all()"]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| @ yqosqzyt test.user@example.com 2001-02-03 08:05:15 c 8d46d915 | ||
| │ c | ||
| ○ mzvwutvl test.user@example.com 2001-02-03 08:05:12 b 3bcb28c4 | ||
| │ b | ||
| ◆ rlvkpnrz test.user@example.com 2001-02-03 08:05:09 a@origin 7d980be7 | ||
| │ a | ||
| ◆ zzzzzzzz root() 00000000 | ||
| [EOF] | ||
| "###); | ||
|
|
||
| let output = local_dir.run_jj(["gerrit", "upload", "-r", "c", "--remote-branch=main"]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| ------- stderr ------- | ||
|
|
||
| Found 1 heads to push to Gerrit (remote 'origin'), target branch 'main' | ||
|
|
||
| Pushing yqosqzyt 8d46d915 c | c | ||
| [EOF] | ||
| "###); | ||
|
|
||
| // The output should be unchanged because we only add Change-Id trailers | ||
| // transiently | ||
| let output = local_dir.run_jj(["log", "-r", "all()"]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| @ yqosqzyt test.user@example.com 2001-02-03 08:05:15 c 8d46d915 | ||
| │ c | ||
| ○ mzvwutvl test.user@example.com 2001-02-03 08:05:12 b 3bcb28c4 | ||
| │ b | ||
| ◆ rlvkpnrz test.user@example.com 2001-02-03 08:05:09 a@origin 7d980be7 | ||
| │ a | ||
| ◆ zzzzzzzz root() 00000000 | ||
| [EOF] | ||
| "###); | ||
|
|
||
| // There's no particular reason to run this with jj util exec, it's just that | ||
| // the infra makes it easier to run this way. | ||
| let output = remote_dir.run_jj(["util", "exec", "--", "git", "log", "refs/for/main"]); | ||
| insta::assert_snapshot!(output, @r###" | ||
| commit 015df2b1d38bdc71ae7ef24c2889100e39d34ef8 | ||
| Author: Test User <test.user@example.com> | ||
| Date: Sat Feb 3 04:05:13 2001 +0700 | ||
|
|
||
| c | ||
|
|
||
| Change-Id: Id39b308212fe7e0b746d16c13355f3a90712d7f9 | ||
|
|
||
| commit 81b723522d1c1a583a045eab5bfb323e45e6198d | ||
| Author: Test User <test.user@example.com> | ||
| Date: Sat Feb 3 04:05:11 2001 +0700 | ||
|
|
||
| b | ||
|
|
||
| Change-Id: Id043564ef93650b06a70f92f9d91912b6a6a6964 | ||
|
|
||
| commit 7d980be7a1d499e4d316ab4c01242885032f7eaf | ||
| Author: Test User <test.user@example.com> | ||
| Date: Sat Feb 3 04:05:08 2001 +0700 | ||
|
|
||
| a | ||
| [EOF] | ||
| "###); | ||
| } | ||
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
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.
Can you add a test that will upload series that contains all preset
Change-Idtrailers? 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.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.
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