aboutsummaryrefslogtreecommitdiff
path: root/tests/test-reconcile--should-skip-p.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-10 02:44:10 -0500
committerCraig Jennings <c@cjennings.net>2026-05-10 02:44:10 -0500
commit5a46d415df75b8b0168e2cf48b30fe463c01a77c (patch)
tree72c1f8d75b2fb4a020a46f4d3b97778ca65fb331 /tests/test-reconcile--should-skip-p.el
parent2afb005af6272b1b4229b377db0423dca045732f (diff)
downloaddotemacs-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/test-reconcile--should-skip-p.el')
-rw-r--r--tests/test-reconcile--should-skip-p.el110
1 files changed, 70 insertions, 40 deletions
diff --git a/tests/test-reconcile--should-skip-p.el b/tests/test-reconcile--should-skip-p.el
index 3e9c0177..8964fd3b 100644
--- a/tests/test-reconcile--should-skip-p.el
+++ b/tests/test-reconcile--should-skip-p.el
@@ -17,50 +17,58 @@
(reconcile-test-with-temp-dirs
("repo/.git/")
(let ((dir (expand-file-name "repo" test-root)))
- (reconcile-test-with-shell-mocks
- (lambda (_cmd) 0)
- (lambda (cmd)
- (if (string-match-p "remote.origin.url" cmd)
- "git@github.com:user/repo.git"
- ""))
- (should-not (cj/reconcile--should-skip-p dir))))))
+ (reconcile-test-with-git-mock
+ (lambda (args)
+ (if (equal args '("config" "--get" "remote.origin.url"))
+ '(:exit 0 :output "git@github.com:user/repo.git\n")
+ '(:exit 0 :output "")))
+ (should-not (cj/reconcile--should-skip-p dir))))))
(ert-deftest test-should-skip-p-normal-http-remote-skipped ()
"HTTP remote repo should be skipped (reference clone)."
(reconcile-test-with-temp-dirs
("repo/.git/")
(let ((dir (expand-file-name "repo" test-root)))
- (reconcile-test-with-shell-mocks
- (lambda (_cmd) 0)
- (lambda (cmd)
- (if (string-match-p "remote.origin.url" cmd)
- "http://github.com/user/repo.git"
- ""))
- (should (cj/reconcile--should-skip-p dir))))))
+ (reconcile-test-with-git-mock
+ (lambda (args)
+ (if (equal args '("config" "--get" "remote.origin.url"))
+ '(:exit 0 :output "http://github.com/user/repo.git\n")
+ '(:exit 0 :output "")))
+ (should (cj/reconcile--should-skip-p dir))))))
(ert-deftest test-should-skip-p-normal-https-remote-skipped ()
"HTTPS remote repo should be skipped (reference clone)."
(reconcile-test-with-temp-dirs
("repo/.git/")
(let ((dir (expand-file-name "repo" test-root)))
- (reconcile-test-with-shell-mocks
- (lambda (_cmd) 0)
- (lambda (cmd)
- (if (string-match-p "remote.origin.url" cmd)
- "https://github.com/user/repo.git"
- ""))
- (should (cj/reconcile--should-skip-p dir))))))
+ (reconcile-test-with-git-mock
+ (lambda (args)
+ (if (equal args '("config" "--get" "remote.origin.url"))
+ '(:exit 0 :output "https://github.com/user/repo.git\n")
+ '(:exit 0 :output "")))
+ (should (cj/reconcile--should-skip-p dir))))))
+
+(ert-deftest test-should-skip-p-normal-https-remote-not-skipped-when-policy-disabled ()
+ "HTTPS remote repos can be included by disabling the skip regexp."
+ (reconcile-test-with-temp-dirs
+ ("repo/.git/")
+ (let ((dir (expand-file-name "repo" test-root))
+ (cj/reconcile-skipped-remote-regexp nil))
+ (reconcile-test-with-git-mock
+ (lambda (args)
+ (if (equal args '("config" "--get" "remote.origin.url"))
+ '(:exit 0 :output "https://github.com/user/repo.git\n")
+ '(:exit 0 :output "")))
+ (should-not (cj/reconcile--should-skip-p dir))))))
(ert-deftest test-should-skip-p-normal-no-remote-skipped ()
"Local-only repo (no remote) should be skipped."
(reconcile-test-with-temp-dirs
("repo/.git/")
(let ((dir (expand-file-name "repo" test-root)))
- (reconcile-test-with-shell-mocks
- (lambda (_cmd) 0)
- (lambda (cmd)
- (if (string-match-p "remote.origin.url" cmd) "" ""))
- (should (cj/reconcile--should-skip-p dir))))))
+ (reconcile-test-with-git-mock
+ (lambda (_args) '(:exit 1 :output ""))
+ (should (cj/reconcile--should-skip-p dir))))))
;;; Boundary Cases
@@ -76,26 +84,48 @@
(reconcile-test-with-temp-dirs
("repo/.git/")
(let ((dir (expand-file-name "repo" test-root)))
- (reconcile-test-with-shell-mocks
- (lambda (_cmd) 0)
- (lambda (cmd)
- (if (string-match-p "remote.origin.url" cmd)
- "user@myserver.com:repos/project.git"
- ""))
- (should-not (cj/reconcile--should-skip-p dir))))))
+ (reconcile-test-with-git-mock
+ (lambda (args)
+ (if (equal args '("config" "--get" "remote.origin.url"))
+ '(:exit 0 :output "user@myserver.com:repos/project.git\n")
+ '(:exit 0 :output "")))
+ (should-not (cj/reconcile--should-skip-p dir))))))
(ert-deftest test-should-skip-p-boundary-ssh-protocol-url-not-skipped ()
"ssh:// protocol URL should NOT be skipped."
(reconcile-test-with-temp-dirs
("repo/.git/")
(let ((dir (expand-file-name "repo" test-root)))
- (reconcile-test-with-shell-mocks
- (lambda (_cmd) 0)
- (lambda (cmd)
- (if (string-match-p "remote.origin.url" cmd)
- "ssh://git@github.com/user/repo.git"
- ""))
- (should-not (cj/reconcile--should-skip-p dir))))))
+ (reconcile-test-with-git-mock
+ (lambda (args)
+ (if (equal args '("config" "--get" "remote.origin.url"))
+ '(:exit 0 :output "ssh://git@github.com/user/repo.git\n")
+ '(:exit 0 :output "")))
+ (should-not (cj/reconcile--should-skip-p dir))))))
+
+(ert-deftest test-should-skip-p-boundary-file-protocol-remote-not-skipped ()
+ "file:// remote repo should NOT be skipped by the default policy."
+ (reconcile-test-with-temp-dirs
+ ("repo/.git/")
+ (let ((dir (expand-file-name "repo" test-root)))
+ (reconcile-test-with-git-mock
+ (lambda (args)
+ (if (equal args '("config" "--get" "remote.origin.url"))
+ '(:exit 0 :output "file:///srv/git/repo.git\n")
+ '(:exit 0 :output "")))
+ (should-not (cj/reconcile--should-skip-p dir))))))
+
+(ert-deftest test-should-skip-p-boundary-local-path-remote-not-skipped ()
+ "Plain local path remote should NOT be skipped by the default policy."
+ (reconcile-test-with-temp-dirs
+ ("repo/.git/")
+ (let ((dir (expand-file-name "repo" test-root)))
+ (reconcile-test-with-git-mock
+ (lambda (args)
+ (if (equal args '("config" "--get" "remote.origin.url"))
+ '(:exit 0 :output "/srv/git/repo.git\n")
+ '(:exit 0 :output "")))
+ (should-not (cj/reconcile--should-skip-p dir))))))
(provide 'test-reconcile--should-skip-p)
;;; test-reconcile--should-skip-p.el ends here