-
@ Damus Code
2024-05-31 07:05:51Here's a quick script for generating git shortlog longform notes on git push. It currently powers the Damus Code nostr account:
Let's say you are hosting a bare git repository on a server at
git/project
. You can add apost-receive
hook that generates a longform note when you push to the server:In
server:git/project/hooks/post-receive
:```bash
!/usr/bin/env bash
commit_body="" last="" project="my-project" # update this with your project name sec="abcdef..." # update this with your secret key branch="master"
while read oldrev newrev refname; do branch=$refname last=$newrev relays="wss://relay.damus.io wss://nos.lol" commit_body=$(git shortlog $oldrev..$newrev | awk -f /home/user/markdown-shortlog.awk) done
if [[ $branch == "refs/heads/master" ]]; then
nostril --content "# Changes
$commit_body" \ --envelope \ --kind 30023 \ --tag title "$project" \ --tag summary "Latest codebase changes to $project" \ --tag t gitlog \ --sec $sec \ | nostcat --connect-timeout 1000 $relays fi ```
you'll need nostril, nostcat, and
markdown-shortlog.awk
:```awk /^[^ ]/ { if (author) { print "" } author = $0 print "## " author }
/^ / { print "-" substr($0, 6) } ```
Now when you push, it will generate a longform note that looks something like this:
Example
William Casarin (10):
- fix warnings
- readme: add usage
- textmode: fix coloring of abbreviated names
- profiling: update puffin version
- refactor: move note into its own widget
- refactor: rename widgets to ui
- ui: simplify note widget
- get all missing ids from all timelines
- initial inline note previews
- fix until filters
kernelkind (6):
- Add custom visual themes
- Add modular custom text styles
- Apply app style to AccountLoginView
- Add MobileAccountLoginView
- Refactor 'ui tests' conception to previews
- Use custom style in app