From 5d1cbb8b8b6aab9b48da78cdb1ad0bf595a420a5 Mon Sep 17 00:00:00 2001 From: Saba Saba Date: Thu, 9 Feb 2023 12:26:18 -0500 Subject: [PATCH] Added clean-working-directory as a macro to protect against modified files polluting the working directory. Also added documentation. --- git-repl.cl | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/git-repl.cl b/git-repl.cl index 484bd78..db137f0 100644 --- a/git-repl.cl +++ b/git-repl.cl @@ -4,15 +4,21 @@ (in-package :cl-user) +(defvar *grep* "findstr" "The name of the program used for searching. On Windows this is set to \'findstr\', but it may be changed to \'grep\' for Unix systems.") + (defmacro defun-public (name arglist &body body) `(progn (export ',name) (defun ,name ,arglist ,@body))) -(defvar *grep* "findstr") +(defmacro clean-working-directory (&body body) + `(if (null (modified-files)) + (write-line "You have modified files. Please stash or commit your files before proceeding.") + ,@body)) -(defun remove-empty (text) - (remove-if #'str:emptyp text)) +(defun remove-empty (text-lines) + "Removes every empty line from a list of lines of text" + (remove-if #'str:emptyp text-lines)) (defun run-command (command) (remove-empty @@ -62,22 +68,28 @@ (git "stash" "pop")) (defun-public stash-config () - (progn - (no-skip-all) - (save-stash))) + (clean-working-directory + (progn + (no-skip-all) + (save-stash)))) (defun-public pop-config () - (progn - (pop-stash) - (skip-modified))) + "Pops the stash and skips it to store it as your configuration" + (clean-working-directory + (progn + (pop-stash) + (skip-modified)))) (defun-public delete-branch (branch-name) + "Deletes the given local branch name" (git "branch" "-d" branch-name)) (defun-public delete-merged-branches () + "Deletes every local branch covered by \'git branch --merged\'" (mapcar #'delete-branch (git "branch" "--merged"))) (defun-public make (executable-name) + "Compiles the current state into an executable" (progn (load (compile-file "git-repl.cl")) (save-lisp-and-die executable-name :executable t))) -- 2.20.1