diff options
author | Case Duckworth | 2023-06-02 15:05:28 -0500 |
---|---|---|
committer | Case Duckworth | 2023-06-02 15:05:28 -0500 |
commit | af1543a9a844e362a57dc898088c4f4b068a6675 (patch) | |
tree | 1e5675db9e64e6c63145b43023f70f7984ad66b9 | |
parent | Just use ed. (diff) | |
download | git-init-remote-af1543a9a844e362a57dc898088c4f4b068a6675.tar.gz git-init-remote-af1543a9a844e362a57dc898088c4f4b068a6675.zip |
Make hook executable and prompt to push
-rwxr-xr-x | git-init-remote | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/git-init-remote b/git-init-remote index a934c1f..043a780 100755 --- a/git-init-remote +++ b/git-init-remote | |||
@@ -3,8 +3,33 @@ | |||
3 | GITREMOTE=git.acdw.net | 3 | GITREMOTE=git.acdw.net |
4 | GITROOT=/git | 4 | GITROOT=/git |
5 | 5 | ||
6 | POSTUPDATEHOOK=/tmp/post-update.hook | ||
7 | |||
8 | init_post_update_hook() { | ||
9 | # This post-update hook will update cgit's date display. | ||
10 | cat <<\EOF | ||
11 | #!/bin/sh | ||
12 | |||
13 | # Update "agefile" for cgit | ||
14 | # The default location is <git-dir>/info/web/last-modified | ||
15 | agefile="$(git rev-parse --git-dir)/info/web/last-modified" | ||
16 | mkdir -p "$(dirname "$agefile")" | ||
17 | |||
18 | git for-each-ref > "$agefile" \ | ||
19 | --sort=-authordate --count=1 \ | ||
20 | --format='%(authordate:iso8601)' | ||
21 | |||
22 | # Prepare a packed repository for use over dumb transports | ||
23 | git update-server-info | ||
24 | EOF | ||
25 | } | ||
26 | |||
27 | ## Setup | ||
28 | |||
6 | git ls-files > /dev/null || exit 1 | 29 | git ls-files > /dev/null || exit 1 |
7 | 30 | ||
31 | test -f "$POSTUPDATEHOOK" || init_post_update_hook > "$POSTUPDATEHOOK" | ||
32 | |||
8 | # consider --git-dir as well .. however --git-dir would require more massaging | 33 | # consider --git-dir as well .. however --git-dir would require more massaging |
9 | # of the output. | 34 | # of the output. |
10 | local="$(git rev-parse --show-toplevel)" | 35 | local="$(git rev-parse --show-toplevel)" |
@@ -23,10 +48,23 @@ echo "ssh \"$GITREMOTE\" ed \"$remote/description\"" | |||
23 | ssh "$GITREMOTE" ed "$remote/description" | 48 | ssh "$GITREMOTE" ed "$remote/description" |
24 | 49 | ||
25 | # Add post-update-hook | 50 | # Add post-update-hook |
26 | echo "scp post-update.hook \"$GITREMOTE:$remote/hooks/post-update\"" | 51 | echo "scp \"$POSTUPDATEHOOK\" \"$GITREMOTE:$remote/hooks/post-update\"" |
27 | scp post-update.hook "$GITREMOTE:$remote/hooks/post-update" | 52 | scp "$POSTUPDATEHOOK" "$GITREMOTE:$remote/hooks/post-update" |
53 | echo "ssh \"$GITREMOTE\" chmod +x \"$remote/hooks/post-update\"" | ||
54 | ssh "$GITREMOTE" chmod +x "$remote/hooks/post-update" | ||
28 | 55 | ||
29 | ## Local work | 56 | ## Local work |
30 | 57 | ||
31 | echo "git remote add origin \"$GITREMOTE:$remote\"" | 58 | echo "git remote add origin \"$GITREMOTE:$remote\"" |
32 | git remote add origin "$GITREMOTE:$remote" | 59 | git remote add origin "$GITREMOTE:$remote" |
60 | |||
61 | echo -n "Push to remote?" | ||
62 | read | ||
63 | |||
64 | case "$REPLY" in | ||
65 | y*|Y*|'') | ||
66 | echo git push -u origin main | ||
67 | git push -u origin main | ||
68 | ;; | ||
69 | *) ;; | ||
70 | esac | ||