Last active
April 21, 2025 10:57
-
-
Save dewomser/743328e2b14a067f15c84b832e1ed579 to your computer and use it in GitHub Desktop.
Toot the local git diff in a specific git repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#This script is useing "toot" ang "gist". Must be installed | |
# Variables | |
REPO_NAME="Hello_world" | |
REPO_REMOTE_ROOT="https://github.com/foo" | |
REPO_DIR="/home/fpp/git/$REPO_NAME" | |
GIST_DESCRIPTION="Latest commit diff $REPO_NAME" | |
GIST_FILENAME="diff.txt" | |
MASTODON_MESSAGE="Check out the latest commit diff: $REPO_NAME" | |
# Change to the repository directory | |
cd "$REPO_DIR" || exit | |
# Get the first 10 lines of the diff from the latest commit | |
DIFF=$(git diff HEAD~1 HEAD | head -n 10) | |
# Create a temporary file for the diff | |
TEMP_FILE=$(mktemp) | |
echo "$REPO_NAME" > "$TEMP_FILE" | |
echo "$REPO_REMOTE_ROOT/$REPO_NAME" >> "$TEMP_FILE" | |
echo "------------" >> "$TEMP_FILE" | |
echo "$DIFF" >> "$TEMP_FILE" | |
# Create a GitHub Gist | |
GIST_URL=$(gist -d "$GIST_DESCRIPTION" "$TEMP_FILE") | |
# Send a message to Mastodon | |
toot post "$MASTODON_MESSAGE $GIST_URL" | |
# Clean up the temporary file | |
rm "$TEMP_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment