-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgit.lisp
79 lines (65 loc) · 2.7 KB
/
git.lisp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
;;;; git.lisp
(in-package #:quicklisp-controller)
;;; Stuff for automatically committing */source.txt files with
;;; appropriate github messages.
(defun call-in-projects-directory (fun)
(with-posix-cwd
(translate-logical-pathname "quicklisp-controller:projects;")
(funcall fun)))
(defmacro in-projects-directory (&body body)
`(call-in-projects-directory (lambda () ,@body)))
(defun clean-stage-p ()
(in-projects-directory
(null (run-output-lines "git" "status" "--porcelain"
"--untracked-files=no"))))
(defun commit-message (source)
(setf source (source-designator source))
(let ((issue-number (github-issue-number source)))
(unless issue-number
(error "No github issue info for substring ~S" (name source)))
(format nil "Added ~A per issue #~A"
(name source)
issue-number)))
(defun commit-source (source &key commit-message unclean)
(let* ((source (source-designator source))
(file (source-file source))
(message (or commit-message
(commit-message source))))
(unless (or unclean (clean-stage-p))
(cerror "Continue anyway" "Stage isn't clean"))
(in-projects-directory
(run "git" "add" (pathname file))
(run "git" "commit" "-m" message))
(list :committed (name source) :with message)))
(defmacro with-issue-number ((var source) &body body)
(let ((source-var (copy-symbol 'source)))
`(let* ((,source-var (source-designator ,source))
(,var (github-issue-number ,source-var)))
(unless ,var
(error "Can't find issue number for ~A" ,source-var))
,@body)))
(defun set-issue-label (source label)
(setf source (source-designator source))
(let ((issue-number (github-issue-number source)))
(unless issue-number
(error "Can't find issue number for ~A" source))
(githappy:modify-repo-issue :owner "quicklisp"
:repo "quicklisp-projects"
:number issue-number
:body (githappy:js "labels" (list label)))))
(defun comment-on-issue (source comment)
(with-issue-number (number source)
(githappy:create-repo-issue-comment :body (githappy:js "body" comment)
:issue-number number
:repo "quicklisp-projects"
:owner "quicklisp")))
(defun mark-canbuild (source)
(set-issue-label source "canbuild"))
(defun mark-cantbuild (source)
(set-issue-label source "cantbuild"))
(defun push-projects ()
(with-posix-cwd (translate-logical-pathname "quicklisp-controller:projects;")
(run "git" "push" "origin" "master")))
(defun pull-projects ()
(with-posix-cwd (translate-logical-pathname "quicklisp-controller:projects;")
(run "git" "pull")))