|
6 | 6 | using System.Reflection; |
7 | 7 | using System.Text; |
8 | 8 | using System.Text.Json; |
9 | | -using System.Text.RegularExpressions; |
10 | 9 | using System.Threading; |
11 | 10 | using System.Threading.Tasks; |
12 | 11 |
|
@@ -488,23 +487,7 @@ private static bool TryLaunchAsRebaseTodoEditor(string[] args, out int exitCode) |
488 | 487 |
|
489 | 488 | using var stream = File.OpenRead(jobsFile); |
490 | 489 | var collection = JsonSerializer.Deserialize(stream, JsonCodeGen.Default.InteractiveRebaseJobCollection); |
491 | | - using var writer = new StreamWriter(file); |
492 | | - foreach (var job in collection.Jobs) |
493 | | - { |
494 | | - var code = job.Action switch |
495 | | - { |
496 | | - Models.InteractiveRebaseAction.Pick => 'p', |
497 | | - Models.InteractiveRebaseAction.Edit => 'e', |
498 | | - Models.InteractiveRebaseAction.Reword => 'r', |
499 | | - Models.InteractiveRebaseAction.Squash => 's', |
500 | | - Models.InteractiveRebaseAction.Fixup => 'f', |
501 | | - _ => 'd' |
502 | | - }; |
503 | | - writer.WriteLine($"{code} {job.SHA}"); |
504 | | - } |
505 | | - |
506 | | - writer.Flush(); |
507 | | - |
| 490 | + collection.WriteTodoList(file); |
508 | 491 | exitCode = 0; |
509 | 492 | return true; |
510 | 493 | } |
@@ -535,27 +518,8 @@ private static bool TryLaunchAsRebaseMessageEditor(string[] args, out int exitCo |
535 | 518 | var onto = File.ReadAllText(ontoFile).Trim(); |
536 | 519 | using var stream = File.OpenRead(jobsFile); |
537 | 520 | var collection = JsonSerializer.Deserialize(stream, JsonCodeGen.Default.InteractiveRebaseJobCollection); |
538 | | - if (!collection.Onto.Equals(onto) || !collection.OrigHead.Equals(origHead)) |
539 | | - return true; |
540 | | - |
541 | | - var done = File.ReadAllText(doneFile).Trim().Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); |
542 | | - if (done.Length == 0) |
543 | | - return true; |
544 | | - |
545 | | - var current = done[^1].Trim(); |
546 | | - var match = REG_REBASE_TODO().Match(current); |
547 | | - if (!match.Success) |
548 | | - return true; |
549 | | - |
550 | | - var sha = match.Groups[1].Value; |
551 | | - foreach (var job in collection.Jobs) |
552 | | - { |
553 | | - if (job.SHA.StartsWith(sha)) |
554 | | - { |
555 | | - File.WriteAllText(file, job.Message); |
556 | | - break; |
557 | | - } |
558 | | - } |
| 521 | + if (collection.Onto.StartsWith(onto, StringComparison.OrdinalIgnoreCase) && collection.OrigHead.StartsWith(origHead, StringComparison.OrdinalIgnoreCase)) |
| 522 | + collection.WriteCommitMessage(doneFile, file); |
559 | 523 |
|
560 | 524 | return true; |
561 | 525 | } |
@@ -806,9 +770,6 @@ private string FixFontFamilyName(string input) |
806 | 770 | return trimmed.Count > 0 ? string.Join(',', trimmed) : string.Empty; |
807 | 771 | } |
808 | 772 |
|
809 | | - [GeneratedRegex(@"^[a-z]+\s+([a-fA-F0-9]{4,64})(\s+.*)?$")] |
810 | | - private static partial Regex REG_REBASE_TODO(); |
811 | | - |
812 | 773 | private Models.IpcChannel _ipcChannel = null; |
813 | 774 | private ViewModels.Launcher _launcher = null; |
814 | 775 | private ResourceDictionary _activeLocale = null; |
|
0 commit comments