warbo-utilities: af3ee2118ba2d77490542a3a0bd8408204be49b4
1: #!/usr/bin/env bash
2: set -e
3:
4: mount | grep -q s3_repos || {
5: echo "$HOME/Drives/s3_repos not mounted, skipping render" 1>&2
6: exit 0
7: }
8:
9: cd "$1"
10:
11: NAME=$(basename "$PWD" .git)
12:
13: # S3 will delete empty directories, but git checks for their presence. Create
14: # them if they don't exist.
15: if [[ -e HEAD ]] # Only make dirs in something that looks like a git repo!
16: then
17: for D in refs/heads refs/tags objects/info
18: do
19: [[ -e "$D" ]] || mkdir -p "$D"
20: done
21: fi
22:
23: PAGES=$(repoPath="$PWD" htmlInOut=1 inNixedDir genGitHtml)
24: export PAGES
25: DEST="$HOME/Drives/s3_repos/$NAME"
26:
27: git2ipfs "$PWD" || echo "Failed to push to IPFS, carrying on anyway..." 1>&2
28:
29: if [[ -n "$PAGES" ]]
30: then
31: echo "Pushing '$PAGES' to Web" 1>&2
32:
33: #export RCLONE_S3_REGION=eu-west-1
34: #export RCLONE_S3_PROVIDER=AWS
35: #export RCLONE_S3_ENV_AUTH=true
36: # Don't include repo.git, since we can use the real, canonical one
37: #with-aws-creds rclone sync "$PAGES" ":s3:www.chriswarbo.net/git/$NAME"
38: rsync --checksum --delete --ignore-times --progress --copy-unsafe-links \
39: --archive --no-perms --no-owner --no-group \
40: --exclude /repo.git --exclude /branches/master "$PAGES/" "$DEST" || {
41: CODE="$?"
42: if [[ "$CODE" -eq 23 ]]
43: then
44: echo "Ignoring rsync error about attributes (it's S3's fault)" 1>&2
45: else
46: echo "Unexpected rsync problem, aborting" 1>&2
47: exit "$CODE"
48: fi
49: }
50:
51: # Edit repo link to point at canonical /git repo
52: sed -e "s@repo.git@/git/$NAME.git@g" -i "$DEST/index.html"
53: fi
54:
55: # Ensure there's no snapshot
56: F="$DEST/repo.git"
57: if [[ -e "$F" ]]
58: then
59: echo "WARNING: Shouldn't have '$F', canonical URL should be used" 1>&2
60: fi
61:
62: # Ensure we use canonical URL
63: URL="/git/$NAME.git"
64: F="$DEST/index.html"
65:
66: # shellcheck disable=SC2029
67: if grep -q "$URL" < "$F"
68: then
69: true
70: else
71: echo "WARNING: Didn't find canonical URL '$URL' in '$F'" 1>&2
72: fi
Generated by git2html.