From 9360580a9421159406f8f97f010370f686b8839d Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 16 Jul 2024 14:24:30 -0400 Subject: [PATCH] Add Forge diff-for-pr function for pull request creation This commit adds a new function forge-diff-for-pr to generate a Git diff for use in pull request creation. The function is called automatically when creating a pull request using Forge, providing an easy way to view changes between the source and target branches. --- emacs/.emacs.d/config/init-git.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/emacs/.emacs.d/config/init-git.el b/emacs/.emacs.d/config/init-git.el index eb31051..e883876 100644 --- a/emacs/.emacs.d/config/init-git.el +++ b/emacs/.emacs.d/config/init-git.el @@ -70,6 +70,12 @@ (advice-add 'forge-topic-at-point :around (lambda (oldfn &rest args) (ignore-errors (apply oldfn args)))) + (defun forge-diff-for-pr () + (interactive) + (let ((target forge--buffer-base-branch) + (source forge--buffer-head-branch)) + (magit-diff-range (format "%s..%s" source target)))) + (add-hook 'forge-create-pullreq-hook #'forge-diff-for-pr) :custom (forge-owned-accounts '((jdormit . (remote-name "jdormit")))) :general