Fixed defect with single string case for handle-file-paths
authorSaba Saba <saba@sabadev.xyz>
Thu, 9 Feb 2023 17:26:20 +0000 (12:26 -0500)
committerSaba Saba <saba@sabadev.xyz>
Thu, 9 Feb 2023 17:26:20 +0000 (12:26 -0500)
git-repl.cl

index 5124325..4ecca4c 100644 (file)
     collect (ldiff front next)
     while next))
 
-(defun handle-file-paths (arg)
+(defun-public handle-file-paths (arg)
+  "Accepts either a string or a list of strings. Returns a list of strings, each one surrounded by \", chunked in lists of length *file-chunk-length*"
   (typecase arg
-    (string '(add-quotes arg))
+    (string (list (add-quotes arg)))
     (list (mapcar (lambda (x) (str:join " " x)) (chunk-list *file-chunk-length* (mapcar #'add-quotes arg))))
     (t (error "Argument must be either a string or a list of strings."))))
 
-(defun-public update-index (command file-path)
+(defun-public git-chunked-command (command subcommand file-path)
   "Runs the specified command on the filepath or list of filepaths"
-  (mapcar (lambda (x) (git "update-index" command "--" x)) (handle-file-paths file-path)))
+  (mapcar (lambda (x) (git command subcommand "--" x)) (handle-file-paths file-path)))
+
+(defun-public update-index (command file-path)
+  "Runs the specified update-index command on the filepath or list of filepaths"
+  (git-chunked-command "update-index" command file-path))
 
 (defun-public skip-file (file-path)
   "Given a filepath or list of filepaths, skips the specified files"
 
 (defun-public delete-merged-branches ()
   "Deletes every local branch covered by \'git branch --merged\'"
-  (mapcar #'delete-branch (git "branch" "--merged")))
+  (git-chunked-command "branch" "-d" (git "branch" "--merged")))
 
 (defun-public help ()
   "Prints out usage instructions for this REPL"