Skip to content

Commit 9376569

Browse files
committed
Link the repositories
1 parent c726d61 commit 9376569

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

magit-standup.el

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,11 @@ the org link prefix string, or nil for plain text."
151151
(let* ((parts (split-string line "\0"))
152152
(hash (car parts))
153153
(rest (cadr parts)))
154-
(if link-prefix
155-
(concat "[[" link-prefix ":" repo-path "::" hash "][" hash "]]"
156-
" " rest)
157-
(concat hash " " rest))))
154+
(format "%s %s"
155+
(if link-prefix
156+
(format "[[%s:%s::%s][%s]]" link-prefix repo-path hash hash)
157+
hash)
158+
rest)))
158159

159160
(defun magit-standup--collect-commits (repo-path since-date)
160161
"Collect commits from REPO-PATH since SINCE-DATE.
@@ -183,13 +184,13 @@ BRANCH-COMMITS is a cons of (BRANCH-NAME . COMMITS).
183184
LINK-PREFIX is the org link prefix string, or nil for plain text.
184185
Returns nil when BRANCH-COMMITS has no commits."
185186
(when (cdr branch-commits)
186-
(concat "** ~" (car branch-commits) "~\n"
187+
(format "** ~%s~\n%s\n"
188+
(car branch-commits)
187189
(mapconcat
188190
(lambda (c)
189-
(concat "- " (magit-standup--format-commit
190-
repo-path c link-prefix)))
191-
(cdr branch-commits) "\n")
192-
"\n")))
191+
(format "- %s" (magit-standup--format-commit
192+
repo-path c link-prefix)))
193+
(cdr branch-commits) "\n"))))
193194

194195
(defun magit-standup--format-org (repo-commits &optional link-prefix)
195196
"Format REPO-COMMITS as `org-mode' text.
@@ -208,9 +209,9 @@ LINK-PREFIX is the org link prefix string, or nil for plain text."
208209
repo-path bc link-prefix))
209210
(cdr entry)))))
210211
(when formatted
211-
(concat "* " repo-name "\n\n"
212-
(mapconcat #'identity formatted "\n")
213-
"\n"))))
212+
(format "* [[file:%s][%s]]\n\n%s\n"
213+
repo-path repo-name
214+
(mapconcat #'identity formatted "\n")))))
214215
repo-commits))
215216

216217
(defun magit-standup--gather (&optional since-date repos)

test/magit-standup-test.el

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
"def456\0Add feature")))))
188188
nil)
189189
:to-equal
190-
"* my-repo\n\n** ~main~\n- abc123 Fix bug\n- def456 Add feature\n\n"))
190+
"* [[file:/home/user/my-repo][my-repo]]\n\n** ~main~\n- abc123 Fix bug\n- def456 Add feature\n\n"))
191191

192192
(it "omits repos when all branches have no commits"
193193
(expect (magit-standup--format-org
@@ -201,15 +201,15 @@
201201
("stale-branch"))))
202202
nil)
203203
:to-equal
204-
"* my-repo\n\n** ~main~\n- abc Fix thing\n\n"))
204+
"* [[file:/home/user/my-repo][my-repo]]\n\n** ~main~\n- abc Fix thing\n\n"))
205205

206206
(it "shows multiple branches under one repo"
207207
(expect (magit-standup--format-org
208208
'(("/home/user/my-repo" . (("main" . ("abc\0Fix thing"))
209209
("feature" . ("def\0Add thing")))))
210210
nil)
211211
:to-equal
212-
(concat "* my-repo\n\n** ~main~\n- abc Fix thing\n"
212+
(concat "* [[file:/home/user/my-repo][my-repo]]\n\n** ~main~\n- abc Fix thing\n"
213213
"\n** ~feature~\n- def Add thing\n\n")))
214214

215215
(it "separates multiple repos with blank lines"
@@ -218,15 +218,15 @@
218218
("/home/user/repo-b" . (("develop" . ("def\0Other thing")))))
219219
nil)
220220
:to-equal
221-
(concat "* repo-a\n\n** ~main~\n- abc Fix thing\n\n"
222-
"* repo-b\n\n** ~develop~\n- def Other thing\n\n")))
221+
(concat "* [[file:/home/user/repo-a][repo-a]]\n\n** ~main~\n- abc Fix thing\n\n"
222+
"* [[file:/home/user/repo-b][repo-b]]\n\n** ~develop~\n- def Other thing\n\n")))
223223

224224
(it "applies link-prefix to commits"
225225
(expect (magit-standup--format-org
226226
'(("/home/user/my-repo" . (("main" . ("abc\0Fix thing")))))
227227
"orgit-rev")
228228
:to-equal
229-
"* my-repo\n\n** ~main~\n- [[orgit-rev:/home/user/my-repo::abc][abc]] Fix thing\n\n")))
229+
"* [[file:/home/user/my-repo][my-repo]]\n\n** ~main~\n- [[orgit-rev:/home/user/my-repo::abc][abc]] Fix thing\n\n")))
230230

231231
(describe "magit-standup--gather"
232232
(before-each

0 commit comments

Comments
 (0)