| 1 |
// Copyright 2022 The Jujutsu Authors |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
use crate::common::CommandOutput; |
| 16 |
use crate::common::TestEnvironment; |
| 17 |
use crate::common::TestWorkDir; |
| 18 |
|
| 19 |
#[test] |
| 20 |
fn test_metaedit() { |
| 21 |
let mut test_env = TestEnvironment::default(); |
| 22 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 23 |
let work_dir = test_env.work_dir("repo"); |
| 24 |
|
| 25 |
work_dir |
| 26 |
.run_jj(["bookmark", "create", "-r@", "a"]) |
| 27 |
.success(); |
| 28 |
work_dir.write_file("file1", "a\n"); |
| 29 |
work_dir.run_jj(["new"]).success(); |
| 30 |
work_dir |
| 31 |
.run_jj(["bookmark", "create", "-r@", "b"]) |
| 32 |
.success(); |
| 33 |
work_dir.write_file("file1", "b\n"); |
| 34 |
work_dir.run_jj(["new"]).success(); |
| 35 |
work_dir |
| 36 |
.run_jj(["bookmark", "create", "-r@", "c"]) |
| 37 |
.success(); |
| 38 |
work_dir.write_file("file1", "c\n"); |
| 39 |
// Test the setup |
| 40 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 41 |
@ Commit ID: 22be6c4e01da7039a1a8c3adb91b8841252bb354 |
| 42 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 43 |
│ Bookmarks: c |
| 44 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 45 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 46 |
│ |
| 47 |
│ (no description set) |
| 48 |
│ |
| 49 |
○ Commit ID: 75591b1896b4990e7695701fd7cdbb32dba3ff50 |
| 50 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 51 |
│ Bookmarks: b |
| 52 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 53 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 54 |
│ |
| 55 |
│ (no description set) |
| 56 |
│ |
| 57 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 58 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 59 |
│ Bookmarks: a |
| 60 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 61 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 62 |
│ |
| 63 |
│ (no description set) |
| 64 |
│ |
| 65 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 66 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 67 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 68 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 69 |
|
| 70 |
(no description set) |
| 71 |
|
| 72 |
[EOF] |
| 73 |
"); |
| 74 |
let setup_opid = work_dir.current_operation_id(); |
| 75 |
|
| 76 |
// Without arguments, the commits are not rewritten. |
| 77 |
// TODO: Require an argument? |
| 78 |
let output = work_dir.run_jj(["metaedit", "kkmpptxzrspx"]); |
| 79 |
insta::assert_snapshot!(output, @" |
| 80 |
------- stderr ------- |
| 81 |
Nothing changed. |
| 82 |
[EOF] |
| 83 |
"); |
| 84 |
|
| 85 |
// When resetting the author has no effect, the commits are not rewritten. |
| 86 |
let output = work_dir.run_jj([ |
| 87 |
"metaedit", |
| 88 |
"--config=user.name=Test User", |
| 89 |
"--update-author", |
| 90 |
"kkmpptxzrspx", |
| 91 |
]); |
| 92 |
insta::assert_snapshot!(output, @" |
| 93 |
------- stderr ------- |
| 94 |
Nothing changed. |
| 95 |
[EOF] |
| 96 |
"); |
| 97 |
|
| 98 |
// Update author, ensure the commit can be specified with -r too |
| 99 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 100 |
work_dir |
| 101 |
.run_jj([ |
| 102 |
"metaedit", |
| 103 |
"--config=user.name=Ove Ridder", |
| 104 |
"[email protected]", |
| 105 |
"--update-author", |
| 106 |
"-r", |
| 107 |
"kkmpptxzrspx", |
| 108 |
]) |
| 109 |
.success(); |
| 110 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 111 |
@ Commit ID: 6f31b2555777ac2261dd17008b6fdc42619ebe1f |
| 112 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 113 |
│ Bookmarks: c |
| 114 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 115 |
│ Committer: Ove Ridder <[email protected]> (2001-02-03 04:05:17.000 +07:00) |
| 116 |
│ |
| 117 |
│ (no description set) |
| 118 |
│ |
| 119 |
○ Commit ID: 590c8b6945666401d01269190c1b82cd3311a0cd |
| 120 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 121 |
│ Bookmarks: b |
| 122 |
│ Author : Ove Ridder <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 123 |
│ Committer: Ove Ridder <[email protected]> (2001-02-03 04:05:17.000 +07:00) |
| 124 |
│ |
| 125 |
│ (no description set) |
| 126 |
│ |
| 127 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 128 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 129 |
│ Bookmarks: a |
| 130 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 131 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 132 |
│ |
| 133 |
│ (no description set) |
| 134 |
│ |
| 135 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 136 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 137 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 138 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 139 |
|
| 140 |
(no description set) |
| 141 |
|
| 142 |
[EOF] |
| 143 |
"); |
| 144 |
|
| 145 |
// Update author timestamp |
| 146 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 147 |
work_dir |
| 148 |
.run_jj(["metaedit", "--update-author-timestamp", "kkmpptxzrspx"]) |
| 149 |
.success(); |
| 150 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 151 |
@ Commit ID: b23f6a3f160d122f8d8dacd8d2acff2d29d5ba84 |
| 152 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 153 |
│ Bookmarks: c |
| 154 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 155 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:20.000 +07:00) |
| 156 |
│ |
| 157 |
│ (no description set) |
| 158 |
│ |
| 159 |
○ Commit ID: f121a0fb72e1790e4116b2e3b6989c795ac7f74b |
| 160 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 161 |
│ Bookmarks: b |
| 162 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:20.000 +07:00) |
| 163 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:20.000 +07:00) |
| 164 |
│ |
| 165 |
│ (no description set) |
| 166 |
│ |
| 167 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 168 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 169 |
│ Bookmarks: a |
| 170 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 171 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 172 |
│ |
| 173 |
│ (no description set) |
| 174 |
│ |
| 175 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 176 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 177 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 178 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 179 |
|
| 180 |
(no description set) |
| 181 |
|
| 182 |
[EOF] |
| 183 |
"); |
| 184 |
|
| 185 |
// Set author |
| 186 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 187 |
work_dir |
| 188 |
.run_jj([ |
| 189 |
"metaedit", |
| 190 |
"--author", |
| 191 |
"Alice <[email protected]>", |
| 192 |
"kkmpptxzrspx", |
| 193 |
]) |
| 194 |
.success(); |
| 195 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 196 |
@ Commit ID: 74007c679b9e4f13d1e3d553ef8397586b033421 |
| 197 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 198 |
│ Bookmarks: c |
| 199 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 200 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:23.000 +07:00) |
| 201 |
│ |
| 202 |
│ (no description set) |
| 203 |
│ |
| 204 |
○ Commit ID: d070c8adbc590813c81e296591d6b2cac8f3bb41 |
| 205 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 206 |
│ Bookmarks: b |
| 207 |
│ Author : Alice <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 208 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:23.000 +07:00) |
| 209 |
│ |
| 210 |
│ (no description set) |
| 211 |
│ |
| 212 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 213 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 214 |
│ Bookmarks: a |
| 215 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 216 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 217 |
│ |
| 218 |
│ (no description set) |
| 219 |
│ |
| 220 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 221 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 222 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 223 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 224 |
|
| 225 |
(no description set) |
| 226 |
|
| 227 |
[EOF] |
| 228 |
"); |
| 229 |
|
| 230 |
// new author date |
| 231 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 232 |
work_dir |
| 233 |
.run_jj([ |
| 234 |
"metaedit", |
| 235 |
"--author-timestamp", |
| 236 |
"1995-12-19T16:39:57-08:00", |
| 237 |
]) |
| 238 |
.success(); |
| 239 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 240 |
@ Commit ID: a527219f85839d58ddb6115fbc4f0f8bc6649266 |
| 241 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 242 |
│ Bookmarks: c |
| 243 |
│ Author : Test User <[email protected]> (1995-12-19 16:39:57.000 -08:00) |
| 244 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:26.000 +07:00) |
| 245 |
│ |
| 246 |
│ (no description set) |
| 247 |
│ |
| 248 |
○ Commit ID: 75591b1896b4990e7695701fd7cdbb32dba3ff50 |
| 249 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 250 |
│ Bookmarks: b |
| 251 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 252 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 253 |
│ |
| 254 |
│ (no description set) |
| 255 |
│ |
| 256 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 257 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 258 |
│ Bookmarks: a |
| 259 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 260 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 261 |
│ |
| 262 |
│ (no description set) |
| 263 |
│ |
| 264 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 265 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 266 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 267 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 268 |
|
| 269 |
(no description set) |
| 270 |
|
| 271 |
[EOF] |
| 272 |
"); |
| 273 |
|
| 274 |
// invalid date gives an error |
| 275 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 276 |
let output = work_dir.run_jj(["metaedit", "--author-timestamp", "aaaaaa"]); |
| 277 |
insta::assert_snapshot!(output, @" |
| 278 |
------- stderr ------- |
| 279 |
error: invalid value 'aaaaaa' for '--author-timestamp <AUTHOR_TIMESTAMP>': premature end of input |
| 280 |
|
| 281 |
For more information, try '--help'. |
| 282 |
[EOF] |
| 283 |
[exit status: 2] |
| 284 |
"); |
| 285 |
|
| 286 |
// Update committer timestamp |
| 287 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 288 |
work_dir |
| 289 |
.run_jj(["metaedit", "--force-rewrite", "kkmpptxzrspx"]) |
| 290 |
.success(); |
| 291 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 292 |
@ Commit ID: 6c0aa6574ef6450eaf7eae1391cc6c769c53a50c |
| 293 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 294 |
│ Bookmarks: c |
| 295 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 296 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:31.000 +07:00) |
| 297 |
│ |
| 298 |
│ (no description set) |
| 299 |
│ |
| 300 |
○ Commit ID: 0a570dfbbaf794cd15bbdbf28f94785405ef5b3b |
| 301 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 302 |
│ Bookmarks: b |
| 303 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 304 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:31.000 +07:00) |
| 305 |
│ |
| 306 |
│ (no description set) |
| 307 |
│ |
| 308 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 309 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 310 |
│ Bookmarks: a |
| 311 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 312 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 313 |
│ |
| 314 |
│ (no description set) |
| 315 |
│ |
| 316 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 317 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 318 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 319 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 320 |
|
| 321 |
(no description set) |
| 322 |
|
| 323 |
[EOF] |
| 324 |
"); |
| 325 |
|
| 326 |
// change test author config for changing committer |
| 327 |
test_env.add_env_var("JJ_USER", "Test Committer"); |
| 328 |
test_env.add_env_var("JJ_EMAIL", "[email protected]"); |
| 329 |
let work_dir = test_env.work_dir("repo"); |
| 330 |
|
| 331 |
// update existing commit with restored test author config |
| 332 |
insta::assert_snapshot!(work_dir.run_jj(["metaedit", "--force-rewrite"]), @" |
| 333 |
------- stderr ------- |
| 334 |
Modified 1 commits: |
| 335 |
mzvwutvl 75259df4 c | (no description set) |
| 336 |
Working copy (@) now at: mzvwutvl 75259df4 c | (no description set) |
| 337 |
Parent commit (@-) : kkmpptxz 0a570dfb b | (no description set) |
| 338 |
[EOF] |
| 339 |
"); |
| 340 |
insta::assert_snapshot!(work_dir.run_jj(["show"]), @" |
| 341 |
Commit ID: 75259df433eebc10b3ad78a9814d6647b764ce28 |
| 342 |
Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 343 |
Bookmarks: c |
| 344 |
Author : Test User <[email protected]> (2001-02-03 08:05:13) |
| 345 |
Committer: Test Committer <[email protected]> (2001-02-03 08:05:33) |
| 346 |
|
| 347 |
(no description set) |
| 348 |
|
| 349 |
Modified regular file file1: |
| 350 |
1 : b |
| 351 |
1: c |
| 352 |
[EOF] |
| 353 |
"); |
| 354 |
|
| 355 |
// When resetting the description has no effect, the commits are not rewritten. |
| 356 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 357 |
let output = work_dir.run_jj(["metaedit", "--message", "", "kkmpptxzrspx"]); |
| 358 |
insta::assert_snapshot!(output, @" |
| 359 |
------- stderr ------- |
| 360 |
Nothing changed. |
| 361 |
[EOF] |
| 362 |
"); |
| 363 |
|
| 364 |
// Update description |
| 365 |
work_dir |
| 366 |
.run_jj(["metaedit", "--message", "d\ne\nf"]) |
| 367 |
.success(); |
| 368 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 369 |
@ Commit ID: 502004368461738c866bc690ce08f7c219a4de10 |
| 370 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 371 |
│ Bookmarks: c |
| 372 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 373 |
│ Committer: Test Committer <[email protected]> (2001-02-03 04:05:37.000 +07:00) |
| 374 |
│ |
| 375 |
│ d |
| 376 |
│ e |
| 377 |
│ f |
| 378 |
│ |
| 379 |
○ Commit ID: 75591b1896b4990e7695701fd7cdbb32dba3ff50 |
| 380 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 381 |
│ Bookmarks: b |
| 382 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 383 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 384 |
│ |
| 385 |
│ (no description set) |
| 386 |
│ |
| 387 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 388 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 389 |
│ Bookmarks: a |
| 390 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 391 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 392 |
│ |
| 393 |
│ (no description set) |
| 394 |
│ |
| 395 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 396 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 397 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 398 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 399 |
|
| 400 |
(no description set) |
| 401 |
|
| 402 |
[EOF] |
| 403 |
"); |
| 404 |
|
| 405 |
// Set empty description |
| 406 |
work_dir.run_jj(["metaedit", "--message", ""]).success(); |
| 407 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 408 |
@ Commit ID: a44f230f9af7eed606af7713774feba5e39f36f7 |
| 409 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 410 |
│ Bookmarks: c |
| 411 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 412 |
│ Committer: Test Committer <[email protected]> (2001-02-03 04:05:39.000 +07:00) |
| 413 |
│ |
| 414 |
│ (no description set) |
| 415 |
│ |
| 416 |
○ Commit ID: 75591b1896b4990e7695701fd7cdbb32dba3ff50 |
| 417 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 418 |
│ Bookmarks: b |
| 419 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 420 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 421 |
│ |
| 422 |
│ (no description set) |
| 423 |
│ |
| 424 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 425 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 426 |
│ Bookmarks: a |
| 427 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 428 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 429 |
│ |
| 430 |
│ (no description set) |
| 431 |
│ |
| 432 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 433 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 434 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 435 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 436 |
|
| 437 |
(no description set) |
| 438 |
|
| 439 |
[EOF] |
| 440 |
"); |
| 441 |
} |
| 442 |
|
| 443 |
#[test] |
| 444 |
fn test_metaedit_no_matching_revisions() { |
| 445 |
let test_env = TestEnvironment::default(); |
| 446 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 447 |
let work_dir = test_env.work_dir("repo"); |
| 448 |
let output = work_dir.run_jj(["metaedit", "--update-change-id", "none()"]); |
| 449 |
insta::assert_snapshot!(output, @" |
| 450 |
------- stderr ------- |
| 451 |
No revisions to modify. |
| 452 |
[EOF] |
| 453 |
"); |
| 454 |
} |
| 455 |
|
| 456 |
#[test] |
| 457 |
fn test_metaedit_multiple_revisions() { |
| 458 |
let test_env = TestEnvironment::default(); |
| 459 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 460 |
let work_dir = test_env.work_dir("repo"); |
| 461 |
|
| 462 |
work_dir |
| 463 |
.run_jj(["bookmark", "create", "-r@", "a"]) |
| 464 |
.success(); |
| 465 |
work_dir.write_file("file1", "a\n"); |
| 466 |
work_dir.run_jj(["new"]).success(); |
| 467 |
work_dir |
| 468 |
.run_jj(["bookmark", "create", "-r@", "b"]) |
| 469 |
.success(); |
| 470 |
work_dir.write_file("file1", "b\n"); |
| 471 |
work_dir.run_jj(["new"]).success(); |
| 472 |
work_dir |
| 473 |
.run_jj(["bookmark", "create", "-r@", "c"]) |
| 474 |
.success(); |
| 475 |
work_dir.write_file("file1", "c\n"); |
| 476 |
// Test the setup |
| 477 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 478 |
@ Commit ID: 22be6c4e01da7039a1a8c3adb91b8841252bb354 |
| 479 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 480 |
│ Bookmarks: c |
| 481 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 482 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 483 |
│ |
| 484 |
│ (no description set) |
| 485 |
│ |
| 486 |
○ Commit ID: 75591b1896b4990e7695701fd7cdbb32dba3ff50 |
| 487 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 488 |
│ Bookmarks: b |
| 489 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 490 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 491 |
│ |
| 492 |
│ (no description set) |
| 493 |
│ |
| 494 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 495 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 496 |
│ Bookmarks: a |
| 497 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 498 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 499 |
│ |
| 500 |
│ (no description set) |
| 501 |
│ |
| 502 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 503 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 504 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 505 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 506 |
|
| 507 |
(no description set) |
| 508 |
|
| 509 |
[EOF] |
| 510 |
"); |
| 511 |
let setup_opid = work_dir.current_operation_id(); |
| 512 |
|
| 513 |
// Update multiple revisions |
| 514 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 515 |
work_dir.run_jj(["new"]).success(); |
| 516 |
let output = work_dir.run_jj([ |
| 517 |
"metaedit", |
| 518 |
"--config=user.name=Ove Ridder", |
| 519 |
"[email protected]", |
| 520 |
"--update-author", |
| 521 |
"kkmpptxz::mzvwutvl", |
| 522 |
]); |
| 523 |
insta::assert_snapshot!(output, @r" |
| 524 |
------- stderr ------- |
| 525 |
Modified 2 commits: |
| 526 |
kkmpptxz d84add51 b | (no description set) |
| 527 |
mzvwutvl 447d6d8a c | (no description set) |
| 528 |
Rebased 1 descendant commits. |
| 529 |
Working copy (@) now at: yostqsxw ebd66676 (empty) (no description set) |
| 530 |
Parent commit (@-) : mzvwutvl 447d6d8a c | (no description set) |
| 531 |
[EOF] |
| 532 |
"); |
| 533 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 534 |
@ Commit ID: ebd66676fa9e0cd2c9f560bc0dc343b8809e4dfe |
| 535 |
│ Change ID: yostqsxwqrltovqlrlzszywzslusmuup |
| 536 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:15.000 +07:00) |
| 537 |
│ Committer: Ove Ridder <[email protected]> (2001-02-03 04:05:16.000 +07:00) |
| 538 |
│ |
| 539 |
│ (no description set) |
| 540 |
│ |
| 541 |
○ Commit ID: 447d6d8a12d90ff0f10bbefc552f9272694389d6 |
| 542 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 543 |
│ Bookmarks: c |
| 544 |
│ Author : Ove Ridder <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 545 |
│ Committer: Ove Ridder <[email protected]> (2001-02-03 04:05:16.000 +07:00) |
| 546 |
│ |
| 547 |
│ (no description set) |
| 548 |
│ |
| 549 |
○ Commit ID: d84add5150537e89db428790c0f9413320127f00 |
| 550 |
│ Change ID: kkmpptxzrspxrzommnulwmwkkqwworpl |
| 551 |
│ Bookmarks: b |
| 552 |
│ Author : Ove Ridder <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 553 |
│ Committer: Ove Ridder <[email protected]> (2001-02-03 04:05:16.000 +07:00) |
| 554 |
│ |
| 555 |
│ (no description set) |
| 556 |
│ |
| 557 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 558 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 559 |
│ Bookmarks: a |
| 560 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 561 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 562 |
│ |
| 563 |
│ (no description set) |
| 564 |
│ |
| 565 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 566 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 567 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 568 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 569 |
|
| 570 |
(no description set) |
| 571 |
|
| 572 |
[EOF] |
| 573 |
"); |
| 574 |
} |
| 575 |
|
| 576 |
#[test] |
| 577 |
fn test_new_change_id() { |
| 578 |
let test_env = TestEnvironment::default(); |
| 579 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 580 |
let work_dir = test_env.work_dir("repo"); |
| 581 |
|
| 582 |
work_dir |
| 583 |
.run_jj(["bookmark", "create", "-r@", "a"]) |
| 584 |
.success(); |
| 585 |
work_dir.write_file("file1", "a\n"); |
| 586 |
work_dir.run_jj(["new"]).success(); |
| 587 |
work_dir |
| 588 |
.run_jj(["bookmark", "create", "-r@", "b"]) |
| 589 |
.success(); |
| 590 |
work_dir.write_file("file1", "b\n"); |
| 591 |
work_dir.run_jj(["new"]).success(); |
| 592 |
work_dir |
| 593 |
.run_jj(["bookmark", "create", "-r@", "c"]) |
| 594 |
.success(); |
| 595 |
work_dir.write_file("file1", "c\n"); |
| 596 |
|
| 597 |
let output = work_dir.run_jj(["metaedit", "--update-change-id", "kkmpptxzrspx"]); |
| 598 |
insta::assert_snapshot!(output, @r" |
| 599 |
------- stderr ------- |
| 600 |
Modified 1 commits: |
| 601 |
yqosqzyt 01d6741e b | (no description set) |
| 602 |
Rebased 1 descendant commits. |
| 603 |
Working copy (@) now at: mzvwutvl 0c3fe2d8 c | (no description set) |
| 604 |
Parent commit (@-) : yqosqzyt 01d6741e b | (no description set) |
| 605 |
[EOF] |
| 606 |
"); |
| 607 |
insta::assert_snapshot!(get_log(&work_dir), @" |
| 608 |
@ Commit ID: 0c3fe2d854b2b492a053156a505d6c40fe783138 |
| 609 |
│ Change ID: mzvwutvlkqwtuzoztpszkqxkqmqyqyxo |
| 610 |
│ Bookmarks: c |
| 611 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 612 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 613 |
│ |
| 614 |
│ (no description set) |
| 615 |
│ |
| 616 |
○ Commit ID: 01d6741ed708318bcd5911320237066db4b63b53 |
| 617 |
│ Change ID: yqosqzytrlswkspswpqrmlplxylrzsnz |
| 618 |
│ Bookmarks: b |
| 619 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:11.000 +07:00) |
| 620 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:13.000 +07:00) |
| 621 |
│ |
| 622 |
│ (no description set) |
| 623 |
│ |
| 624 |
○ Commit ID: e6086990958c236d72030f0a2651806aa629f5dd |
| 625 |
│ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 626 |
│ Bookmarks: a |
| 627 |
│ Author : Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 628 |
│ Committer: Test User <[email protected]> (2001-02-03 04:05:09.000 +07:00) |
| 629 |
│ |
| 630 |
│ (no description set) |
| 631 |
│ |
| 632 |
◆ Commit ID: 0000000000000000000000000000000000000000 |
| 633 |
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 634 |
Author : (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 635 |
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) |
| 636 |
|
| 637 |
(no description set) |
| 638 |
|
| 639 |
[EOF] |
| 640 |
"); |
| 641 |
insta::assert_snapshot!(work_dir.run_jj(["evolog", "-r", "yqosqzytrlswkspswpqrmlplxylrzsnz"]), @" |
| 642 |
○ yqosqzyt [email protected] 2001-02-03 08:05:13 b 01d6741e |
| 643 |
│ (no description set) |
| 644 |
│ -- operation ae935f447fc3 edit commit metadata for commit 75591b1896b4990e7695701fd7cdbb32dba3ff50 |
| 645 |
○ kkmpptxz/0 [email protected] 2001-02-03 08:05:11 75591b18 (hidden) |
| 646 |
│ (no description set) |
| 647 |
│ -- operation 40edb1af22f3 snapshot working copy |
| 648 |
○ kkmpptxz/1 [email protected] 2001-02-03 08:05:09 acebf2bd (hidden) |
| 649 |
(empty) (no description set) |
| 650 |
-- operation 9cda02fa4d24 new empty commit |
| 651 |
[EOF] |
| 652 |
"); |
| 653 |
insta::assert_snapshot!(work_dir.run_jj(["evolog", "-r", "mzvwut"]), @" |
| 654 |
@ mzvwutvl [email protected] 2001-02-03 08:05:13 c 0c3fe2d8 |
| 655 |
│ (no description set) |
| 656 |
│ -- operation ae935f447fc3 edit commit metadata for commit 75591b1896b4990e7695701fd7cdbb32dba3ff50 |
| 657 |
○ mzvwutvl/1 [email protected] 2001-02-03 08:05:13 22be6c4e (hidden) |
| 658 |
│ (no description set) |
| 659 |
│ -- operation 8eb7de08e61f snapshot working copy |
| 660 |
○ mzvwutvl/2 [email protected] 2001-02-03 08:05:11 b9f5490a (hidden) |
| 661 |
(empty) (no description set) |
| 662 |
-- operation d4a1aacb95fb new empty commit |
| 663 |
[EOF] |
| 664 |
"); |
| 665 |
} |
| 666 |
|
| 667 |
#[test] |
| 668 |
fn test_metaedit_option_mutual_exclusion() { |
| 669 |
let test_env = TestEnvironment::default(); |
| 670 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 671 |
let work_dir = test_env.work_dir("repo"); |
| 672 |
work_dir.run_jj(["commit", "-m=a"]).success(); |
| 673 |
work_dir.run_jj(["describe", "-m=b"]).success(); |
| 674 |
insta::assert_snapshot!(work_dir.run_jj([ |
| 675 |
"metaedit", |
| 676 |
"--author=Alice <[email protected]>", |
| 677 |
"--update-author", |
| 678 |
]), @" |
| 679 |
------- stderr ------- |
| 680 |
error: the argument '--author <AUTHOR>' cannot be used with '--update-author' |
| 681 |
|
| 682 |
Usage: jj metaedit --author <AUTHOR> [REVSETS]... |
| 683 |
|
| 684 |
For more information, try '--help'. |
| 685 |
[EOF] |
| 686 |
[exit status: 2] |
| 687 |
"); |
| 688 |
} |
| 689 |
|
| 690 |
#[test] |
| 691 |
fn test_update_empty_author_or_email() { |
| 692 |
let mut test_env = TestEnvironment::default(); |
| 693 |
|
| 694 |
// get rid of test author config |
| 695 |
test_env.add_env_var("JJ_USER", ""); |
| 696 |
test_env.add_env_var("JJ_EMAIL", ""); |
| 697 |
|
| 698 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 699 |
|
| 700 |
// show that commit has no author set |
| 701 |
insta::assert_snapshot!(test_env.work_dir("repo").run_jj(["show"]), @" |
| 702 |
Commit ID: 42c91a3e183efb4499038d0d9aa3d14b5deafde0 |
| 703 |
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 704 |
Author : (no name set) <(no email set)> (2001-02-03 08:05:07) |
| 705 |
Committer: (no name set) <(no email set)> (2001-02-03 08:05:07) |
| 706 |
|
| 707 |
(no description set) |
| 708 |
|
| 709 |
[EOF] |
| 710 |
"); |
| 711 |
|
| 712 |
// restore test author config, exercise --quiet |
| 713 |
test_env.add_env_var("JJ_USER", "Test User"); |
| 714 |
test_env.add_env_var("JJ_EMAIL", "[email protected]"); |
| 715 |
let work_dir = test_env.work_dir("repo"); |
| 716 |
|
| 717 |
// update existing commit with restored test author config |
| 718 |
insta::assert_snapshot!(work_dir.run_jj(["metaedit", "--update-author", "--quiet"]), @""); |
| 719 |
insta::assert_snapshot!(work_dir.run_jj(["show"]), @" |
| 720 |
Commit ID: 0f13b5f2ea7fad147c133c81b87d31e7b1b8c564 |
| 721 |
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 722 |
Author : Test User <[email protected]> (2001-02-03 08:05:09) |
| 723 |
Committer: Test User <[email protected]> (2001-02-03 08:05:09) |
| 724 |
|
| 725 |
(no description set) |
| 726 |
|
| 727 |
[EOF] |
| 728 |
"); |
| 729 |
|
| 730 |
// confirm user / email can be cleared/restored separately |
| 731 |
// leave verbose to see no-email warning + hint |
| 732 |
test_env.add_env_var("JJ_EMAIL", ""); |
| 733 |
let work_dir = test_env.work_dir("repo"); |
| 734 |
insta::assert_snapshot!(work_dir.run_jj(["metaedit", "--update-author"]), @r#" |
| 735 |
------- stderr ------- |
| 736 |
Modified 1 commits: |
| 737 |
qpvuntsm 234908d4 (empty) (no description set) |
| 738 |
Working copy (@) now at: qpvuntsm 234908d4 (empty) (no description set) |
| 739 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 740 |
Warning: Email not configured. Until configured, your commits will be created with the empty identity, and can't be pushed to remotes. |
| 741 |
Hint: To configure, run: |
| 742 |
jj config set --user user.email "[email protected]" |
| 743 |
[EOF] |
| 744 |
"#); |
| 745 |
insta::assert_snapshot!(work_dir.run_jj(["show"]), @" |
| 746 |
Commit ID: 234908d4748ff3224a87888d8b52a4923e1a89a5 |
| 747 |
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 748 |
Author : Test User <(no email set)> (2001-02-03 08:05:09) |
| 749 |
Committer: Test User <(no email set)> (2001-02-03 08:05:11) |
| 750 |
|
| 751 |
(no description set) |
| 752 |
|
| 753 |
[EOF] |
| 754 |
"); |
| 755 |
|
| 756 |
// confirm no-name warning + hint |
| 757 |
test_env.add_env_var("JJ_USER", ""); |
| 758 |
test_env.add_env_var("JJ_EMAIL", "[email protected]"); |
| 759 |
let work_dir = test_env.work_dir("repo"); |
| 760 |
insta::assert_snapshot!(work_dir.run_jj(["metaedit", "--update-author"]), @r#" |
| 761 |
------- stderr ------- |
| 762 |
Modified 1 commits: |
| 763 |
qpvuntsm ac5048cf (empty) (no description set) |
| 764 |
Working copy (@) now at: qpvuntsm ac5048cf (empty) (no description set) |
| 765 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 766 |
Warning: Name not configured. Until configured, your commits will be created with the empty identity, and can't be pushed to remotes. |
| 767 |
Hint: To configure, run: |
| 768 |
jj config set --user user.name "Some One" |
| 769 |
[EOF] |
| 770 |
"#); |
| 771 |
insta::assert_snapshot!(work_dir.run_jj(["show"]), @" |
| 772 |
Commit ID: ac5048cf35372ddc30e2590271781a3eab0bcaf8 |
| 773 |
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu |
| 774 |
Author : (no name set) <[email protected]> (2001-02-03 08:05:09) |
| 775 |
Committer: (no name set) <[email protected]> (2001-02-03 08:05:13) |
| 776 |
|
| 777 |
(no description set) |
| 778 |
|
| 779 |
[EOF] |
| 780 |
"); |
| 781 |
} |
| 782 |
|
| 783 |
#[test] |
| 784 |
/// Test that setting the same timestamp twice does nothing (issue #7602) |
| 785 |
fn test_metaedit_set_same_timestamp_twice() { |
| 786 |
let test_env = TestEnvironment::default(); |
| 787 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 788 |
let work_dir = test_env.work_dir("repo"); |
| 789 |
|
| 790 |
// Set the author-timestamp to the same value twice |
| 791 |
// and check that the second time it does nothing |
| 792 |
let output = work_dir.run_jj([ |
| 793 |
"metaedit", |
| 794 |
"--author-timestamp", |
| 795 |
"2001-02-03 04:05:14.000+07:00", |
| 796 |
]); |
| 797 |
insta::assert_snapshot!(output, @" |
| 798 |
------- stderr ------- |
| 799 |
Modified 1 commits: |
| 800 |
qpvuntsm 51b97b23 (empty) (no description set) |
| 801 |
Working copy (@) now at: qpvuntsm 51b97b23 (empty) (no description set) |
| 802 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 803 |
[EOF] |
| 804 |
"); |
| 805 |
|
| 806 |
// Running it again with the same date has no effect |
| 807 |
let output = work_dir.run_jj([ |
| 808 |
"metaedit", |
| 809 |
"--author-timestamp", |
| 810 |
"2001-02-03 04:05:14.000+07:00", |
| 811 |
]); |
| 812 |
insta::assert_snapshot!(output, @" |
| 813 |
------- stderr ------- |
| 814 |
Nothing changed. |
| 815 |
[EOF] |
| 816 |
"); |
| 817 |
} |
| 818 |
|
| 819 |
#[must_use] |
| 820 |
fn get_log(work_dir: &TestWorkDir) -> CommandOutput { |
| 821 |
work_dir.run_jj([ |
| 822 |
"--config", |
| 823 |
"template-aliases.'format_timestamp(t)'='t'", |
| 824 |
"log", |
| 825 |
"-T", |
| 826 |
"builtin_log_detailed", |
| 827 |
]) |
| 828 |
} |