Skip to content

Commit

Permalink
[wip] show repo
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Sep 28, 2023
1 parent bb8b431 commit 1ac6a83
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lisp/forge-notify.el
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
(if (eq forge-notifications-display-style 'flat)
(magit-insert-section-body
(dolist (notif notifs)
(forge-insert-notification notif width))
(forge-insert-notification notif width t))
(insert ?\n))
(pcase-dolist (`(,_ . ,notifs)
(--group-by (oref it repository) notifs))
Expand All @@ -188,11 +188,11 @@
(forge-insert-notification notif width))
(insert ?\n))))))))))

(defun forge-insert-notification (notif width)
(defun forge-insert-notification (notif width show-repo)
(with-slots (type topic title url unread-p) notif
(pcase type
((or 'issue 'pullreq)
(forge-insert-topic (forge-get-topic notif) nil width))
(forge-insert-topic (forge-get-topic notif) nil width nil show-repo))
('commit
(magit-insert-section (ncommit nil) ; !commit
(string-match "[^/]*\\'" url)
Expand Down
2 changes: 1 addition & 1 deletion lisp/forge-pullreq.el
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Also see option `forge-topic-list-limit'."
(magit-make-margin-overlay nil t))))))

(cl-defmethod forge--insert-topic-contents :after ((pullreq forge-pullreq)
_width _prefix)
&rest _ignored)
(unless (oref pullreq merged)
(magit-insert-heading)
(forge--insert-pullreq-commits pullreq)))
Expand Down
2 changes: 2 additions & 0 deletions lisp/forge-repo.el
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ an error."
If there is no such repository and DEMAND is non-nil, then signal
an error."
(or (magit-section-value-if 'forge-repo)
(and-let* ((topic (forge-topic-at-point nil 'not-thingatpt)))
(forge-get-repository topic))
(and (derived-mode-p 'forge-repository-list-mode)
(forge-get-repository :id (tabulated-list-get-id)))
(and demand (user-error "No repository at point"))))
Expand Down
14 changes: 10 additions & 4 deletions lisp/forge-topic.el
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ implement such a function themselves. See #447.")
(insert ?\n)
(magit-make-margin-overlay nil t))))))

(defun forge-insert-topic (topic &optional topic-section-type width prefix)
(defun forge-insert-topic ( topic
&optional topic-section-type width prefix show-repo)
"Insert TOPIC as a new section.
If TOPIC-SECTION-TYPE is provided, it is the section type to use.
If WIDTH is provided, it is a fixed width to use for the topic
Expand All @@ -339,7 +340,7 @@ identifier."
(cond ((forge--childp topic 'forge-issue) 'issue)
((forge--childp topic 'forge-pullreq) 'pullreq))))
(magit-insert-section ((eval topic-section-type) topic t)
(forge--insert-topic-contents topic width prefix)))
(forge--insert-topic-contents topic width prefix show-repo)))

(cl-defmethod forge--format-topic-id ((topic forge-topic) &optional prefix)
(propertize (format "%s%s"
Expand All @@ -354,9 +355,14 @@ identifier."
(cl-defmethod forge--topic-type-prefix ((_repo forge-repository) _type)
"#")

(cl-defmethod forge--insert-topic-contents ((topic forge-topic) width prefix)
(cl-defmethod forge--insert-topic-contents ((topic forge-topic)
width prefix show-repo)
(with-slots (number title unread-p closed) topic
(insert (format (if width (format "%%-%is" (1+ width)) "%s")
(when show-repo
(let ((repo (forge-get-repository topic)))
(insert
(string-pad (format "%s/%s " (oref repo owner) (oref repo name)) 24))))
(insert (format (if width (format "%%-%is" (1+ width)) "%s%s")
(forge--format-topic-id topic prefix)))
(forge--insert-topic-marks topic)
(insert " ")
Expand Down

0 comments on commit 1ac6a83

Please sign in to comment.