Jelajahi Sumber

chore: check repo dir exists in git/add-all

Yukun Guo 5 tahun lalu
induk
melakukan
9c0dabb3de
1 mengubah file dengan 8 tambahan dan 0 penghapusan
  1. 8 0
      src/main/frontend/git.cljs

+ 8 - 0
src/main/frontend/git.cljs

@@ -110,6 +110,14 @@
   "Equivalent to `git add --all`. Returns changed files."
   [repo-url]
   (p/let [repo-dir (util/get-repo-dir repo-url)
+
+          ; statusMatrix will return `[]` rather than raising an error if the repo directory does
+          ; not exist. So checks whether repo-dir exists before proceeding.
+          _ (-> (js/window.pfs.stat repo-dir)
+                (p/catch #(p/rejected (str "Cannot find repo dir '"
+                                           repo-dir
+                                           "' in fs when `git add --all`"))))
+
           status-matrix (js/window.workerThread.statusMatrixChanged repo-dir)
           changed-files (for [[file head work-dir _stage] status-matrix
                               :when (not= head work-dir)]