diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-10 02:44:10 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-10 02:44:10 -0500 |
| commit | 5a46d415df75b8b0168e2cf48b30fe463c01a77c (patch) | |
| tree | 72c1f8d75b2fb4a020a46f4d3b97778ca65fb331 /tests/testutil-reconcile-open-repos.el | |
| parent | 2afb005af6272b1b4229b377db0423dca045732f (diff) | |
| download | dotemacs-5a46d415df75b8b0168e2cf48b30fe463c01a77c.tar.gz dotemacs-5a46d415df75b8b0168e2cf48b30fe463c01a77c.zip | |
Make repo reconciliation review-first
Stop automatically stashing, pulling, and popping dirty repos during reconciliation. Clean repos still pull, dirty repos open Magit for review, and results now include structured statuses, skip reasons, pruning, and a summary.
Diffstat (limited to 'tests/testutil-reconcile-open-repos.el')
| -rw-r--r-- | tests/testutil-reconcile-open-repos.el | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/testutil-reconcile-open-repos.el b/tests/testutil-reconcile-open-repos.el index 2d8614eb..b81e1b48 100644 --- a/tests/testutil-reconcile-open-repos.el +++ b/tests/testutil-reconcile-open-repos.el @@ -2,7 +2,7 @@ ;;; Commentary: ;; Provides helper macros and functions for testing reconcile-open-repos. -;; Creates temporary directory trees with fake .git dirs and mocks shell commands. +;; Creates temporary directory trees with fake .git dirs and mocks git commands. ;;; Code: @@ -42,6 +42,36 @@ SHELL-CMD-TO-STR-FN receives (command) and returns a string." (lambda (cmd) (funcall ,shell-cmd-to-str-fn cmd)))) ,@body)) +(defvar reconcile-test-git-calls nil + "List of git argv lists observed during reconcile tests.") + +(defmacro reconcile-test-with-git-mock (handler &rest body) + "Run BODY with `process-file' mocked for git. +HANDLER receives the argv list and returns either an exit code integer or a +plist with :exit and :output." + (declare (indent 1)) + `(let ((reconcile-test-git-calls nil)) + (cl-letf (((symbol-function 'process-file) + (lambda (program _infile destination _display &rest args) + (unless (string= program "git") + (error "Unexpected program: %s" program)) + (push args reconcile-test-git-calls) + (let* ((result (funcall ,handler args)) + (plist-result (and (consp result) (keywordp (car result)))) + (exit (if plist-result (plist-get result :exit) result)) + (output (if plist-result (plist-get result :output) ""))) + (when (and destination output) + (let ((stdout-dest (if (consp destination) + (car destination) + destination))) + (cond + ((bufferp stdout-dest) + (with-current-buffer stdout-dest (insert output))) + ((eq stdout-dest t) + (insert output))))) + exit)))) + ,@body))) + (defvar reconcile-test-magit-calls nil "List of directories passed to magit-status during tests.") |
