Skip to content

Instantly share code, notes, and snippets.

@llogiq
Created May 1, 2020 18:25
Show Gist options
  • Save llogiq/cd318e80ffe741db6f8ce4a4c0212949 to your computer and use it in GitHub Desktop.
Save llogiq/cd318e80ffe741db6f8ce4a4c0212949 to your computer and use it in GitHub Desktop.
cd /home/andre/projects/this-week-in-rust
COMMAND="$1"
case "${COMMAND}" in
start)
git checkout master
git pull origin master
FILE=draft*/*.md
set $(head -n 2 ${FILE} | tail -n 1)
NUMBER="$2"
git checkout -b "twir-${NUMBER}"
set $(rg -F '[merged]:' ${FILE})
MERGED_LINK="$2"
NEXT_LINK=$(python - ${MERGED_LINK} <<EOF
import sys, datetime
(base, ta, dates) = sys.argv[1].rpartition("%3A")
(old_date, new_date) = dates.split("..")
start = datetime.date(*[int(x) for x in new_date.split("-")])
end_date = start + datetime.timedelta(days=7)
print("[merged]:", "".join([base, ta, new_date, "..", end_date.strftime("%Y-%m-%d")]))
EOF
)
echo $NEXT_LINK
firefox --new-tab https://users.rust-lang.org/t/twir-quote-of-the-week/328
firefox --new-tab https://users.rust-lang.org/t/crate-of-the-week/2704
firefox --new-tab $NEXT_LINK
geany ${FILE}
;;
check)
FILE=draft*/*.md
echo "dubletten"
rg -o 'pull/\d+' draft*/*.md | sort | uniq -c | rg -v '^\s+1\s'
echo "links"
rg '\* \[.*\]\(.*\)' draft*/*.md | rg -v http
;;
push)
FILE=draft*/*.md
git add ${FILE}
git commit -m "C/QotW + notable changes"
set $(head -n 2 ${FILE} | tail -n 1)
NUMBER="$2"
git push llogiq twir-${NUMBER}
firefox --new-tab https://github.com/llogiq/this-week-in-rust/pull/new/twir-${NUMBER}
git push --delete llogiq twir-$[${NUMBER}-1]
;;
*)
echo "usage: twir [start|check|push]"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment