This repository has been archived by the owner on Dec 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ohl-gitalk.el
44 lines (38 loc) · 1.59 KB
/
ohl-gitalk.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
;;; ohl-gitalk.el --- Gitalk in Org Hugo Lazy -*- lexical-binding: t -*-
;; Author: Fingker Knight <[email protected]>
;; URL: https://github.com/fingerknight/org-hugo-lazy.el
;; Version: 0.0.1
(defvar ohl-gitalk--issue-list nil
"List records all the ISSUEs.
Each ISSUE is a assoc-list. Key is the md5 of relative path of the post.\
Value is the ordered number of Github Issue")
(defun ohl-gitalk--get-issue-list (dir)
"Get all comments(issues) from repo"
(message "[Org Hugo Lazy] Getting Issue List...")
(let* ((cmd-output (shell-command-to-string
(format "cd %s; gh issue list" dir)))
(issue-list (mapcar #'(lambda (each)
(s-split "\t" each))
(cl-subseq (s-lines cmd-output)
0 -1))))
(setq ohl-gitalk--issue-list
(when issue-list
(--map-when
(funcall #'(lambda (label-list)
(and (member "Gitalk" label-list)
(length= label-list 2)))
(s-split-words (nth 3 it)))
(car (remove "Gitalk" (s-split-words (nth 3 it))))
issue-list))))
(message (if ohl-gitalk--issue-list
"Issue list gotten"
"Failed to get issue list")))
(defun ohl-gitalk--git-add-issue (dir title uri id)
"Inital a new issue used to comment"
(when (and ohl-gitalk--issue-list
(not (member id ohl-gitalk--issue-list)))
(let ((cmd-formatter "cd %s; gh label create \"%s\"; gh issue create --title \"%s\" --body \"%s\" --label \"Gitalk,%s\""))
(message "[Org Hugo lazy] Adding new issue: %s, %s" title id)
(message (shell-command-to-string (format cmd-formatter
dir id title uri id))))))
(provide 'ohl-gitalk)