From 0f75222778ba7082155138e7fbcc8ca1cf3c655c Mon Sep 17 00:00:00 2001 From: teuserer Date: Tue, 2 Jul 2024 22:00:05 +0200 Subject: [PATCH] add softwerke event generator --- tools/README.md | 27 ++++++++++++++- tools/generate_softwerke_stammtisch.sh | 47 ++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100755 tools/generate_softwerke_stammtisch.sh diff --git a/tools/README.md b/tools/README.md index 51c5a78..63122a6 100644 --- a/tools/README.md +++ b/tools/README.md @@ -5,8 +5,9 @@ ```bash cd tools python3 generate_stammtisch_events.py -Enter the year: 2024 ``` +> Enter the year: 2024 + Output: ```bash @@ -28,3 +29,27 @@ Markdown file '2024-11-06_n39_stammtisch.md' generated successfully in the _even Markdown file '2024-11-27_n39_stammtisch.md' generated successfully in the _events folder! Markdown file '2024-12-18_n39_stammtisch.md' generated successfully in the _events folder! ``` + +## Softwerke Stammtisch Event erzeugen + +```bash +cd tools +./generate_softwerke_stammtisch.sh +``` +> When is the next Stammtisch? (YYYY-MM-DD) + +> 2024-07-05 + +Output: + +```bash +Zu neuem Branch 'events/2024-07-05_softwerke_stammtisch.md' gewechselt +[events/2024-07-05_softwerke_stammtisch.md 6a22bef] Add event for 2024-07-05 + 1 file changed, 10 insertions(+) + create mode 100644 _events/2024/2024-07-05_softwerke_stammtisch.md +``` + +Branch veröffentlichen: +```bash +git push origin events/2024-07-05_softwerke_stammtisch.md +``` \ No newline at end of file diff --git a/tools/generate_softwerke_stammtisch.sh b/tools/generate_softwerke_stammtisch.sh new file mode 100755 index 0000000..677598a --- /dev/null +++ b/tools/generate_softwerke_stammtisch.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +git checkout main > /dev/null +git pull origin main || exit 1 + +# If no argument is supplied ask for the date of the next Stammtisch +if [ $# -eq 0 ]; then + echo "When is the next Stammtisch? (YYYY-MM-DD)" + read date +else + date=$1 + echo "Using date $date" +fi + +# Parse the date +year=$(echo $date | cut -d'-' -f1) +month=$(echo $date | cut -d'-' -f2) +day=$(echo $date | cut -d'-' -f3) +dow=$(date -d $date +%A) +Month=$(date -d $date +%B) + +root_dir=`git rev-parse --show-toplevel` +filename="$year-$month-${day}_softwerke_stammtisch.md" + +# Create a new branch. delete it if it already exists +git branch -D "events/$filename" > /dev/null 2>&1 +git checkout -b "events/$filename" > /dev/null || exit 1 + +# Create the new file +cat > "$root_dir/_events/$year/$filename" <