-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitmaster_flash.py
More file actions
4867 lines (4408 loc) · 234 KB
/
Copy pathgitmaster_flash.py
File metadata and controls
4867 lines (4408 loc) · 234 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""gitmaster_flash — fast terminal (TUI) overview of every Git repo below the
current directory, so you can tidy up many repos quickly.
Green = clean and in sync with the configured remote; red/yellow = needs
attention (modified/deleted/untracked files, merge conflicts, stashes, commits
ahead/behind). Problem repos sort to the top.
Keys (all shown in the footer, nothing to memorize; case-insensitive — f == F):
↑/↓ select a repo
→ expand (shows files with M/D/U/C and stashes)
← collapse
⏎ quit and cd into the repo in your terminal
(needs the shell wrapper `gmf` from gmf.zsh — a child process cannot
change the parent shell's working directory)
F/… open the repo in a configured app (see config.json)
A look at the changes file by file; there Z discards the selected one
(hard for a single file, all of them together into a stash instead)
C commit helper: suggests what to commit and what to .gitignore
P safely push the current branch to the private sync remote
L safely fast-forward the current branch from the private sync remote
G guarded GitHub push (preview + typed confirmation; branch only, no tags)
H explain the Git safety rules
I show repository details, remote addresses, and clickable GitHub URLs
U apply the latest stash (git stash pop, with confirmation)
S view the latest stash as a diff (read-only, scrollable)
D drop the latest stash (git stash drop, with confirmation)
R reload everything incl. `git fetch --all` (shows progress)
Q quit
Non-interactive: with --list / --json (or no TTY) it prints the overview as text
or JSON (machine-readable). Exit code 1 if any repo needs attention.
Two machines: `--diff HOST` compares this machine's repos with another one over
ssh and prints only the differences (read-only, never changes anything). The only
requirement is that `ssh HOST` works — gitmaster_flash does NOT need to be
installed there: the script is piped over stdin, so both sides always run the
exact same version. Remotes live in .git/config and are never carried by git
itself, so they drift silently between machines — that is what this finds.
Try it risk-free: `gitmaster_flash.py --demo` builds a throwaway sandbox of fake
repos in every state and opens the UI on it (also used for the README screenshots).
Config: ~/.config/gitmaster_flash/config.json (created on first run). Configurable:
app keys, the sync-remote match, scan exclusions, and UI language (en/de).
"""
from __future__ import annotations
import argparse
import concurrent.futures
import curses
import hashlib
import json
import math
import os
import posixpath
import re
import shlex
import signal
import stat
import subprocess
import sys
import tempfile
import unicodedata
import urllib.parse
from dataclasses import dataclass, field
from pathlib import Path
from typing import NamedTuple
__version__ = "0.18.1"
# Ein reiner lokaler Scan darf alle zwölf Worker nutzen. Beim Fetch bleiben wir
# dagegen bewusst unter dem verbreiteten sshd-Default ``MaxStartups 10:30:100``:
# Beim ersten Kaltstart ist der ControlMaster-Socket noch nicht da, und zwölf
# gleichzeitige SSH-Anmeldungen würden sonst zufällig einzelne Repos treffen.
LOCAL_SCAN_WORKERS = 12
FETCH_SCAN_WORKERS = 8
CONFIG_PATH = Path.home() / ".config" / "gitmaster_flash" / "config.json"
# Defaults; die geschriebene config.json darf einzelne Schlüssel überschreiben.
# Bewusst generisch gehalten: eigene Editoren/Remote-Namen setzt man in der Config.
DEFAULT_CONFIG = {
# Taste -> App zum Öffnen des Repo-Ordners (macOS `open -a`). Die Taste
# erscheint automatisch im Footer ("E Editor"). Beispiel für weitere:
# "Z": {"name": "Zed", "path": "/Applications/Zed.app"} (freie Taste waehlen)
"apps": {
"E": {"name": "Editor", "path": "/Applications/Visual Studio Code.app"},
},
# Woran der Sync-Remote erkannt wird: Remote-Name ODER Host in der URL.
"sync_remote_names": ["origin"],
"sync_remote_hosts": [],
# Ordner, in die der Repo-Scan gar nicht erst hineinschaut (Tempo).
"skip_dirs": ["node_modules", "Library", ".Trash", "venv", ".venv", "__pycache__"],
# UI-Sprache: "en", "de" oder null = automatisch aus $LANG (Fallback en).
"lang": None,
# Ab so vielen Repos startet die kompakte, mehrspaltige Ansicht (M schaltet um).
"compact_from": 20,
# Timeout in Sekunden für einzelne git-Aufrufe (fetch darf länger).
"git_timeout": 10,
"fetch_timeout": 30,
# `git commit` führt den pre-commit-Hook des Repos aus — und der startet in
# vielen Projekten Linter oder Tests, die deutlich länger als zehn Sekunden
# brauchen. Mit dem kurzen git_timeout wäre jeder solche Commit chancenlos.
"commit_timeout": 120,
}
# Muster für die Commit-Hilfe: Dateien, die typischerweise in .gitignore gehören.
# (basename_oder_teil, ist_verzeichnis, gitignore_zeile)
IGNORE_RULES = [
("node_modules", True, "node_modules/"),
("__pycache__", True, "__pycache__/"),
(".venv", True, ".venv/"),
("venv", True, "venv/"),
("dist", True, "dist/"),
("build", True, "build/"),
(".idea", True, ".idea/"),
(".pytest_cache", True, ".pytest_cache/"),
(".mypy_cache", True, ".mypy_cache/"),
(".ruff_cache", True, ".ruff_cache/"),
(".DS_Store", False, ".DS_Store"),
("Thumbs.db", False, "Thumbs.db"),
(".env", False, ".env"),
]
IGNORE_SUFFIXES = {".pyc": "*.pyc", ".log": "*.log", ".tmp": "*.tmp"}
# ---------------------------------------------------------------------------
# i18n — kleine Übersetzungsschicht (Englisch = Basis, Deutsch optional)
# ---------------------------------------------------------------------------
UI_LANG = "en" # von main() gesetzt; Tests nutzen die englische Basis.
TR = {
# Fortschritt / Kopf
"reading": {"en": "Reading repos", "de": "Lese Repos"},
"fetching": {"en": "Fetching from remote", "de": "Hole Stand vom Remote (fetch)"},
"hdr_repos": {"en": "repos", "de": "Repos"},
# --diff (two machines)
"diff_here": {"en": "here", "de": "hier"},
"diff_same": {"en": "No differences to {h}.", "de": "Kein Unterschied zu {h}."},
"diff_need_host": {"en": "--diff needs a host, e.g. --diff mymac",
"de": "--diff braucht einen Host, z.B. --diff meinmac"},
"diff_ssh_failed": {"en": "Cannot reach {h}: {e}", "de": "{h} nicht erreichbar: {e}"},
"diff_ssh_exit": {"en": "ssh exited with code {code}",
"de": "ssh endete mit Code {code}"},
"diff_ssh_no_output": {"en": "no output", "de": "keine Ausgabe"},
"diff_ssh_bad_json": {"en": "unreadable JSON", "de": "unlesbares JSON"},
"diff_version": {
"en": "! version differs: {a} {va} vs {b} {vb} — compare with care",
"de": "! Version verschieden: {a} {va} vs. {b} {vb} — Vergleich mit Vorsicht lesen"},
# {m}/{a}/{b} kommen vorformatiert aus _loc(): "hier" bleibt nackt,
# Hostnamen bekommen "auf"/"on" — deshalb steht die Praeposition NICHT im Text.
"diff_on": {"en": "on {m}", "de": "auf {m}"},
"diff_only_on": {"en": "only {m}: {rel}", "de": "nur {m}: {rel}"},
"diff_remote_missing": {
"en": "DRIFT {rel}: remote '{r}' only {m} (git never transfers remotes)",
"de": "DRIFT {rel}: Remote '{r}' nur {m} (Git uebertraegt Remotes nie)"},
"diff_remote_state": {
"en": "DRIFT {rel}: {r} is {aa} ahead/{ab} behind {a}, {ba}/{bb} {b}",
"de": "DRIFT {rel}: {r} {a} {aa} voraus/{ab} zurueck, {b} {ba}/{bb}"},
"diff_sync_even": {
"en": "SYNC {rel}: {r} {aa} ahead/{ab} behind on both machines",
"de": "SYNC {rel}: {r} auf beiden Rechnern {aa} voraus/{ab} zurueck"},
"diff_branch": {"en": "local {rel}: [{ba}] {a}, [{bb}] {b}",
"de": "lokal {rel}: [{ba}] {a}, [{bb}] {b}"},
"diff_dirty": {"en": "local {rel}: {n} changed/new file(s) {m}",
"de": "lokal {rel}: {n} geaenderte/neue Datei(en) {m}"},
# Einmal je Lauf, nicht je Repo: sonst wiederholt ein einziger fehlgeschlagener
# Fetch dieselbe Zeile fuer jedes Repo des Rechners.
"diff_fetch_failed_side": {
"en": ("local fetch failed {m} for {n} repo(s) — remote state not measurable "
"there, not a difference between the machines"),
"de": ("lokal Fetch scheiterte {m} bei {n} Repo(s) — der Remote-Stand ist dort "
"nicht messbar, das ist kein Unterschied zwischen den Rechnern")},
"diff_repo_field": {
"en": "DRIFT {rel}: {field} is {va} {a}, {vb} {b}",
"de": "DRIFT {rel}: {field} {a}={va}, {b}={vb}"},
"diff_remote_security": {
"en": "DRIFT {rel}: security/endpoint identity for {r} differs",
"de": "DRIFT {rel}: Sicherheit/Ziel-Identität für {r} unterscheidet sich"},
"diff_remote_branch": {
"en": "DRIFT {rel}: branch '{br}' exists on {r} only {m}",
"de": "DRIFT {rel}: Branch '{br}' existiert auf {r} nur {m}"},
"hdr_review": {"en": "{n} to review", "de": "{n} zu prüfen"},
"hdr_clean": {"en": "all clean ✔", "de": "alles sauber ✔"},
# Repo-Zeile
"clean_synced": {"en": "✔ clean & synced", "de": "✔ sauber & synchron"},
"no_sync_remote": {"en": "no sync remote", "de": "kein Sync-Remote"},
"branch_not_on": {"en": "branch '{b}' not on {r}", "de": "Branch '{b}' nicht auf {r}"},
"detached": {"en": "detached HEAD", "de": "detached HEAD"},
"error_prefix": {"en": "ERROR: {e}", "de": "FEHLER: {e}"},
"conflict_n": {"en": "conflict:{n}", "de": "Konflikt:{n}"},
# Detailzeilen
"conflict_label": {"en": "C=conflict ", "de": "C=Konflikt "},
"stash_row_hint": {"en": "(U pop · S preview · D drop)",
"de": "(U anwenden · S Vorschau · D verwerfen)"},
"no_changes": {"en": "(no changes)", "de": "(keine Änderungen)"},
# Änderungen ansehen (A)
"changes_title": {"en": "Changes · {rel}", "de": "Änderungen · {rel}"},
"changes_footer": {
"en": " ↑/↓ or Tab select file · ⏎ show diff · Z discard · Q/Esc back",
"de": " ↑/↓ oder Tab Datei wählen · ⏎ Diff ansehen · Z verwerfen · Q/Esc zurück"},
"no_changes_to_show": {"en": "Nothing changed in this repository.",
"de": "In diesem Repo hat sich nichts geändert."},
"diff_title": {"en": "Diff · {p}", "de": "Diff · {p}"},
"diff_empty": {"en": "(no textual difference — binary or mode change only)",
"de": "(kein Textunterschied — nur binär oder Rechte geändert)"},
"diff_failed": {"en": "Diff for {p} failed: {e}",
"de": "Diff für {p} fehlgeschlagen: {e}"},
# Footer
"f1": {"en": " ↑/↓/←/→ select · ⏎ cd & quit · M view · Tab log · I info · H help",
"de": " ↑/↓/←/→ wählen · ⏎ cd & Exit · M Ansicht · Tab Log · I Info · H Hilfe"},
"f2": {"en": " {apps} · A changes · C commit · U stash pop · S stash view · D stash drop",
"de": " {apps} · A Änderungen · C Commit · U Stash pop · S Stash-Blick · D Stash weg"},
"f3": {"en": " R fetch all · P sync push · L sync pull · G GitHub push · Q quit",
"de": " R fetch all · P Sync-Push · L Sync-Pull · G GitHub-Push · Q Beenden"},
# Kompakte Ansicht und Protokollbereich
"compact_more": {"en": "columns {a}-{b}/{n}", "de": "Spalten {a}-{b}/{n}"},
"log_pane_title": {"en": " Commands", "de": " Befehle"},
"log_pane_hint": {"en": " (Tab to scroll)", "de": " (Tab zum Scrollen)"},
"log_pane_focus": {"en": " ↑/↓ scroll · Tab back to the list",
"de": " ↑/↓ scrollen · Tab zurück zur Liste"},
"yesno": {"en": " (Y/N)", "de": " (J/N)"},
"yesno_extra": {"en": " (Y/N/{k})", "de": " (J/N/{k})"},
# Apps
"app_not_found": {"en": "App not found: {p} (edit config.json)",
"de": "App nicht gefunden: {p} (config.json anpassen)"},
"app_opened": {"en": "Opened {name}: {rel}", "de": "{name} geöffnet: {rel}"},
"app_open_failed": {"en": "Failed to open {name}: {e}",
"de": "{name} öffnen fehlgeschlagen: {e}"},
"app_over_ssh": {
"en": "This is an SSH session — {name} can only open on the Mac you sit at.",
"de": "Das ist eine SSH-Sitzung — {name} öffnet nur auf dem Mac vor dir."},
"cd_hint": {"en": "(Tip: install the `gmf` shell wrapper from gmf.zsh, "
"then you land there automatically.)",
"de": "(Tipp: Shell-Wrapper `gmf` aus gmf.zsh installieren, "
"dann landet man automatisch dort.)"},
# Stash
"no_stash": {"en": "No stash in this repo.", "de": "Kein Stash in diesem Repo."},
"resolve_conflicts_first": {
"en": "Resolve the merge conflicts first (open the repo with an app key), "
"then press U again.",
"de": "Erst die Merge-Konflikte auflösen (App-Taste öffnet das Repo), "
"dann erneut U drücken."},
"confirm_pop": {"en": "Apply latest stash in '{rel}' (git stash pop)?",
"de": "Neuesten Stash in '{rel}' anwenden (git stash pop)?"},
"cancelled": {"en": "Cancelled.", "de": "Abgebrochen."},
"stash_applied": {"en": "Stash applied in {rel}.", "de": "Stash angewendet in {rel}."},
"stash_conflict": {
"en": "Stash created {n} merge conflict(s) — the stash is kept. "
"Open the repo with an app key and resolve.",
"de": "Stash erzeugte {n} Merge-Konflikt(e) — Stash bleibt erhalten. "
"Repo mit einer App-Taste öffnen und auflösen."},
"stash_pop_failed": {"en": "stash pop failed: {e}", "de": "stash pop fehlgeschlagen: {e}"},
"empty_diff": {"en": "(empty diff)", "de": "(leerer Diff)"},
"stash_preview_failed": {"en": "Stash preview failed: {e}",
"de": "Stash-Vorschau fehlgeschlagen: {e}"},
"stash_preview_empty": {
"en": "(stash exists, but Git produced no displayable patch)",
"de": "(Stash vorhanden, aber Git erzeugte keinen darstellbaren Patch)"},
"stash_preview_title": {"en": "Stash preview · {rel} · {s}",
"de": "Stash-Vorschau · {rel} · {s}"},
"confirm_drop": {"en": "Drop latest stash in '{rel}' PERMANENTLY "
"(git stash drop)? Cannot be undone.",
"de": "Neuesten Stash in '{rel}' ENDGÜLTIG verwerfen "
"(git stash drop)? Nicht rückgängig machbar."},
"drop_cancelled": {"en": "Cancelled — stash kept.",
"de": "Abgebrochen — Stash bleibt erhalten."},
"stash_dropped": {"en": "Stash dropped in {rel}.", "de": "Stash verworfen in {rel}."},
"stash_drop_failed": {"en": "stash drop failed: {e}",
"de": "stash drop fehlgeschlagen: {e}"},
# Pager
"pager_footer": {"en": " ↑/↓ scroll · Q/Esc close · line {a}-{b} / {n}",
"de": " ↑/↓ scrollen · Q/Esc schließen · Zeile {a}-{b} / {n}"},
# Commit-Hilfe
"commit_title": {"en": "Commit helper · {rel} — review, then ⏎",
"de": "Commit-Hilfe · {rel} — Vorschlag prüfen, dann ⏎"},
"to_gitignore": {"en": "→ .gitignore ({p})", "de": "→ .gitignore ({p})"},
"do_commit": {"en": "✔ commit", "de": "✔ committen"},
"do_skip": {"en": "✘ skip", "de": "✘ auslassen"},
"commit_footer": {"en": " ␣ commit on/off · i gitignore on/off · ⏎ next · Esc cancel",
"de": " ␣ committen an/aus · i gitignore an/aus · ⏎ weiter · Esc abbrechen"},
"commit_cancelled": {"en": "Commit helper cancelled.", "de": "Commit-Hilfe abgebrochen."},
"nothing_selected": {"en": "Nothing selected.", "de": "Nichts ausgewählt."},
"commit_in": {"en": "Commit in {rel}", "de": "Commit in {rel}"},
"new_in_gitignore": {"en": "New in .gitignore:", "de": "Neu in .gitignore:"},
"more_entries": {"en": "… and {n} more", "de": "… und {n} weitere"},
"to_commit_n": {"en": "To commit: {n} file(s)", "de": "Zu committen: {n} Datei(en)"},
"recent_msgs": {"en": "Recent commit messages (style reference):",
"de": "Letzte Commit-Messages (Stil-Vorlage):"},
"commit_msg_prompt": {"en": "Commit message: ", "de": "Commit-Message: "},
"empty_msg": {"en": "Empty message — cancelled.", "de": "Leere Message — abgebrochen."},
"git_add_failed": {"en": "git add failed: {e}", "de": "git add fehlgeschlagen: {e}"},
"commit_failed": {"en": "Commit failed: {e}", "de": "Commit fehlgeschlagen: {e}"},
# Ein Commit läuft nicht immer sofort durch: der pre-commit-Hook des Repos kann
# Linter oder Tests starten. Ohne diese Zeile sähe die TUI so lange tot aus.
"commit_running": {
"en": "Committing … a pre-commit hook may run (up to {s}s).",
"de": "Committe … ein pre-commit-Hook kann laufen (bis zu {s}s)."},
"commit_timeout_none": {
"en": "Commit cancelled after {s}s — nothing was committed. Raise commit_timeout "
"in the config file if the hook needs longer.",
"de": "Commit nach {s}s abgebrochen — es wurde nichts committet. Bei Bedarf "
"commit_timeout in der config.json erhöhen."},
"commit_timeout_done": {
"en": "Commit cancelled after {s}s, but the commit exists — check git log.",
"de": "Commit nach {s}s abgebrochen, aber der Commit ist da — git log prüfen."},
"commit_conflicts": {
"en": "Commit helper is blocked while merge conflicts exist.",
"de": "Die Commit-Hilfe ist gesperrt, solange Merge-Konflikte bestehen."},
# Der Rückgängig-Befehl steht bewusst in der Meldung: Wer gerade committet hat,
# soll nicht suchen müssen, wie er es zurücknimmt.
"committed_in": {"en": "Committed in {rel}. Undo: git reset --soft HEAD~1",
"de": "Committet in {rel}. Rückgängig: git reset --soft HEAD~1"},
"confirm_push": {"en": "Push {n} commit(s) to {r} now?",
"de": "Jetzt {n} Commit(s) zu {r} pushen?"},
"committed_pushed": {"en": "Committed & pushed ({r}).", "de": "Committet & gepusht ({r})."},
"push_failed": {"en": "Push failed (Git exit code {code}).",
"de": "Push fehlgeschlagen (Git-Exit-Code {code})."},
"pull_failed": {"en": "Fast-forward failed (Git exit code {code}).",
"de": "Fast-forward fehlgeschlagen (Git-Exit-Code {code})."},
"nothing_to_commit": {"en": "Nothing to commit in this repo.",
"de": "Nichts zu committen in diesem Repo."},
# Sichere Push-/Pull-Hilfe
"no_sync_for_action": {"en": "No sync remote is configured for this repository.",
"de": "Für dieses Repo ist kein Sync-Remote konfiguriert."},
"public_simple_block": {
"en": "The sync remote is public. Use G for the guarded GitHub preview.",
"de": "Der Sync-Remote ist öffentlich. Nutze G für die geschützte GitHub-Vorschau."},
"transfer_fetch_failed": {"en": "Fetch from {r} failed (Git exit code {code}).",
"de": "Fetch von {r} fehlgeschlagen (Git-Exit-Code {code})."},
# Kurz halten: diese Meldung erscheint auch als Badge in der Repo-Zeile und
# wird dort auf die Terminalbreite abgeschnitten. Die Langfassung steht im README.
"transfer_auth_missing": {
"en": "{r} needs a login (no credential helper or SSH key).",
"de": "{r} braucht einen Login (kein Credential-Helper/SSH-Key)."},
"fetch_remote_failed": {
"en": "Fetch from {r} failed; press I to check the cause.",
"de": "Fetch von {r} fehlgeschlagen; mit I die Ursache prüfen."},
"transfer_inspect_failed": {
"en": "Git could not inspect the branch safely; no transfer was attempted.",
"de": "Git konnte den Branch nicht sicher prüfen; es wurde nichts übertragen."},
"remote_url_mismatch": {
"en": "{r} has multiple or differing fetch/push targets; transfer is blocked.",
"de": "{r} hat mehrere oder abweichende Fetch-/Push-Ziele; Transfer ist gesperrt."},
"transfer_changed": {
"en": "Branch, files, index, remote, or target changed after approval; review again.",
"de": "Branch, Dateien, Index, Remote oder Ziel änderten sich nach der Freigabe; erneut prüfen."},
"transfer_dirty": {"en": "Working tree is not clean — commit, ignore, or stash first.",
"de": "Arbeitsbaum ist nicht sauber — erst committen, ignorieren oder stashen."},
"transfer_detached": {"en": "Detached HEAD — use the terminal for this special case.",
"de": "Detached HEAD — diesen Sonderfall im Terminal bearbeiten."},
"transfer_missing": {"en": "Branch '{b}' does not exist on {r}; creating remote branches is blocked here.",
"de": "Branch '{b}' existiert nicht auf {r}; neue Remote-Branches sind hier gesperrt."},
"transfer_divergent": {"en": "Local and {r} have diverged ({a} ahead, {b} behind); no automatic reconciliation.",
"de": "Lokal und {r} sind divergiert ({a} voraus, {b} zurück); kein automatischer Abgleich."},
"transfer_behind": {"en": "Local branch is {n} commit(s) behind {r}; pull first.",
"de": "Der lokale Branch ist {n} Commit(s) hinter {r}; zuerst pullen."},
"nothing_to_push": {"en": "Nothing to push to {r}.", "de": "Nichts zu {r} zu pushen."},
"nothing_to_pull": {"en": "Nothing to pull from {r}.", "de": "Nichts von {r} zu pullen."},
"confirm_sync_push": {"en": "Push {n} commit(s) to the private sync remote {r}?",
"de": "{n} Commit(s) zum privaten Sync-Remote {r} pushen?"},
"confirm_sync_pull": {"en": "Fast-forward {n} commit(s) from the private sync remote {r}?",
"de": "{n} Commit(s) per Fast-forward vom privaten Sync-Remote {r} holen?"},
"sync_pushed": {"en": "Pushed current branch to {r} (no tags).",
"de": "Aktuellen Branch zu {r} gepusht (keine Tags)."},
"sync_pulled": {"en": "Fast-forwarded current branch from {r}.",
"de": "Aktuellen Branch per Fast-forward von {r} geholt."},
"no_github": {"en": "No GitHub remote in this repository.",
"de": "Dieses Repo hat keinen GitHub-Remote."},
"many_github": {"en": "Several GitHub remotes ({names}); use the terminal to choose deliberately.",
"de": "Mehrere GitHub-Remotes ({names}); bitte im Terminal bewusst auswählen."},
"github_preview": {"en": "GitHub push preview · {rel} → {r}/{b}",
"de": "GitHub-Push-Vorschau · {rel} → {r}/{b}"},
"github_type": {"en": "Type '{phrase}' to publish this branch only: ",
"de": "Zum Veröffentlichen nur dieses Branches '{phrase}' eingeben: "},
"github_cancelled": {"en": "GitHub push cancelled — nothing was published.",
"de": "GitHub-Push abgebrochen — nichts wurde veröffentlicht."},
"github_pushed": {"en": "Published current branch to {r}; no tags were sent.",
"de": "Aktuellen Branch zu {r} veröffentlicht; keine Tags übertragen."},
"github_changed": {"en": "Remote or outgoing files changed after the preview; review again.",
"de": "Remote oder ausgehende Dateien änderten sich nach der Vorschau; bitte erneut prüfen."},
"preview_branch_only": {
"en": "Branch only: approved OID + target lease, no tags or new remote branch.",
"de": "Nur Branch: freigegebene OID + Ziel-Lease, keine Tags/neuen Remote-Branches."},
"preview_privacy": {
"en": "Review every outgoing commit and file name; this is not an automatic privacy approval.",
"de": "Jeden ausgehenden Commit und Dateinamen prüfen; dies ist keine automatische Privacy-Freigabe."},
"outgoing_commits": {"en": "Outgoing commits:", "de": "Ausgehende Commits:"},
"changed_files": {"en": "Changed files:", "de": "Geänderte Dateien:"},
"none_label": {"en": "(none)", "de": "(keine)"},
"git_help_title": {"en": "Safe Git actions & command log",
"de": "Sichere Git-Aktionen & Befehlsprotokoll"},
"git_help_body": {
"en": "P Push only the current branch to the private sync remote.\n"
" Requires a clean tree, fetches first, and rejects behind/divergent history.\n\n"
"L Pull only from the private sync remote by fast-forward.\n"
" Never merges or rebases and refuses dirty/divergent repositories.\n\n"
"G Guarded GitHub push. Shows outgoing commits and file names first.\n"
" Requires typing PUSH <remote>; pins source and target OIDs and sends no tags.\n"
" New or unrelated GitHub branches remain terminal-only special cases.\n\n"
"R Fetches all remotes in all repositories; it does not change working trees.\n\n"
"Z Discards the selected file in the changes view (A) — the only action\n"
" that loses an uncommitted change, and there is no undo for it.\n"
" Untracked files, merge conflicts and renames are refused.\n"
" A in that dialog puts all changes into a stash instead.",
"de": "P Nur den aktuellen Branch zum privaten Sync-Remote pushen.\n"
" Verlangt einen sauberen Tree, fetcht zuerst und blockiert Rückstand/Divergenz.\n\n"
"L Nur per Fast-forward vom privaten Sync-Remote holen.\n"
" Führt nie Merge oder Rebase aus und verweigert dirty/divergente Repos.\n\n"
"G Geschützter GitHub-Push mit Vorschau von Commits und Dateinamen.\n"
" Verlangt PUSH <Remote>; pinnt Quell-/Ziel-OID und sendet keine Tags.\n"
" Neue oder unverbundene GitHub-Branches bleiben Terminal-Sonderfälle.\n\n"
"R Fetcht alle Remotes aller Repos; Working Trees bleiben unverändert.\n\n"
"Z Verwirft in der Änderungsansicht (A) die gewählte Datei — die einzige\n"
" Aktion, die eine nicht committete Änderung verliert; kein Zurück.\n"
" Unverfolgte Dateien, Merge-Konflikte und Umbenennungen lehnt gmf ab.\n"
" A im selben Dialog legt stattdessen alle Änderungen in einen Stash."},
# Repo-Info
"repo_info_title": {"en": "Repository info · {rel}", "de": "Repo-Info · {rel}"},
"info_path": {"en": "Path", "de": "Pfad"},
"info_branch": {"en": "Branch", "de": "Branch"},
"info_head": {"en": "HEAD", "de": "HEAD"},
"info_last_commit": {"en": "Last commit", "de": "Letzter Commit"},
"info_history": {"en": "History", "de": "Historie"},
"info_history_value": {
"en": "{n} commit(s) · {kind}",
"de": "{n} Commit(s) · {kind}"},
"info_full_clone": {"en": "full clone", "de": "vollständiger Clone"},
"info_shallow_clone": {"en": "shallow clone", "de": "flacher Clone"},
"info_no_commits": {"en": "(no commits)", "de": "(keine Commits)"},
"info_upstream": {"en": "Upstream", "de": "Upstream"},
"info_delta": {"en": "{a} ahead / {b} behind",
"de": "{a} voraus / {b} zurück"},
"info_worktree": {"en": "Working tree", "de": "Arbeitsbaum"},
"info_clean": {"en": "clean", "de": "sauber"},
"info_changes": {
"en": "M:{m} · D:{d} · U:{u} · conflicts:{c}",
"de": "M:{m} · D:{d} · U:{u} · Konflikte:{c}"},
"info_stashes": {"en": "Stashes", "de": "Stashes"},
"info_tags": {"en": "Tags at HEAD", "de": "Tags an HEAD"},
"info_remotes": {"en": "Remotes", "de": "Remotes"},
"info_sync": {"en": "sync", "de": "Sync"},
"info_github": {"en": "GitHub", "de": "GitHub"},
"info_unsafe_remote": {
"en": "fetch/push targets differ",
"de": "Fetch-/Push-Ziele weichen ab"},
"info_fetch_url": {"en": "fetch", "de": "Fetch"},
"info_push_url": {"en": "push", "de": "Push"},
"info_fetch_push_url": {"en": "fetch+push", "de": "Fetch+Push"},
"info_web_url": {"en": "web", "de": "Web"},
"info_branch_label": {"en": "branch {b}", "de": "Branch {b}"},
"info_branch_missing_value": {"en": "not on this remote",
"de": "nicht auf diesem Remote"},
"info_last_error": {"en": "Last error", "de": "Letzter Fehler"},
"info_git_said": {"en": "Git said", "de": "Git sagte"},
# Branch-Abschnitt der Info-Seite
"info_branches": {"en": "Local branches", "de": "Lokale Branches"},
"info_branch_current": {"en": "current", "de": "aktuell"},
"info_branch_merged": {"en": "merged", "de": "gemergt"},
"info_branch_upstream_gone": {"en": "upstream gone", "de": "Upstream weg"},
"info_branch_commit": {"en": "commit", "de": "Commit"},
"info_remote_error": {
"en": "Remote details unavailable: {e}",
"de": "Remote-Details nicht verfügbar: {e}"},
"info_fetch_failed": {"en": "last fetch failed", "de": "letzter Fetch fehlgeschlagen"},
# Info-Ansicht: Navigation und Remote-Aktionen
"info_footer_nav": {
"en": " ↑/↓ or Tab select remote/branch · PgUp/PgDn scroll · Q/Esc close",
"de": " ↑/↓ oder Tab Remote/Branch wählen · Bild↑/Bild↓ scrollen · Q/Esc schließen"},
"info_footer_actions": {
"en": " T test remote (does it still exist?) · X remove remote (local config only)",
"de": " T Remote prüfen (existiert es noch?) · X Remote entfernen (nur lokale Config)"},
"info_footer_actions_branch": {
"en": " X delete branch (only if merged; commits stay reachable)",
"de": " X Branch löschen (nur wenn gemergt; Commits bleiben erreichbar)"},
"info_no_remotes": {"en": "This repository has no remote.",
"de": "Dieses Repo hat kein Remote."},
"info_nothing_selected": {"en": "Nothing selected.", "de": "Nichts ausgewählt."},
"info_check_remote_only": {"en": "T tests remotes; a branch is local anyway.",
"de": "T prüft Remotes; ein Branch ist ohnehin lokal."},
# Branch löschen (X auf einem Branch)
"branch_delete_title": {"en": "Delete branch · {b}", "de": "Branch löschen · {b}"},
"branch_is_current": {"en": "{b} is the current branch — switch branches first.",
"de": "{b} ist der aktuelle Branch — erst wechseln."},
"branch_not_merged": {
"en": "{b} is not merged into HEAD; gmf deletes merged branches only "
"(terminal: git branch -D {b}).",
"de": "{b} ist nicht in HEAD gemergt; gmf löscht nur gemergte Branches "
"(Terminal: git branch -D {b})."},
"branch_effect_pointer": {
"en": "· only the branch pointer {b} disappears from .git/config and refs",
"de": "· es verschwindet nur der Branch-Zeiger {b} aus Config und Refs"},
"branch_effect_merged": {
"en": "· its commits are already in HEAD, so nothing is lost",
"de": "· seine Commits stecken schon in HEAD, es geht also nichts verloren"},
"branch_effect_remote": {
"en": "· a branch of the same name on a remote is NOT touched",
"de": "· ein gleichnamiger Branch auf einem Remote bleibt unberührt"},
"branch_effect_safe": {
"en": "· files, stashes and other branches stay untouched",
"de": "· Dateien, Stashes und andere Branches bleiben unberührt"},
"branch_delete_confirm": {"en": "Delete branch {b} now?",
"de": "Branch {b} jetzt löschen?"},
"branch_deleted": {"en": "Deleted branch {b} (was {oid}).",
"de": "Branch {b} gelöscht (war {oid})."},
"branch_delete_failed": {"en": "Deleting {b} failed: {e}",
"de": "Löschen von {b} fehlgeschlagen: {e}"},
"branch_delete_cancelled": {"en": "No branch was deleted.",
"de": "Es wurde kein Branch gelöscht."},
# Remote prüfen (T)
"check_running": {"en": "Testing {r} …", "de": "Prüfe {r} …"},
"check_ok": {"en": "{r} exists and answers ({n} branch(es) there).",
"de": "{r} existiert und antwortet ({n} Branch(es) dort)."},
"check_empty": {"en": "{r} answers but has no branches yet (empty repository).",
"de": "{r} antwortet, hat aber noch keine Branches (leeres Repo)."},
"check_gone": {
"en": "{r}: reachable, but no repository there (or no access).",
"de": "{r}: erreichbar, aber dort kein Repo (oder kein Zugriff)."},
"check_auth": {"en": "{r}: server wants a login (credential helper or SSH key missing).",
"de": "{r}: Server verlangt einen Login (Credential-Helper/SSH-Key fehlt)."},
"check_nokeychain": {
"en": ("{r}: not measurable from this session — the credential helper reads the "
"login keychain, which only the GUI session can open. The login itself is "
"fine; check it with the GUI session of that machine."),
"de": ("{r}: aus dieser Sitzung nicht messbar — der Credential-Helper liest den "
"Login-Schlüsselbund, und den öffnet nur die GUI-Sitzung. Der Login selbst "
"ist in Ordnung; prüfen in der GUI-Sitzung des Rechners.")},
"check_hostkey": {
"en": "{r}: host key unknown or changed — connect once in a terminal.",
"de": "{r}: Hostschlüssel unbekannt/geändert — einmal im Terminal verbinden."},
"check_dns": {"en": "{r}: host name does not resolve (no network or DNS).",
"de": "{r}: Hostname nicht auflösbar (kein Netz oder DNS)."},
"check_unreachable": {
"en": "{r}: no connection — offline, firewall, or server down.",
"de": "{r}: keine Verbindung — offline, Firewall oder Server aus."},
"check_server": {
"en": "{r}: server error there — their problem, not your repository.",
"de": "{r}: Serverfehler dort — deren Problem, nicht dein Repo."},
"check_timeout": {"en": "{r}: no answer within {s}s — network or server too slow.",
"de": "{r}: keine Antwort in {s}s — Netz oder Server zu langsam."},
"check_unknown": {"en": "{r}: unclear result — {e}", "de": "{r}: unklares Ergebnis — {e}"},
# Stichworte für die Repo-Zeile (der ganze Satz steht auf der Info-Seite)
"short_gone": {"en": "repository gone", "de": "Repo weg"},
"short_auth": {"en": "login missing", "de": "Login fehlt"},
"short_nokeychain": {"en": "keychain unavailable", "de": "Schlüsselbund unerreichbar"},
"short_hostkey": {"en": "host key unknown", "de": "Hostschlüssel unbekannt"},
"short_dns": {"en": "host not found", "de": "Host nicht gefunden"},
"short_unreachable": {"en": "no connection", "de": "keine Verbindung"},
"short_server": {"en": "server error", "de": "Serverfehler"},
"short_timeout": {"en": "no answer", "de": "keine Antwort"},
"short_unknown": {"en": "fetch failed", "de": "Fetch fehlgeschlagen"},
# Remote entfernen (X)
"remove_title": {"en": "Remove remote · {r}", "de": "Remote entfernen · {r}"},
"remove_what_happens": {"en": "What this does:", "de": "Was dabei passiert:"},
"remove_effect_config": {
"en": "· the [remote \"{r}\"] section disappears from .git/config",
"de": "· der Abschnitt [remote \"{r}\"] verschwindet aus .git/config"},
"remove_effect_refs": {
"en": "· the remote-tracking branches refs/remotes/{r}/* are deleted",
"de": "· die Remote-Tracking-Branches refs/remotes/{r}/* werden gelöscht"},
"remove_effect_upstream": {
"en": "· a local branch tracking {r} loses its upstream setting",
"de": "· ein lokaler Branch mit Upstream auf {r} verliert diese Verknüpfung"},
"remove_effect_safe": {
"en": "· commits, files, branches and stashes stay untouched — nothing is sent",
"de": "· Commits, Dateien, Branches und Stashes bleiben unberührt — nichts wird gesendet"},
"remove_effect_server": {
"en": "· nothing changes on the server; this is purely local",
"de": "· auf dem Server ändert sich nichts; das ist rein lokal"},
"remove_undo": {"en": "Undo (restore the local configuration):",
"de": "Rückgängig (lokale Konfiguration wiederherstellen):"},
"remove_command": {"en": "Command:", "de": "Befehl:"},
# Änderungen verwerfen (V in der Änderungsansicht)
"discard_title": {"en": "Discard changes · {p}",
"de": "Änderungen verwerfen · {p}"},
"discard_effect_restore": {
"en": "· the file goes back to the state of the last commit",
"de": "· die Datei geht auf den Stand des letzten Commits zurück"},
"discard_effect_unstage": {
"en": "· this file is in no commit yet — there is no earlier state",
"de": "· diese Datei steht in keinem Commit — einen früheren Stand gibt es nicht"},
"discard_effect_stays": {
"en": "· it only loses its staging and stays on disk as an untracked file",
"de": "· sie verliert nur die Vormerkung und bleibt als unverfolgte Datei liegen"},
"discard_effect_history": {
"en": "· committed history is untouched; only the uncommitted change is lost",
"de": "· die Historie bleibt unberührt; verloren geht nur die nicht committete Änderung"},
"discard_extent": {"en": "· extent: {n} changed line(s)",
"de": "· Umfang: {n} geänderte Zeile(n)"},
"discard_no_undo": {
"en": "No undo: what is discarded here cannot be brought back.",
"de": "Kein Rückgängig: Was hier verworfen wird, kommt nicht zurück."},
"discard_offer_all": {
"en": "A = put all {n} changed files into a stash instead (can be brought back)",
"de": "A = stattdessen alle {n} geänderten Dateien in einen Stash (holbar)"},
"discard_confirm": {"en": "Discard the changes in '{p}'?",
"de": "Änderungen in '{p}' verwerfen?"},
"discard_unstage_confirm": {"en": "Remove '{p}' from the staged files?",
"de": "'{p}' aus den vorgemerkten Dateien nehmen?"},
"discard_cancelled": {"en": "Cancelled — nothing discarded.",
"de": "Abgebrochen — nichts verworfen."},
"discard_done": {"en": "Discarded: {p}", "de": "Verworfen: {p}"},
"discard_unstage_done": {"en": "No longer staged, file kept: {p}",
"de": "Nicht mehr vorgemerkt, Datei bleibt liegen: {p}"},
"discard_failed": {"en": "Discarding failed: {e}",
"de": "Verwerfen fehlgeschlagen: {e}"},
"discard_refused_untracked": {
"en": "Untracked file — it was never in Git, so there is no earlier state to "
"go back to. Delete it yourself or put it in .gitignore.",
"de": "Unverfolgte Datei — sie war nie in Git, es gibt keinen früheren Stand. "
"Selbst löschen oder in .gitignore aufnehmen."},
"discard_refused_conflict": {
"en": "Merge conflict — resolve it first; gmf discards nothing here.",
"de": "Merge-Konflikt — erst auflösen; gmf verwirft hier nichts."},
"discard_refused_rename": {
"en": "Renamed file — the new and the old name belong together, and gmf does "
"not discard half a rename.",
"de": "Umbenannte Datei — neuer und alter Name gehören zusammen, und eine "
"halbe Umbenennung verwirft gmf nicht."},
# Alle Änderungen eines Repos (zweite Stufe desselben Dialogs)
"discard_all_title": {"en": "Discard all changes · {rel}",
"de": "Alle Änderungen verwerfen · {rel}"},
"discard_all_effect_stash": {
"en": "· all {n} changed file(s) go into a stash, not into the bin",
"de": "· alle {n} geänderten Dateien wandern in einen Stash, nicht in den Müll"},
"discard_all_effect_tree": {
"en": "· the working tree returns to the state of the last commit",
"de": "· der Arbeitsbaum geht auf den Stand des letzten Commits zurück"},
"discard_all_effect_untracked": {
"en": "· untracked files stay where they are",
"de": "· unverfolgte Dateien bleiben liegen"},
"discard_all_effect_visible": {
"en": "· the stash stays visible in the list: S shows it, D drops it",
"de": "· der Stash bleibt in der Liste sichtbar: S zeigt ihn, D wirft ihn weg"},
# Ehrlich bleiben: `git stash pop` (ohne --index, wie auch die Taste U)
# schreibt alles in den Arbeitsbaum zurück. Was vorher vorgemerkt war, ist
# danach nicht mehr vorgemerkt.
"discard_all_undo": {
"en": "Undo (brings the contents back, U does the same; the staging is lost):",
"de": "Rückgängig (holt die Inhalte zurück, U tut dasselbe; "
"die Vormerkung geht verloren):"},
"discard_all_confirm": {"en": "Move all changes in '{rel}' into a stash?",
"de": "Alle Änderungen in '{rel}' in einen Stash legen?"},
"discard_all_done": {"en": "All changes stashed in {rel} — U brings them back.",
"de": "Alle Änderungen in {rel} gestasht — U holt sie zurück."},
"discard_all_refused_no_head": {
"en": "This repository has no commit yet — Git cannot stash here.",
"de": "Dieses Repo hat noch keinen Commit — Git kann hier nicht stashen."},
"discard_all_refused_only_untracked": {
"en": "Only untracked files here — gmf discards none of those.",
"de": "Hier liegen nur unverfolgte Dateien — davon verwirft gmf keine."},
"discard_all_refused_conflict": {
"en": "Merge conflict — resolve it first; gmf discards nothing here.",
"de": "Merge-Konflikt — erst auflösen; gmf verwirft hier nichts."},
# Sicherheitszusage der destruktiven Dialoge: der auszuführende Befehl muss im
# Moment der Bestätigung sichtbar sein. Passt er nicht mehr aufs Fenster,
# wird die Aktion verweigert statt blind bestätigt.
"dialog_too_small": {
"en": "Window is too small to show this confirmation safely — enlarge it and retry.",
"de": "Fenster zu klein, um diese Bestätigung sicher zu zeigen — vergrößern und erneut versuchen."},
"remove_sync_warning": {
"en": "Careful: {r} is the sync remote here — P and L stop working for this repo.",
"de": "Achtung: {r} ist hier der Sync-Remote — P und L funktionieren danach nicht mehr."},
"remove_confirm": {"en": "Remove remote {r} now?", "de": "Remote {r} jetzt entfernen?"},
"remove_done": {"en": "Removed remote {r}.", "de": "Remote {r} entfernt."},
"remove_failed": {"en": "Removing {r} failed (Git exit code {code}).",
"de": "Entfernen von {r} fehlgeschlagen (Git-Exit-Code {code})."},
"remove_cancelled": {"en": "Nothing was removed.", "de": "Es wurde nichts entfernt."},
# Befehlsprotokoll
"cmdlog_title": {"en": "Commands this session ran",
"de": "In dieser Sitzung ausgeführte Befehle"},
"cmdlog_cancelled": {"en": "not run — cancelled", "de": "nicht ausgeführt — abgebrochen"},
"cmdlog_empty": {
"en": "(none yet — actions like C, P, L, G, U, D, X and Z are listed here)",
"de": "(noch keine — Aktionen wie C, P, L, G, U, D, X und Z stehen hier)"},
"cmdlog_hint": {
"en": "Every line is a real Git command; you can run it in a terminal yourself.",
"de": "Jede Zeile ist ein echter Git-Befehl; genauso im Terminal ausführbar."},
# main
"not_a_dir": {"en": "Not a directory: {p}", "de": "Kein Ordner: {p}"},
"git_timeout": {"en": "git timeout", "de": "git-Timeout"},
"action_timeout": {
"en": "git {cmd} took longer than {s}s and was cancelled "
"(slow pre-commit hook or slow network?).",
"de": "git {cmd} brauchte länger als {s}s und wurde abgebrochen "
"(langsamer pre-commit-Hook oder langsames Netz?)."},
"demo_built": {"en": "Demo sandbox: {p}\n(fake repos; delete the folder when done)",
"de": "Demo-Sandbox: {p}\n(Fake-Repos; Ordner danach löschen)"},
}
def t(key: str, **kw) -> str:
entry = TR.get(key, {})
s = entry.get(UI_LANG) or entry.get("en") or key
return s.format(**kw) if kw else s
def resolve_lang(cfg: dict, override: str | None = None) -> str:
if override in ("en", "de"):
return override
v = (cfg.get("lang") or "").lower()
if v in ("en", "de"):
return v
env = (os.environ.get("LC_ALL") or os.environ.get("LANG") or "").lower()
return "de" if env.startswith("de") else "en"
# ---------------------------------------------------------------------------
# Konfiguration
# ---------------------------------------------------------------------------
def load_config() -> dict:
"""Config laden; fehlt sie, mit Defaults anlegen (selbsterklärender Start)."""
cfg = json.loads(json.dumps(DEFAULT_CONFIG)) # tiefe Kopie
if CONFIG_PATH.exists():
try:
cfg.update(json.loads(CONFIG_PATH.read_text()))
except (json.JSONDecodeError, OSError) as exc:
print(f"Warning: cannot read {CONFIG_PATH} ({exc}) — using defaults.",
file=sys.stderr)
else:
CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
CONFIG_PATH.write_text(json.dumps(DEFAULT_CONFIG, indent=2, ensure_ascii=False) + "\n")
# App-Tasten intern immer groß (Tastendruck wird ebenfalls großgezogen).
cfg["apps"] = {k.upper(): v for k, v in cfg.get("apps", {}).items()}
return cfg
# ---------------------------------------------------------------------------
# Git-Datensammlung (reine Logik, testbar)
# ---------------------------------------------------------------------------
@dataclass
class RepoStatus:
path: Path
rel: str # Pfad relativ zum Scan-Start (Anzeigename)
branch: str = "?"
remote: str | None = None # Name des erkannten Sync-Remotes (z.B. origin)
remote_state: str = "ok" # ok | no-remote | no-branch | detached | error
ahead: int = 0
behind: int = 0
# Zusatz-Info: Stand gegenüber dem *konfigurierten Upstream*, falls das ein
# ANDERER Remote als der Sync-Remote ist (typisch: github). So werden Commits
# sichtbar, die zwar auf dem Sync-Remote, aber nie z.B. zu GitHub gepusht wurden.
upstream: str | None = None # z.B. "github/main"
upstream_ahead: int = 0
upstream_behind: int = 0
remotes: list = field(default_factory=list) # RemoteStatus, GitHub immer zuletzt
modified: int = 0
deleted: int = 0
untracked: int = 0
conflicts: int = 0 # ungemergte Dateien (Merge-Konflikt, z.B. nach stash pop)
files: list[ChangedFile] = field(default_factory=list)
stashes: list = field(default_factory=list) # ["stash@{0} WIP ...", ...]
error: str = ""
# Die Repo-Zeile bekommt das Stichwort (`error`), die Info-Seite den ganzen
# Satz (`error_long`) und Gits eigenen Wortlaut als Beweis (`error_detail`).
error_long: str = ""
error_detail: str = ""
# Herkunft des Fehlers: True = ein Fetch übers Netz schlug fehl. Nur solche
# Fehler überleben einen lokalen Refresh (carry_fetch_failure) — ein lokaler
# Lesefehler wird dagegen bei jedem Refresh neu festgestellt oder ist weg.
fetch_error: bool = False
@property
def dirty(self) -> bool:
return bool(self.modified or self.deleted or self.untracked or self.conflicts)
@property
def clean_and_synced(self) -> bool:
return (not self.dirty and not self.stashes and self.ahead == 0
and self.behind == 0 and self.remote_state == "ok")
def severity(self) -> int:
"""Sortierschlüssel: Problematisches nach oben."""
if self.error:
return 0
if self.dirty or self.stashes:
return 1
if self.ahead or self.behind:
return 2
if self.remote_state != "ok":
return 3
return 4
@dataclass
class RemoteStatus:
"""Anzeigezustand eines Remotes für den aktuellen Branch.
URLs bleiben absichtlich aus UI/JSON heraus. `public` wird ausschließlich aus
der URL-Klasse abgeleitet; dadurch kann auch ein Remote namens `origin`
verständlich und mit der GitHub-Sicherheitsstufe behandelt werden.
"""
name: str
public: bool = False
mixed_public: bool = False
is_sync: bool = False
branch_exists: bool = False
ahead: int = 0
behind: int = 0
fetch_fingerprint: str = ""
push_fingerprints: list[str] = field(default_factory=list)
target_mismatch: bool = False
multiple_pushurls: bool = False
fetch_failed: bool = False
@property
def transfer_safe(self) -> bool:
return not (self.mixed_public or self.target_mismatch or self.multiple_pushurls)
def badge(self) -> str:
arrows = ""
if self.ahead:
arrows += f"↑{self.ahead}"
if self.behind:
arrows += f"↓{self.behind}"
if not self.branch_exists:
arrows = "?"
if self.fetch_failed:
# ✘ heißt: der Stand daneben ist der letzte bekannte, nicht der aktuelle.
arrows = f"✘{arrows}" if arrows else "✘"
return f"{arrows} {self.name}" if arrows else self.name
@dataclass
class TransferCheck:
"""Deterministischer Preflight für genau einen Branch und einen Remote."""
reason: str
ahead: int = 0
behind: int = 0
remote_ref: str = ""
commits: list[str] = field(default_factory=list)
files: list[str] = field(default_factory=list)
branch: str = ""
head_oid: str = ""
index_oid: str = ""
worktree_fingerprint: str = ""
fetch_fingerprint: str = ""
push_fingerprint: str = ""
target_oid: str = ""
@property
def ready(self) -> bool:
return self.reason == "ready"
def approval_signature(self) -> tuple:
return (self.branch, self.head_oid, self.index_oid, self.worktree_fingerprint,
self.fetch_fingerprint, self.push_fingerprint, self.target_oid,
tuple(self.commits), tuple(self.files), self.ahead, self.behind)
@dataclass
class BranchInfo:
"""Ein lokaler Branch — der zweite Zustand, den Git nie überträgt und niemand sieht."""
name: str
is_head: bool = False
upstream: str = ""
ahead: int = 0
behind: int = 0
upstream_gone: bool = False # Upstream war da, ist auf dem Remote aber weg
oid: str = ""
date: str = ""
subject: str = ""
merged: bool = False # vollständig in HEAD enthalten
@dataclass(frozen=True)
class RemoteTarget:
host: str
repo_id: str
fingerprint: str
@property
def is_github(self) -> bool:
"""Nur der exakte Host github.com bekommt die Public-Push-Klassifikation.
Zentrale Stelle für diese Entscheidung: Produktionscode (Badges,
Web-URLs) und der Helfer is_github_url() laufen beide hierüber.
"""
return self.host == "github.com"
@dataclass
class RemoteConfig:
name: str
fetch_urls: list[str]
push_urls: list[str]
fetch_targets: list[RemoteTarget]
push_targets: list[RemoteTarget]
@property
def transfer_safe(self) -> bool:
return (len(self.fetch_targets) == 1 and len(self.push_targets) == 1
and self.fetch_targets[0] == self.push_targets[0])
# Zwei-Buchstaben-Codes, die einen ungemergten Zustand (Merge-Konflikt) bedeuten.
# git status meldet solche Dateien z.B. nach einem `stash pop` mit Konflikt.
UNMERGED_CODES = {"DD", "AU", "UD", "UA", "DU", "AA", "UU"}
class ChangedFile(NamedTuple):
"""Eine geänderte Datei — einmal fürs Auge, einmal für Git.
``code`` ist die Vereinfachung für die Anzeige (M/D/U/C, siehe
parse_porcelain). ``xy`` ist das rohe Statusfeld von ``git status
--porcelain``: erstes Zeichen der Index (was gestaget ist), zweites Zeichen
der Arbeitsbaum (was daneben noch geändert ist). Erst daran ist erkennbar,
ob eine Änderung nur im Arbeitsbaum liegt (`` M``), nur im Index (``M ``)
oder in beiden (``MM``) — und ob es eine neu hinzugefügte Datei (``A ``) ist,
für die es gar keinen früheren Stand gibt. Ohne diese Unterscheidung lässt
sich nicht sagen, was ein Zurücksetzen der Datei überhaupt bedeutet.
"""
code: str
path: str
xy: str
def parse_porcelain(output: str) -> tuple[int, int, int, int, list[ChangedFile]]:
"""NUL-getrenntes ``git status --porcelain=v1 -z`` auswerten.
-> (modified, deleted, untracked, conflicts, dateien).
Vereinfachung fürs Auge: Konflikt = C, Untracked = U, Gelöschtes = D, jede
andere Änderung (modified/added/renamed/…) = M. Konflikte werden ZUERST
geprüft, sonst würde z.B. `UD` fälschlich als Löschung zählen.
``-z`` ist für die Commit-Hilfe entscheidend: Ohne diese Option setzt Git
Pfade mit Umlauten oder Steuerzeichen in Anführungszeichen und maskiert sie.
Diese Anzeigeform ist kein gültiger Pfad für ein späteres ``git add``.
Rename-/Copy-Einträge besitzen bei ``-z`` ein zweites Feld mit dem alten
Namen. Ein Rename ist Ziel UND Quelle: der Zielpfad erscheint als ``M``, der
Quellpfad zusätzlich als ``D`` — sonst würde die Commit-Hilfe nur den
Zielpfad stagen, den Rename als Kopie committen und die Löschung des alten
Namens bliebe im Repo zurück. Bei einer Kopie (``C``) bleibt die Quelle
unverändert und bekommt keinen Eintrag.
Beide Hälften eines Renames tragen dasselbe rohe ``xy`` (also ``R…``). Nur
daran ist später erkennbar, dass sie zusammengehören: Wer eine der beiden
Hälften allein zurücksetzt, lässt die halbe Umbenennung im Repo stehen.
"""
m = d = u = c = 0
files: list[ChangedFile] = []
fields = output.split("\0")
i = 0
while i < len(fields):
record = fields[i]
i += 1
if not record:
continue
xy, path = record[:2], record[3:]
source = None
if "R" in xy or "C" in xy:
# Bei -z folgt nach dem Zielpfad noch der Quellpfad.
source = fields[i] if i < len(fields) else None
i += 1
if xy in UNMERGED_CODES:
c += 1
files.append(ChangedFile("C", path, xy))
elif xy == "??":
u += 1
files.append(ChangedFile("U", path, xy))
elif "D" in xy:
d += 1
files.append(ChangedFile("D", path, xy))
else:
m += 1
files.append(ChangedFile("M", path, xy))
if source and "R" in xy:
d += 1
files.append(ChangedFile("D", source, xy))
return m, d, u, c, files
class DiscardPlan(NamedTuple):
"""Wie eine Änderung zurückgenommen wird — oder warum gmf es ablehnt.
``args`` sind die Git-Argumente ohne ``git`` selbst; bei einer Ablehnung
sind sie leer und ``refused`` nennt den Grund (Schlüssel für die Meldung).
``kind`` sagt dem Dialog, welcher Fall vorliegt, damit er die Folgen richtig
beschreibt — „zurück auf den letzten Commit" ist etwas anderes als „bleibt
liegen, nur nicht mehr vorgemerkt".
"""
args: tuple[str, ...] = ()
kind: str = ""
refused: str = ""
def plan_discard(entry: ChangedFile, has_head: bool) -> DiscardPlan:
"""Für eine einzelne Datei entscheiden, was Verwerfen hier bedeutet.
``has_head`` sagt, ob das Repo überhaupt schon einen Commit hat (siehe