Use relative path for commit message
This commit is contained in:
parent
563c1daaf4
commit
d3ddb34bdc
1 changed files with 18 additions and 3 deletions
|
@ -1,8 +1,23 @@
|
|||
(defun git-auto-commit-relative-file-name (filename)
|
||||
"Find the path to the filename relative to the git directory"
|
||||
(let* ((git-dir
|
||||
(replace-regexp-in-string
|
||||
"\n+$" "" (shell-command-to-string
|
||||
"git rev-parse --show-toplevel")))
|
||||
(relative-file-name
|
||||
(replace-regexp-in-string
|
||||
"^/" "" (replace-regexp-in-string
|
||||
git-dir "" filename))))
|
||||
relative-file-name))
|
||||
|
||||
(defun git-auto-commit ()
|
||||
"Commit `buffer-file-name` to git"
|
||||
(let ((filename (buffer-file-name)))
|
||||
(shell-command (concat "git add " filename
|
||||
" && git commit -m '" filename "'"))))
|
||||
(let* ((filename (buffer-file-name))
|
||||
(relative-filename
|
||||
(git-auto-commit-relative-file-name filename)))
|
||||
(shell-command
|
||||
(concat "git add " filename
|
||||
" && git commit -m '" relative-filename "'"))))
|
||||
|
||||
(define-minor-mode git-auto-commit-mode
|
||||
"Automatically commit any changes made when saving with this mode
|
||||
|
|
Loading…
Reference in a new issue