Skip to content

Commit b34104c

Browse files
committed
Add force squash across merges option
1 parent 32eb7fb commit b34104c

23 files changed

+464
-2
lines changed

src/Commands/Command.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public enum EditorType
3636
public CancellationToken CancellationToken { get; set; } = CancellationToken.None;
3737
public bool RaiseError { get; set; } = true;
3838
public Models.ICommandLog Log { get; set; } = null;
39+
public Dictionary<string, string> Envs { get; } = new();
3940

4041
public async Task<bool> ExecAsync()
4142
{
@@ -192,6 +193,9 @@ protected ProcessStartInfo CreateGitStartInfo(bool redirect)
192193
start.Environment.Add("LC_ALL", "C");
193194
}
194195

196+
foreach (var kv in Envs)
197+
start.Environment[kv.Key] = kv.Value;
198+
195199
var builder = new StringBuilder();
196200
builder
197201
.Append("--no-pager -c core.quotepath=off -c credential.helper=")

src/Commands/DiffAll.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Threading.Tasks;
2+
3+
namespace SourceGit.Commands
4+
{
5+
public class DiffAll : Command
6+
{
7+
public DiffAll(string repo, string range)
8+
{
9+
WorkingDirectory = repo;
10+
Context = repo;
11+
Args = $"diff {range}";
12+
}
13+
14+
public async Task<string> GetResultAsync()
15+
{
16+
var rs = await ReadToEndAsync();
17+
return rs.IsSuccess ? rs.StdOut : string.Empty;
18+
}
19+
}
20+
}

src/Commands/DiffStat.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Threading.Tasks;
2+
3+
namespace SourceGit.Commands
4+
{
5+
public class DiffStat : Command
6+
{
7+
public DiffStat(string repo, string range)
8+
{
9+
WorkingDirectory = repo;
10+
Context = repo;
11+
Args = $"diff --stat {range}";
12+
}
13+
14+
public async Task<string> GetResultAsync()
15+
{
16+
var rs = await ReadToEndAsync().ConfigureAwait(false);
17+
if (rs.IsSuccess && !string.IsNullOrEmpty(rs.StdOut))
18+
return rs.StdOut.Trim();
19+
return string.Empty;
20+
}
21+
}
22+
}

src/Commands/IsAncestor.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Threading.Tasks;
2+
3+
namespace SourceGit.Commands
4+
{
5+
public class IsAncestor : Command
6+
{
7+
public IsAncestor(string repo, string ancestor, string descendant)
8+
{
9+
WorkingDirectory = repo;
10+
Context = repo;
11+
Args = $"merge-base --is-ancestor {ancestor} {descendant}";
12+
RaiseError = false;
13+
}
14+
15+
public bool Test()
16+
{
17+
return ReadToEnd().IsSuccess;
18+
}
19+
}
20+
}

