fix(lib): cases where doom/bumpify-diff fails

...to crawl the package! forms in the magit diff buffer.
This commit is contained in:
Henrik Lissner 2022-03-31 19:11:23 +02:00
parent da1eb4d107
commit 1f0b74a7c5
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -208,6 +208,7 @@ Must be run from a magit diff buffer."
(magit-diff-staged)
(unless (eq major-mode 'magit-diff-mode)
(user-error "Not in a magit diff buffer"))
(goto-char (point-min))
(let (targets lines)
(save-excursion
(while (re-search-forward "^modified +\\(.+\\)$" nil t)
@ -216,26 +217,26 @@ Must be run from a magit diff buffer."
(while (re-search-forward "^-" nil t)
(let ((file (magit-file-at-point))
before after)
(save-window-excursion
(call-interactively #'magit-diff-visit-file)
(or (looking-at-p "(package!")
(re-search-forward "(package! " (line-end-position) t)
(re-search-backward "(package! "))
(let ((buffer-file-name file))
(cl-destructuring-bind (&key package plist _beg _end)
(doom--package-at-point)
(setq before (doom--package-to-bump-string package plist)))))
(re-search-forward "^+")
(save-window-excursion
(call-interactively #'magit-diff-visit-file)
(or (looking-at-p "(package!")
(re-search-forward "(package! " (line-end-position) t)
(re-search-backward "(package! "))
(let ((buffer-file-name file))
(cl-destructuring-bind (&key package plist _beg _end)
(doom--package-at-point)
(setq after (doom--package-to-bump-string package plist)))))
(cl-pushnew (format "%s -> %s" before after) lines)))
(and (save-window-excursion
(call-interactively #'magit-diff-visit-file)
(when (or (looking-at-p "(package!")
(re-search-forward "(package! " (line-end-position) t)
(re-search-backward "(package! " nil t))
(let ((buffer-file-name file))
(cl-destructuring-bind (&key package plist _beg _end)
(doom--package-at-point)
(setq before (doom--package-to-bump-string package plist))))))
(re-search-forward "^+" nil t)
(save-window-excursion
(call-interactively #'magit-diff-visit-file)
(or (looking-at-p "(package!")
(re-search-forward "(package! " (line-end-position) t)
(re-search-backward "(package! "))
(let ((buffer-file-name file))
(cl-destructuring-bind (&key package plist _beg _end)
(doom--package-at-point)
(setq after (doom--package-to-bump-string package plist)))))
(cl-pushnew (format "%s -> %s" before after) lines))))
(if (null lines)
(user-error "No bumps to bumpify")
(prog1 (funcall (if interactive #'kill-new #'identity)