diff --git a/pre-push-fediverse b/pre-push-fediverse index ed4c5ec..ff7504a 100755 --- a/pre-push-fediverse +++ b/pre-push-fediverse @@ -5,13 +5,16 @@ # To temperarily turn off posting, in project root: # touch .git/ignorepost +# Configuration variables +# Post titles: On Mastodon this is a content warning, so you may want to turn it off. +title=true + + # Check if .git/ignorepost exists - if so, exit silently if [[ -f ".git/ignorepost" ]]; then exit 0 fi -# Do not allow errors -set -e remote="$1" url="$2" @@ -31,8 +34,8 @@ project="${project%.git}" # Get pusher's name from git config more safely pusher="$(git config user.name)" if [[ -z "$pusher" ]]; then - echo "Error: Could not determine user name from git config" - exit 1 + echo "Error: Could not determine user name from git config. Pushing anyway." + exit 0 fi # Initialize message @@ -59,8 +62,8 @@ while read localRef localSha remoteRef remoteSha; do # Verify we can access the commit if ! git cat-file -e "$localSha"; then - echo "Error: Cannot access commit $localSha" - exit 1 + echo "Error: Cannot access commit $localSha. Pushing anyway." + exit 0 fi # Get latest commit message @@ -98,7 +101,11 @@ fi # Only post if we have something to say if [[ -n "$message" ]]; then + if [[ "${title}" == "true" ]]; then toot post -v public -p "$project" -t "text/markdown" "$message" &> /dev/null + else + toot post -v public -t "text/markdown" "$message" &> /dev/null + fi fi exit 0