Skip to content

Commit 0ea1f04

Browse files
committed
Move index setup to a script
1 parent a0e8773 commit 0ea1f04

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

README.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,7 @@ export GIT_REPO_URL=file://`pwd`/tmp/index-bare
3838
export GIT_REPO_CHECKOUT=`pwd`/tmp/index-co
3939
```
4040

41-
### Set up the git index
42-
43-
First, run these commands in this repository's checkout to create a blank index:
44-
45-
```
46-
mkdir -p tmp
47-
git init --bare tmp/index-bare
48-
git clone tmp/index-bare tmp/index-co
49-
touch tmp/index-co/.git/git-daemon-export-ok
50-
```
51-
52-
Second, configure cargo to publish to your local registry by adding this to your
53-
local `~/.cargo/config`
54-
55-
```
56-
[registry]
57-
index = "http://localhost:8888/git/index"
58-
```
41+
To set up the git index, run `./script/init-local-index.sh`.
5942

6043
## Running
6144

script/init-local-index.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
if [ -d tmp/index-bare ]; then
6+
echo tmp/index-bare already exists, exiting
7+
exit 0
8+
fi
9+
10+
mkdir -p tmp
11+
rm -rf tmp/index-bare tmp/index-co
12+
13+
echo "Initializing repository in tmp/index-bare..."
14+
git init -q --bare tmp/index-bare
15+
16+
echo "Creating checkout in tmp/index-bare..."
17+
git init -q tmp/index-co
18+
cd tmp/index-co
19+
cat > config.json <<-EOF
20+
{
21+
"dl": "http://localhost:8888/api/v1/crates",
22+
"api": "http://localhost:8888/"
23+
}
24+
EOF
25+
git add config.json
26+
git commit -qm 'Initial commit'
27+
git remote add origin ../index-bare
28+
git push -q origin master -u > /dev/null
29+
cd ../..
30+
touch tmp/index-co/.git/git-daemon-export-ok
31+
32+
cat - <<-EOF
33+
Please add the following to your HOME/.cargo/config:
34+
35+
[registry]
36+
index = "http://localhost:8888/git/index"
37+
38+
You will also need to generate a token from in the app itself
39+
EOF
40+

0 commit comments

Comments
 (0)