-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathupstream-vcs.lisp
116 lines (96 loc) · 3.9 KB
/
upstream-vcs.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
;;;; upstream-vcs.lisp
(in-package #:quicklisp-controller)
(defclass vcs-source (upstream-source)
((command
:initarg :command
:accessor command)
(command-arguments
:initarg :command-arguments
:accessor command-arguments)
(checkout-subcommand
:initarg :checkout-subcommand
:accessor checkout-subcommand)
(checkout-subcommand-arguments
:initarg :checkout-subcommand-arguments
:accessor checkout-subcommand-arguments)
(update-subcommand
:initarg :update-subcommand
:accessor update-subcommand)
(update-subcommand-arguments
:initarg :update-subcommand-arguments
:accessor update-subcommand-arguments))
(:default-initargs
:command-arguments nil
:checkout-subcommand "co"
:checkout-subcommand-arguments nil
:update-subcommand "update"
:update-subcommand-arguments nil))
(defmethod source-description ((source vcs-source))
(format nil "~A ~A ~A"
(command source)
(checkout-subcommand source)
(location source)))
(defgeneric vcs-checkout-arguments (source checkout-directory)
(:method ((source vcs-source) checkout-directory)
(append (list* (command source)
(command-arguments source))
(list* (checkout-subcommand source)
(checkout-subcommand-arguments source))
(list (location source) (native checkout-directory)))))
(defgeneric vcs-checkout (source checkout-directory)
(:method ((source vcs-source) checkout-directory)
(apply #'run (vcs-checkout-arguments source checkout-directory))))
(defgeneric vcs-update-arguments (source checkout-directory)
(:method ((source vcs-source) checkout-directory)
(append (list* (command source) (command-arguments source))
(list* (update-subcommand source)
(update-subcommand-arguments source)))))
(defgeneric vcs-update (source checkout-directory)
(:method ((source vcs-source) checkout-directory)
(with-posix-cwd checkout-directory
(apply #'run (vcs-update-arguments source checkout-directory)))))
(defgeneric vcs-checkout (vcs-source checkout-directory)
(:method ((source vcs-source) checkout-directory)
(let ((args (append (list (command source))
(command-arguments source)
(list (checkout-subcommand source))
(checkout-subcommand-arguments source)
(list (location source) (native checkout-directory)))))
(apply #'run args))))
(defgeneric export-source (vcs-source export-directory))
(defmethod release-tarball-prefix ((source vcs-source))
(format nil "~A-~A-~A/"
(project-name source)
(prefix-timestamp)
(command source)))
(defgeneric cached-checkout-directory (source)
(:method ((source vcs-source))
(merge-logical (format nil "~A/~A/"
(project-name source)
(string-digest (location source)))
"quicklisp-controller:upstream-cache;vcs;")))
(defmethod ensure-source-cache ((source vcs-source))
(let ((pathname (cached-checkout-directory source)))
(unless (probe-file pathname)
(ensure-directories-exist (parent-directory pathname))
(vcs-checkout source pathname))
(probe-file pathname)))
(defmethod update-source-cache ((source vcs-source))
(let ((pathname (cached-checkout-directory source)))
(if (probe-file pathname)
(vcs-update source pathname)
(ensure-source-cache source))
(probe-file pathname)))
;;; Tags of some sort
(defclass tagged-mixin ()
((tag-data
:initarg :tag-data
:accessor tag-data)))
(defmethod source-location-initargs :around ((source tagged-mixin))
(let ((initargs (call-next-method)))
(append initargs (list :tag-data))))
(defmethod release-tarball-prefix ((source tagged-mixin))
(format nil "~A-~A-~A/"
(project-name source)
(tag-data source)
(command source)))