mirror of
https://github.com/NinjaTrappeur/my-repo-pins.git
synced 2024-06-08 14:20:35 +02:00
h--forge-fetchers-state: init all forges state to loading
We introduce the h--init-forges-state function in charge of initializing the forge state and setting all the forges status to loading. It prevents the forge names to gradually pop-up during a forge request and instead display them with their appropriate status.
This commit is contained in:
parent
af0940261c
commit
82543d9e02
19
h-tests.el
19
h-tests.el
|
@ -289,6 +289,25 @@ For reference: a empty test root looks like this:
|
|||
(should (file-exists-p (format "%s/.git" tmpdir)))
|
||||
(delete-directory tmpdir t))))))
|
||||
|
||||
;;; State Management tests
|
||||
|
||||
(ert-deftest h--test-init-forges-state ()
|
||||
"Test the h--init-forges-state function."
|
||||
(let* ((forge-fetchers
|
||||
'(("GitHub.com" .
|
||||
((query-user-repo . h--query-github-owner-repo)))
|
||||
("GitLab.com" .
|
||||
((query-user-repo . (lambda (owner repo cb) (h--query-gitlab-owner-repo "gitlab.com" owner repo cb)))))
|
||||
("git.sr.ht" .
|
||||
((query-user-repo . (lambda (owner repo cb) (h--query-sourcehut-owner-repo "git.sr.ht" owner repo cb)))))
|
||||
("Codeberg.org" .
|
||||
((query-user-repo . (lambda (owner repo cb) (h--query-gitea-owner-repo "codeberg.org" owner repo cb)))))))
|
||||
(result (h--init-forges-state forge-fetchers)))
|
||||
(should (equal (alist-get "GitHub.com" result nil nil 'equal) 'loading))
|
||||
(should (equal (alist-get "GitLab.com" result nil nil 'equal) 'loading))
|
||||
(should (equal (alist-get "git.sr.ht" result nil nil 'equal) 'loading))
|
||||
(should (equal (alist-get "Codeberg.org" result nil nil 'equal) 'loading))))
|
||||
|
||||
;;; UI-related tests
|
||||
|
||||
(ert-deftest h--test-add-keys-to-forge-status ()
|
||||
|
|
10
h.el
10
h.el
|
@ -676,6 +676,14 @@ READ-RESULT)"
|
|||
;; Internal: Internal state management
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun h--init-forges-state (forge-fetchers)
|
||||
"Initialize ‘h--forge-fetchers-state’.
|
||||
|
||||
We iterate through the forges set in FORGE-FETCHERS and associate
|
||||
each of them with a pending status. We then return this new state
|
||||
alist."
|
||||
(seq-map (lambda (e) `(,(car e) . loading)) forge-fetchers))
|
||||
|
||||
(defun h--update-forges-state (forge-name new-state user-query)
|
||||
"Update ‘h--forge-fetchers-state’ for FORGE-NAME with NEW-STATE.
|
||||
|
||||
|
@ -735,7 +743,7 @@ TODO: split that mess before release. We shouldn't query here."
|
|||
"Clone USER-QUERY in its appropriate directory in ‘h-code-root’."
|
||||
(interactive "sGit repository to checkout: ")
|
||||
(progn
|
||||
(setq h--forge-fetchers-state nil)
|
||||
(setq h--forge-fetchers-state (h--init-forges-state h-forge-fetchers))
|
||||
(h--query-forge-fetchers user-query)))
|
||||
|
||||
;;;###autoload
|
||||
|
|
Loading…
Reference in a new issue