First commit, added pre-push hook for posting commit message to Pleroma or Mastodon.

This commit is contained in:
stormdragon2976
2023-02-05 14:18:41 -05:00
parent c0a1a1be2f
commit df55f335f9
2 changed files with 36 additions and 0 deletions

22
pre-push Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# Requires toot: https://github.com/ihabunek/toot
# remote is $1 e.g. origin
# url is $2
url="${2#*@}"
url="${url%.git}"
shopt -s extglob
url="${url/:*([0-9])//}"
url="https://${url//\/\///}"
branch="$(git branch | grep "\* ")"
branch="${branch:2}"
commit="$(git log -1 --pretty=%B)"
project="${2##*/}"
project="${project%.git}"
pusher="$(git log | grep -m1 "Author: ")"
pusher="${pusher#Author: }"
pusher="${pusher% <*@*.*>}"
toot post --quiet -v public -p "$project" -t "text/markdown" "$pusher pushed changes to the $branch branch of the [$project project]($url)
$commit"
exit 0