-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvcs.jam
110 lines (85 loc) · 2.34 KB
/
vcs.jam
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
# Version Control System module
#
# @todo propose a minimal interface for vcs (checkout, etc.)
import path ;
import errors ;
import assert ;
# the list of supported vcs
supported-vcs = archive git svn ;
for vcs in $(supported-vcs)
{
import vcs-$(vcs) ;
}
# Generates a version string from the auto-detected VCS repository.
rule generate-version-string ( directory )
{
# @todo need to fix this
# if ! [ path.exists $(directory) ]
# {
# errors.user-error "$(directory) does not exist." ;
# }
vcs = [ type $(directory) ] ;
assert.in $(vcs) : $(supported-vcs) ;
return [ vcs-$(vcs).generate-version-string $(directory) ] ;
}
# Returns a string describing the version control system.
rule type ( directory )
{
t = ;
for vcs in $(supported-vcs)
{
if [ vcs-$(vcs).is-repository $(directory) ]
{
t = $(vcs) ;
}
}
if ! $(t)
{
errors.error "unknown vcs system at $(directory)" ;
}
return $(t) ;
}
# Fetches from the given url to the given directory using the
# indicated vcs. If the directory already exists, the system will
# check that the url matches, it is an error if it doesn't.
rule fetch ( vcs : root-url : directory )
{
assert.in $(vcs) : $(supported-vcs) ;
if [ path.exists $(directory) ]
{
assert.true type $(directory) : $(vcs) ;
local current-url = [ vcs-$(vcs).root-url $(directory) ] ;
if $(current-url) != $(root-url)
{
errors.error "vcs:$(vcs): $(directory) is at $(current-url) not $(root-url)" ;
}
}
else
{
echo "vcs: fetching $(root-url) to $(directory)" ;
local r1 = [ vcs-$(vcs).fetch $(root-url) : $(directory) ] ;
}
}
# check out a particular ref
rule checkout ( directory : symbolic-ref )
{
echo $(directory) ;
local vcs = [ type $(directory) ] ;
assert.in $(vcs) : $(supported-vcs) ;
echo "vcs: checking out $(symbolic-ref) at $(directory)" ;
local r = [ vcs-$(vcs).checkout $(directory) : $(symbolic-ref) ] ;
}
# return the url associated with directory
rule root-url ( directory )
{
local vcs = [ type $(directory) ] ;
assert.in $(vcs) : $(supported-vcs) ;
return [ vcs-$(vcs).root-url $(directory) ] ;
}
# return the ref associated with directory
rule ref ( directory : symbolic-ref ? )
{
local vcs = [ type $(directory) ] ;
assert.in $(vcs) : $(supported-vcs) ;
return [ vcs-$(vcs).ref $(directory) : $(symbolic-ref) ] ;
}