Skip to content

Commit

Permalink
Fix empty user name error (#47)
Browse files Browse the repository at this point in the history
* Fix empty user name error

* Fix linter error, simplify conditional
  • Loading branch information
ax487 authored May 9, 2023
1 parent 3d9d12f commit 3d1fae9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion blamer.el
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,11 @@ LOCAL-TYPE is force replacement of current `blamer-type' for handle rendering."
(remove-hook 'post-command-hook #'blamer--try-render t)
(remove-hook 'window-state-change-hook #'blamer--try-render t))

(defun blamer--get-user-name ()
"Query git config for user name."
(when-let ((command-output (apply #'vc-git--run-command-string nil blamer--git-author-cmd)))
(replace-regexp-in-string "\n\\'" "" command-output)))

;;;###autoload
(define-minor-mode blamer-mode
"Blamer mode.
Expand All @@ -1014,7 +1019,7 @@ will appear after BLAMER-IDLE-TIME. It works only inside git repo"
(when (and (not blamer--current-author)
blamer-author-formatter
is-git-repo)
(setq-local blamer--current-author (replace-regexp-in-string "\n\\'" "" (apply #'vc-git--run-command-string nil blamer--git-author-cmd))))
(setq-local blamer--current-author (blamer--get-user-name)))
(when (and (buffer-file-name) is-git-repo)
(if blamer-mode
(progn
Expand Down

0 comments on commit 3d1fae9

Please sign in to comment.