1 ! Copyright (C) 2017 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: cli.git combinators io.directories io.files.info
4 io.pathnames kernel sequences uuid web-services.github ;
7 : default-zealot-directory ( chunk -- path ) [ home ".zealot" ] dip 3append-path ;
8 : default-zealot-source-directory ( -- path ) "source" default-zealot-directory ;
9 : default-zealot-builds-directory ( -- path ) "builds" default-zealot-directory ;
11 : zealot-source-directory ( chunk -- path ) [ default-zealot-source-directory ] dip append-path ;
12 : zealot-builds-directory ( chunk -- path ) [ default-zealot-builds-directory ] dip append-path ;
14 : with-default-zealot-source-directory ( chunk quot -- )
15 [ default-zealot-source-directory ] dip with-ensure-directory ; inline
17 : with-default-zealot-builds-directory ( chunk quot -- )
18 [ default-zealot-builds-directory ] dip with-ensure-directory ; inline
20 : with-zealot-source-directory ( chunk quot -- )
21 [ zealot-source-directory ] dip with-ensure-directory ; inline
23 : with-zealot-builds-directory ( chunk quot -- )
24 [ zealot-builds-directory ] dip with-ensure-directory ; inline
27 : with-zealot-github-directory ( quot -- )
28 [ "github" ] dip with-zealot-source-directory ; inline
30 : with-zealot-github-project-directory ( user project quot -- )
31 [ "github" ] 3dip [ 3append-path ] dip with-zealot-source-directory ; inline
33 : zealot-github-clone ( user project -- process )
34 '[ _ _ 2dup "/" glue github-git-clone-as ] with-zealot-github-directory ; inline
36 : zealot-github-source-path ( user project -- path )
37 [ "github" ] 2dip 3append-path zealot-source-directory ;
39 : zealot-github-builds-path ( user project -- path )
40 [ "github" ] 2dip 3append-path uuid1 append-path zealot-builds-directory ;
42 : zealot-github-fetch-all ( user project -- process )
43 [ git-fetch-all* ] with-zealot-github-project-directory ;
45 : zealot-github-fetch-tags ( user project -- process )
46 [ git-fetch-tags* ] with-zealot-github-project-directory ;
48 : zealot-github-pull ( user project -- process )
49 [ git-pull* ] with-zealot-github-project-directory ;
51 : zealot-github-exists-locally? ( user project -- ? )
52 zealot-github-source-path ?file-info >boolean ;
54 : zealot-github-ensure ( user project -- process )
55 2dup zealot-github-exists-locally? [
57 [ zealot-github-fetch-all drop ]
58 [ zealot-github-fetch-tags drop ]
59 [ zealot-github-pull ]
65 : zealot-github-set-build-remote ( path user project -- process )
66 '[ "origin" _ _ github-ssh-uri git-change-remote* ] with-directory ;
68 : zealot-github-add-build-remote ( path user project -- process )
69 '[ "github" _ _ github-ssh-uri git-remote-add* ] with-directory ;
71 : zealot-github-clone-paths ( user project -- process builds-path )
72 [ zealot-github-source-path ]
73 [ zealot-github-builds-path ] 2bi
74 [ git-clone-as ] keep ;
76 : zealot-build-checkout-branch ( path branch -- process )
77 '[ _ git-checkout-existing-branch* ] with-directory ;