diff options
author | Case Duckworth | 2023-05-28 22:14:04 -0500 |
---|---|---|
committer | Case Duckworth | 2023-05-28 22:14:04 -0500 |
commit | 75a4fcbb3e220c2154044d966d5f8de2eeb96014 (patch) | |
tree | 02c90acc4dee3822f560d88d62c66b5d0d67802a | |
download | git-init-remote-75a4fcbb3e220c2154044d966d5f8de2eeb96014.tar.gz git-init-remote-75a4fcbb3e220c2154044d966d5f8de2eeb96014.zip |
Initial commit
-rwxr-xr-x | git-init-remote | 33 | ||||
-rwxr-xr-x | post-update.hook | 15 |
2 files changed, 48 insertions, 0 deletions
diff --git a/git-init-remote b/git-init-remote new file mode 100755 index 0000000..4d8cb29 --- /dev/null +++ b/git-init-remote | |||
@@ -0,0 +1,33 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | GITREMOTE=git.acdw.net | ||
4 | GITROOT=/git | ||
5 | |||
6 | git ls-files > /dev/null || exit 1 | ||
7 | |||
8 | # consider --git-dir as well .. however --git-dir would require more massaging | ||
9 | # of the output. | ||
10 | local="$(git rev-parse --show-toplevel)" | ||
11 | name="${local##*/}" | ||
12 | |||
13 | remote="$GITROOT/$name.git" | ||
14 | |||
15 | ## Remote work | ||
16 | |||
17 | # Initiate the repository | ||
18 | echo "ssh \"$GITREMOTE\" git init --bare \"$remote\"" | ||
19 | ssh "$GITREMOTE" git init --bare "$remote" | ||
20 | |||
21 | # Add a description | ||
22 | echo -n "Repo description: "; read | ||
23 | echo "ssh \"$GITREMOTE\" sh -c \"echo '$REPLY' > '$remote'\"" | ||
24 | ssh "$GITREMOTE" sh -c "echo '$REPLY' > '$remote'" | ||
25 | |||
26 | # Add post-update-hook | ||
27 | echo "scp post-update.hook \"$GITREMOTE:$remote/hooks/post-update\"" | ||
28 | scp post-update.hook "$GITREMOTE:$remote/hooks/post-update" | ||
29 | |||
30 | ## Local work | ||
31 | |||
32 | echo "git remote add origin \"$GITREMOTE:$remote\"" | ||
33 | git remote add origin "$GITREMOTE:$remote" | ||
diff --git a/post-update.hook b/post-update.hook new file mode 100755 index 0000000..a68bf65 --- /dev/null +++ b/post-update.hook | |||
@@ -0,0 +1,15 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Update "agefile" for cgit | ||
4 | # The default location is <git-dir>/info/web/last-modified | ||
5 | |||
6 | agefile="$(git rev-parse --git-dir)/info/web/last-modified" | ||
7 | mkdir -p "$(dirname "$agefile")" | ||
8 | |||
9 | git for-each-ref > "$agefile" \ | ||
10 | --sort=-authordate --count=1 \ | ||
11 | --format='%(authordate:iso8601)' | ||
12 | |||
13 | # Prepare a packed repository for use over dumb transports | ||
14 | |||
15 | git update-server-info | ||