This repository was archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathdat.sh
More file actions
executable file
·134 lines (115 loc) · 4.01 KB
/
dat.sh
File metadata and controls
executable file
·134 lines (115 loc) · 4.01 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# This script serves to clone in and install the listed git repos on
# the notes and doc paths.
NOTES="$PWD/notes-store"
DOCS="$PWD/doc-store"
mkdir -p "$DOCS" # dir used by Grimoire as the doc tree
if [ -z "$GIT_DAT" ]
then
mkdir -p dat # dir for git repos to live in
GIT_DAT="$PWD/dat"
fi
[ -f `which gawk` ] && AWK=`which gawk` || AWK=`which awk`
if [ -z "$AWK" ]
then
echo "Could not locate an AWK implementation! Aborting"
exit 1
fi
git_get() {
# This is a quick little git extension designed to allow me to
# manage all the git repos that I keep around better. The idea is
# that a "root" directory, $GIT_DAT/$OWNER/$REPO, and then symlink
# that directory to wherever you are now as $REPO. Saves excessive
# cloning and keeping multiple coppies of a single repo around.
if ( [[ "--help" = $1 ]] ||
[[ "help" = $1 ]] ||
[[ -z $1 ]] )
then
echo "git-get"
echo "Usage: git get [help | --help | GIT_ADDR | GIT_ADDR USER/NAME]"
echo " Clones a git repo to the $GIT_DAT dir, creating a symlink"
echo " into the current directory."
exit 0
elif [ ! -z $2 ]
then
USER=$(echo $2 | $AWK "{match(\$1,\"([^/]+)/.*\",a)}END{print(a[1])}")
REPO=$(echo $2 | $AWK "{match(\$1,\".*?/(.*?)(.git)?\",a)}END{print(a[1])}")
elif [ ! -z $1 ]
then
USER=$(echo $1 | $AWK "{match(\$1,\".*?:([^/]+)/.*\",a)}END{print(a[1])}")
REPO=$(echo $1 | $AWK "{match(\$1,\".*?:[^/]+/(.*?).git\",a)}END{print(a[1])}")
fi
[ ! -z $USER ] && [ ! -z $REPO ] || exit 1
# Ensure the target dir exists
([ -e "$GIT_DAT/$USER" ] || mkdir -p "$GIT_DAT/$USER" ) &&
# Get the data
([ -e "$GIT_DAT/$USER/$REPO/.git/" ] || git clone $1 "$GIT_DAT/$USER/$REPO") &&
# Create a link to it
([ -e "./$REPO" ] ||
( echo "Creating symlink $REPO" &&
ln -s "$GIT_DAT/$USER/$REPO" "./$REPO"
)
) &&
return 0
}
git_update() {
# $1 is a repo dir
pushd $1 > /dev/null
(git reset --hard > /dev/null) &&
(git pull --quiet origin master) &&
(echo "Updated repo $1")
popd > /dev/null
}
install_docs() {
# $1 := GIT_GROUP
# $2 := GIT_REPO
# $3 := MVN_GROUP
# $4 := MVN_ARTIFACT
# Should not be directly used
git_get "git@github.com:$1/$2.git"
rm "./$2"
dat="$GIT_DAT/$1/$2"
src="$dat/$3/$4"
tgt="$DOCS/$3/$4"
if [ -d "$dat" ]
then
git_update "$dat"
else
git_get "git@github.com:$1/$2.git"
rm "./$2"
fi
( [ -d "$src" ] || ( echo "No such dir $src" && exit 1 ))
mkdir -p "$DOCS/$3/"
([ -a "$tgt" ] && rm "$tgt" )
ln -s "$src" "$tgt"
([ -a "$DOCS/$3/meta.edn" ] ||
(echo "nil" > "$DOCS/$3/meta.edn" &&
echo "Added nil org meta!"))
([ -a "$DOCS/meta.edn" ] ||
(echo "nil" > "$DOCS/meta.edn" &&
echo "Added nil store meta!"))
}
# Install the notes
############################################################
# Note that the notes are a single monolithic project, whereas
# individual libraries are documented seperately.
if [ -a "$NOTES" ]
then
pushd "$NOTES" > /dev/null &&
git reset --hard > /dev/null &&
git pull --quiet &&
echo "Updated datastore!" &&
popd > /dev/null
else
git_get git@github.com:clojure-grimoire/datastore.git &&
mv "./datastore" "$NOTES"
fi
# Import the clojure.core docs & notes
############################################################
install_docs clojure-grimoire doc-clojure-core org.clojure clojure
#install_docs clojure-grimoire doc-cljs-core org.clojure clojurescript
#install_docs clojure-grimoire doc-core-async org.clojure core.async
install_docs clojure-grimoire doc-core-typed org.clojure core.typed
install_docs clojure-grimoire doc-core-typed org.clojure core.typed.rt
install_docs clojure-grimoire doc-lib-grimoire org.clojure-grimoire lib-grimoire
install_docs clojure-grimoire doc-core-logic org.clojure core.logic