src/Resources/Locales/de_DE.axaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
<x:String x:Key="Text.CommitCM.Reword" xml:space="preserve">Umformulieren</x:String>
149149
<x:String x:Key="Text.CommitCM.SaveAsPatch" xml:space="preserve">Als Patch speichern...</x:String>
150150
<x:String x:Key="Text.CommitCM.Squash" xml:space="preserve">Squash in den Vorgänger</x:String>
151+
<x:String x:Key="Text.CommitCM.ForceSquash" xml:space="preserve">Squash hierher erzwingen...</x:String>
151152
<x:String x:Key="Text.CommitDetail.Changes" xml:space="preserve">ÄNDERUNGEN</x:String>
152153
<x:String x:Key="Text.CommitDetail.Changes.Count" xml:space="preserve">geänderte Datei(en)</x:String>
153154
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">Änderungen durchsuchen...</x:String>
@@ -751,6 +752,19 @@
751752
<x:String x:Key="Text.SHALinkCM.NavigateTo" xml:space="preserve">Zum Commit wechseln</x:String>
752753
<x:String x:Key="Text.Squash" xml:space="preserve">Squash Commits</x:String>
753754
<x:String x:Key="Text.Squash.Into" xml:space="preserve">In:</x:String>
755+
<x:String x:Key="Text.ForceSquash.Title" xml:space="preserve">Squash über Merges (Historie glätten)</x:String>
756+
<x:String x:Key="Text.ForceSquash.Warn1" xml:space="preserve">Operation überschreibt die Historie vom gewählten Commit bis HEAD zu einem Commit</x:String>
757+
<x:String x:Key="Text.ForceSquash.Warn2" xml:space="preserve">Alle Merge-Commits im Bereich werden entfernt</x:String>
758+
<x:String x:Key="Text.ForceSquash.Warn3" xml:space="preserve">Signierte Commits oder Merges verlieren Signaturen</x:String>
759+
<x:String x:Key="Text.ForceSquash.Warn4" xml:space="preserve">Anschließend ist ein Force-Push erforderlich</x:String>
760+
<x:String x:Key="Text.ForceSquash.Warn5" xml:space="preserve">Schließe oder aktualisiere alle zugehörigen MR/PR</x:String>
761+
<x:String x:Key="Text.ForceSquash.CreateBackup" xml:space="preserve">Vor dem Überschreiben Sicherungszweig erstellen</x:String>
762+
<x:String x:Key="Text.ForceSquash.AutoStash" xml:space="preserve">Lokale Änderungen automatisch stashen</x:String>
763+
<x:String x:Key="Text.ForceSquash.KeepAuthorDate" xml:space="preserve">Originalautor und -datum des Ziel-Commits beibehalten</x:String>
764+
<x:String x:Key="Text.ForceSquash.AppendMessages" xml:space="preserve">Nachrichten der gesquashten Commits an den Body anhängen</x:String>
765+
<x:String x:Key="Text.ForceSquash.StashPopFailed" xml:space="preserve">Automatischen Stash anwenden fehlgeschlagen.</x:String>
766+
<x:String x:Key="Text.ForceSquash.Success" xml:space="preserve">Historie abgeflacht. Sicherungszweig: {0}</x:String>
767+
<x:String x:Key="Text.ForceSquash.SuccessNoBackup" xml:space="preserve">Historie abgeflacht.</x:String>
754768
<x:String x:Key="Text.SSHKey" xml:space="preserve">SSH privater Schlüssel:</x:String>
755769
<x:String x:Key="Text.SSHKey.Placeholder" xml:space="preserve">Pfad zum privaten SSH Schlüssel</x:String>
756770
<x:String x:Key="Text.Start" xml:space="preserve">START</x:String>

src/Resources/Locales/en_US.axaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
<x:String x:Key="Text.CommitCM.Reword" xml:space="preserve">Reword</x:String>
145145
<x:String x:Key="Text.CommitCM.SaveAsPatch" xml:space="preserve">Save as Patch...</x:String>
146146
<x:String x:Key="Text.CommitCM.Squash" xml:space="preserve">Squash into Parent</x:String>
147+
<x:String x:Key="Text.CommitCM.ForceSquash" xml:space="preserve">Force squash to here...</x:String>
147148
<x:String x:Key="Text.CommitDetail.Changes" xml:space="preserve">CHANGES</x:String>
148149
<x:String x:Key="Text.CommitDetail.Changes.Count" xml:space="preserve">changed file(s)</x:String>
149150
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">Search Changes...</x:String>
@@ -552,6 +553,7 @@
552553
<x:String x:Key="Text.Preferences.DiffMerge.Type" xml:space="preserve">Tool</x:String>
553554
<x:String x:Key="Text.Preferences.General" xml:space="preserve">GENERAL</x:String>
554555
<x:String x:Key="Text.Preferences.General.Check4UpdatesOnStartup" xml:space="preserve">Check for updates on startup</x:String>
556+
<x:String x:Key="Text.Preferences.General.EnableDangerousHistoryRewrites" xml:space="preserve">Enable dangerous history rewrites</x:String>
555557
<x:String x:Key="Text.Preferences.General.DateFormat" xml:space="preserve">Date Format</x:String>
556558
<x:String x:Key="Text.Preferences.General.Locale" xml:space="preserve">Language</x:String>
557559
<x:String x:Key="Text.Preferences.General.MaxHistoryCommits" xml:space="preserve">History Commits</x:String>
@@ -746,6 +748,19 @@
746748
<x:String x:Key="Text.SHALinkCM.NavigateTo" xml:space="preserve">Go to</x:String>
747749
<x:String x:Key="Text.Squash" xml:space="preserve">Squash Commits</x:String>
748750
<x:String x:Key="Text.Squash.Into" xml:space="preserve">Into:</x:String>
751+
<x:String x:Key="Text.ForceSquash.Title" xml:space="preserve">Squash across merges (flatten history)</x:String>
752+
<x:String x:Key="Text.ForceSquash.Warn1" xml:space="preserve">Operation rewrites history from selected commit to HEAD into one commit</x:String>
753+
<x:String x:Key="Text.ForceSquash.Warn2" xml:space="preserve">All merge commits in range will be removed</x:String>
754+
<x:String x:Key="Text.ForceSquash.Warn3" xml:space="preserve">Signed commits or merges lose signatures</x:String>
755+
<x:String x:Key="Text.ForceSquash.Warn4" xml:space="preserve">Force push is required afterwards</x:String>
756+
<x:String x:Key="Text.ForceSquash.Warn5" xml:space="preserve">Close or update any related MR/PR</x:String>
757+
<x:String x:Key="Text.ForceSquash.CreateBackup" xml:space="preserve">Create safety backup branch before rewrite</x:String>
758+
<x:String x:Key="Text.ForceSquash.AutoStash" xml:space="preserve">Auto-stash local changes</x:String>
759+
<x:String x:Key="Text.ForceSquash.KeepAuthorDate" xml:space="preserve">Keep original author/date of target commit</x:String>
760+
<x:String x:Key="Text.ForceSquash.AppendMessages" xml:space="preserve">Append messages of squashed commits to body</x:String>
761+
<x:String x:Key="Text.ForceSquash.StashPopFailed" xml:space="preserve">Failed to apply auto stash.</x:String>
762+
<x:String x:Key="Text.ForceSquash.Success" xml:space="preserve">History flattened. Backup branch: {0}</x:String>
763+
<x:String x:Key="Text.ForceSquash.SuccessNoBackup" xml:space="preserve">History flattened.</x:String>
749764
<x:String x:Key="Text.SSHKey" xml:space="preserve">SSH Private Key:</x:String>
750765
<x:String x:Key="Text.SSHKey.Placeholder" xml:space="preserve">Private SSH key store path</x:String>
751766
<x:String x:Key="Text.Start" xml:space="preserve">START</x:String>

src/Resources/Locales/es_ES.axaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
<x:String x:Key="Text.CommitCM.Reword" xml:space="preserve">Reescribir</x:String>
149149
<x:String x:Key="Text.CommitCM.SaveAsPatch" xml:space="preserve">Guardar como Parche...</x:String>
150150
<x:String x:Key="Text.CommitCM.Squash" xml:space="preserve">Squash en Parent</x:String>
151+
<x:String x:Key="Text.CommitCM.ForceSquash" xml:space="preserve">Forzar squash aquí...</x:String>
151152
<x:String x:Key="Text.CommitDetail.Changes" xml:space="preserve">CAMBIOS</x:String>
152153
<x:String x:Key="Text.CommitDetail.Changes.Count" xml:space="preserve">archivo(s) modificado(s)</x:String>
153154
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">Buscar Cambios...</x:String>
@@ -750,6 +751,19 @@
750751
<x:String x:Key="Text.SHALinkCM.NavigateTo" xml:space="preserve">Ir a</x:String>
751752
<x:String x:Key="Text.Squash" xml:space="preserve">Squash Commits</x:String>
752753
<x:String x:Key="Text.Squash.Into" xml:space="preserve">En:</x:String>
754+
<x:String x:Key="Text.ForceSquash.Title" xml:space="preserve">Squash a través de merges (aplanar historial)</x:String>
755+
<x:String x:Key="Text.ForceSquash.Warn1" xml:space="preserve">La operación reescribe el historial desde el commit seleccionado hasta HEAD en un solo commit</x:String>
756+
<x:String x:Key="Text.ForceSquash.Warn2" xml:space="preserve">Todos los commits de merge en el rango serán eliminados</x:String>
757+
<x:String x:Key="Text.ForceSquash.Warn3" xml:space="preserve">Los commits o merges firmados pierden sus firmas</x:String>
758+
<x:String x:Key="Text.ForceSquash.Warn4" xml:space="preserve">Se requiere un force push después</x:String>
759+
<x:String x:Key="Text.ForceSquash.Warn5" xml:space="preserve">Cierra o actualiza cualquier MR/PR relacionado</x:String>
760+
<x:String x:Key="Text.ForceSquash.CreateBackup" xml:space="preserve">Crear rama de respaldo antes de sobrescribir</x:String>
761+
<x:String x:Key="Text.ForceSquash.AutoStash" xml:space="preserve">Guardar automáticamente los cambios locales</x:String>
762+
<x:String x:Key="Text.ForceSquash.KeepAuthorDate" xml:space="preserve">Conservar autor/fecha originales del commit destino</x:String>
763+
<x:String x:Key="Text.ForceSquash.AppendMessages" xml:space="preserve">Añadir mensajes de los commits aplastados al cuerpo</x:String>
764+
<x:String x:Key="Text.ForceSquash.StashPopFailed" xml:space="preserve">No se pudo aplicar el auto-stash.</x:String>
765+
<x:String x:Key="Text.ForceSquash.Success" xml:space="preserve">Historial aplanado. Rama de respaldo: {0}</x:String>
766+
<x:String x:Key="Text.ForceSquash.SuccessNoBackup" xml:space="preserve">Historial aplanado.</x:String>
753767
<x:String x:Key="Text.SSHKey" xml:space="preserve">Clave Privada SSH:</x:String>
754768
<x:String x:Key="Text.SSHKey.Placeholder" xml:space="preserve">Ruta de almacenamiento de la clave privada SSH</x:String>
755769
<x:String x:Key="Text.Start" xml:space="preserve">INICIAR</x:String>

src/Resources/Locales/fr_FR.axaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<x:String x:Key="Text.CommitCM.Reword" xml:space="preserve">Reformuler</x:String>
109109
<x:String x:Key="Text.CommitCM.SaveAsPatch" xml:space="preserve">Enregistrer en tant que patch...</x:String>
110110
<x:String x:Key="Text.CommitCM.Squash" xml:space="preserve">Squash dans le parent</x:String>
111+
<x:String x:Key="Text.CommitCM.ForceSquash" xml:space="preserve">Forcer le squash ici...</x:String>
111112
<x:String x:Key="Text.CommitDetail.Changes" xml:space="preserve">CHANGEMENTS</x:String>
112113
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">Rechercher les changements...</x:String>
113114
<x:String x:Key="Text.CommitDetail.Files" xml:space="preserve">FICHIERS</x:String>
@@ -611,6 +612,19 @@
611612
<x:String x:Key="Text.SHALinkCM.NavigateTo" xml:space="preserve">Aller à</x:String>
612613
<x:String x:Key="Text.Squash" xml:space="preserve">Squash les commits</x:String>
613614
<x:String x:Key="Text.Squash.Into" xml:space="preserve">Dans :</x:String>
615+
<x:String x:Key="Text.ForceSquash.Title" xml:space="preserve">Squasher à travers les fusions (aplatir l'historique)</x:String>
616+
<x:String x:Key="Text.ForceSquash.Warn1" xml:space="preserve">L'opération réécrit l'historique du commit sélectionné jusqu'à HEAD en un seul commit</x:String>
617+
<x:String x:Key="Text.ForceSquash.Warn2" xml:space="preserve">Tous les commits de fusion dans l'intervalle seront supprimés</x:String>
618+
<x:String x:Key="Text.ForceSquash.Warn3" xml:space="preserve">Les commits ou fusions signés perdent leurs signatures</x:String>
619+
<x:String x:Key="Text.ForceSquash.Warn4" xml:space="preserve">Un push forcé est nécessaire ensuite</x:String>
620+
<x:String x:Key="Text.ForceSquash.Warn5" xml:space="preserve">Fermez ou mettez à jour toute MR/PR liée</x:String>
621+
<x:String x:Key="Text.ForceSquash.CreateBackup" xml:space="preserve">Créer une branche de sauvegarde avant la réécriture</x:String>
622+
<x:String x:Key="Text.ForceSquash.AutoStash" xml:space="preserve">Stasher automatiquement les modifications locales</x:String>
623+
<x:String x:Key="Text.ForceSquash.KeepAuthorDate" xml:space="preserve">Conserver l'auteur/la date originaux du commit cible</x:String>
624+
<x:String x:Key="Text.ForceSquash.AppendMessages" xml:space="preserve">Ajouter les messages des commits squashés au corps</x:String>
625+
<x:String x:Key="Text.ForceSquash.StashPopFailed" xml:space="preserve">Échec de l'application de l'auto-stash.</x:String>
626+
<x:String x:Key="Text.ForceSquash.Success" xml:space="preserve">Historique aplati. Branche de sauvegarde : {0}</x:String>
627+
<x:String x:Key="Text.ForceSquash.SuccessNoBackup" xml:space="preserve">Historique aplati.</x:String>
614628
<x:String x:Key="Text.SSHKey" xml:space="preserve">Clé privée SSH :</x:String>
615629
<x:String x:Key="Text.SSHKey.Placeholder" xml:space="preserve">Chemin du magasin de clés privées SSH</x:String>
616630
<x:String x:Key="Text.Start" xml:space="preserve">START</x:String>

src/Resources/Locales/it_IT.axaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
<x:String x:Key="Text.CommitCM.Reword" xml:space="preserve">Modifica</x:String>
120120
<x:String x:Key="Text.CommitCM.SaveAsPatch" xml:space="preserve">Salva come Patch...</x:String>
121121
<x:String x:Key="Text.CommitCM.Squash" xml:space="preserve">Compatta nel Genitore</x:String>
122+
<x:String x:Key="Text.CommitCM.ForceSquash" xml:space="preserve">Forza squash qui...</x:String>
122123
<x:String x:Key="Text.CommitDetail.Changes" xml:space="preserve">MODIFICHE</x:String>
123124
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">Cerca Modifiche...</x:String>
124125
<x:String x:Key="Text.CommitDetail.Files" xml:space="preserve">FILE</x:String>
@@ -639,6 +640,19 @@
639640
<x:String x:Key="Text.SHALinkCM.NavigateTo" xml:space="preserve">Vai a</x:String>
640641
<x:String x:Key="Text.Squash" xml:space="preserve">Compatta Commit</x:String>
641642
<x:String x:Key="Text.Squash.Into" xml:space="preserve">In:</x:String>
643+
<x:String x:Key="Text.ForceSquash.Title" xml:space="preserve">Squash attraverso i merge (appiattisci la cronologia)</x:String>
644+
<x:String x:Key="Text.ForceSquash.Warn1" xml:space="preserve">L'operazione riscrive la cronologia dal commit selezionato a HEAD in un solo commit</x:String>
645+
<x:String x:Key="Text.ForceSquash.Warn2" xml:space="preserve">Tutti i commit di merge nell'intervallo saranno rimossi</x:String>
646+
<x:String x:Key="Text.ForceSquash.Warn3" xml:space="preserve">I commit o i merge firmati perdono le firme</x:String>
647+
<x:String x:Key="Text.ForceSquash.Warn4" xml:space="preserve">È richiesto un force push dopo</x:String>
648+
<x:String x:Key="Text.ForceSquash.Warn5" xml:space="preserve">Chiudi o aggiorna qualsiasi MR/PR correlato</x:String>
649+
<x:String x:Key="Text.ForceSquash.CreateBackup" xml:space="preserve">Crea un ramo di backup prima della riscrittura</x:String>
650+
<x:String x:Key="Text.ForceSquash.AutoStash" xml:space="preserve">Esegui auto-stash delle modifiche locali</x:String>
651+
<x:String x:Key="Text.ForceSquash.KeepAuthorDate" xml:space="preserve">Mantieni autore/data originali del commit di destinazione</x:String>
652+
<x:String x:Key="Text.ForceSquash.AppendMessages" xml:space="preserve">Aggiungi i messaggi dei commit squasciati al corpo</x:String>
653+
<x:String x:Key="Text.ForceSquash.StashPopFailed" xml:space="preserve">Applicazione dell'auto-stash non riuscita.</x:String>
654+
<x:String x:Key="Text.ForceSquash.Success" xml:space="preserve">Cronologia appiattita. Ramo di backup: {0}</x:String>
655+
<x:String x:Key="Text.ForceSquash.SuccessNoBackup" xml:space="preserve">Cronologia appiattita.</x:String>
642656
<x:String x:Key="Text.SSHKey" xml:space="preserve">Chiave Privata SSH:</x:String>
643657
<x:String x:Key="Text.SSHKey.Placeholder" xml:space="preserve">Percorso per la chiave SSH privata</x:String>
644658
<x:String x:Key="Text.Start" xml:space="preserve">AVVIA</x:String>

0 commit comments

Comments
 (0)