From 39d95753bebdeb32192bbc4050e9cdff16187698 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 16 Sep 2025 11:21:14 -0700 Subject: [PATCH] ;tools:just: reorganise, cleanups --- Justfile | 1229 ++++++++++++++++++++++++++---------------------------- 1 file changed, 592 insertions(+), 637 deletions(-) diff --git a/Justfile b/Justfile index 986d095b4..e2ce86879 100644 --- a/Justfile +++ b/Justfile @@ -47,8 +47,8 @@ # - profiteur - renders profiles as html # - dateround - from dateutils -# ** Helpers ------------------------------------------------------------ -HELPERS: help +# ** just Helpers ------------------------------------------------------------ +JUST_HELPERS: help set export := true @@ -217,9 +217,8 @@ TESTFILES := `fd '\.test$' --exclude ledger-compat` export VERSION := `cat hledger/.version` # Flags for ghc builds. -# Warnings to see during dev tasks like make ghci*. See also the warnings in package.yamls. -# XXX redundant with package.yamls ? +# Warnings to see during dev tasks like make ghci*. XXX redundant with package.yamls ? WARNINGS := ' -Wall -Wno-incomplete-uni-patterns @@ -230,16 +229,16 @@ WARNINGS := ' ' # if you have need to try building in less memory - GHCLOWMEMFLAGS := '' +#GHCLOWMEMFLAGS := '+RTS +M2g -RTS' # ghc-only builds need the macro definitions generated by cabal -# from cabal's dist or dist-sandbox dir, hopefully there's just one: +# from cabal's dist dir, hopefully there's just one: #CABALMACROSFLAGS := '-optP-include -optP hledger/dist*/build/autogen/cabal_macros.h' # or from stack's dist dir: #CABALMACROSFLAGS := '-optP-include -optP hledger/.stack-work/dist/*/*/build/autogen/cabal_macros.h' - CABALMACROSFLAGS := '' + BUILDFLAGS := '-rtsopts ' + WARNINGS + GHCLOWMEMFLAGS + CABALMACROSFLAGS + ' -DDEVELOPMENT' + ' -DVERSION="' + VERSION + '"' + INCLUDEPATHS # -fplugin Debug.Breakpoint \ @@ -541,66 +540,6 @@ hlinttest hlint: installtest: cd; {{ justfile_directory() }}/hledger-install/hledger-install.sh -# ** Installing ------------------------------------------------------------ -INSTALLING: - -# # copy the current ~/.local/bin/hledger to bin/old/hledger-VER -# @copy-as VER: -# cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}" - -# install hledger as bin/old/hledger-VER -@installas VER: - $STACK install --local-bin-path bin/old hledger - for e in hledger ; do mv bin/old/$e bin/old/$e-{{ VER }}; echo "bin/old/$e-{{ VER }}"; done - -# install all hledger executables as bin/old/hledger*-VER -@installallas VER: - $STACK install --local-bin-path bin/old - for e in hledger hledger-ui hledger-web ; do mv bin/old/$e bin/old/$e-{{ VER }}; echo "bin/old/$e-{{ VER }}"; done - -# install hledger with stack traces and ghc-debug support enabled, as bin/hledger*-dbg -@installasdbg *STACKARGS: - $STACK install --local-bin-path bin --flag '*:debug' {{ STACKARGS }} hledger - for e in hledger ; do mv bin/$e bin/$e-dbg; echo "bin/$e-dbg"; done - -# install all hledger executables with stack traces and ghc-debug support enabled, as bin/hledger*-dbg -@installallasdbg *STACKARGS: - $STACK install --local-bin-path bin --flag '*:debug' {{ STACKARGS }} - for e in hledger hledger-ui hledger-web ; do mv bin/$e bin/$e-dbg; echo "bin/$e-dbg"; done - -# On gnu/linux: can't interpolate GTAR here for some reason, and need the shebang line. -# linux / mac only for now, does not handle the windows zip file. -# download github release VER binaries for OS (linux, mac) and ARCH (x64, arm64) to bin/old/hledger*-VER -@installrel VER OS ARCH: - #!/usr/bin/env bash - # if [[ "$OS" == "windows" ]]; then - # cd bin/old && curl -L https://github.com/simonmichael/hledger/releases/download/{{ VER }}/hledger-{{ OS }}-{{ ARCH }}.zip | funzip | `type -P gtar || echo tar` xf - --transform 's/$/-{{ VER }}/' - # else - # fi - cd bin/old && curl -L https://github.com/simonmichael/hledger/releases/download/{{ VER }}/hledger-{{ OS }}-{{ ARCH }}.tar.gz | `type -P gtar || echo tar` xzf - --transform 's/$/-{{ VER }}/' - -# # download recent versions of the hledger executables from github to bin/hledger*-VER -# get-recent-binaries: -# for V in 1.32.2 1.31 1.30 1.29.2 1.28 1.27.1; do just get-binaries $OS x64 $V; done -# just symlink-binaries - -# # add easier symlinks for all the minor hledger releases downloaded by get-binaries. -# symlink-binaries: -# just symlink-binary 1.32.2 -# just symlink-binary 1.29.2 -# just symlink-binary 1.27.1 - -# add an easier symlink for this minor hledger release (hledger-1.29 -> hledger-1.29.2, etc.) -@symlink-binary MINORVER: - cd bin && ln -sf hledger-$MINORVER hledger-`echo $MINORVER | sed -E 's/\.[0-9]+$//'` - -# sym-link some directories required by hledger-web dev builds -symlink-web-dirs: - echo "#ln -sf hledger-web/config # disabled, causes makeinfo warnings" - ln -sf hledger-web/messages - ln -sf hledger-web/static - ln -sf hledger-web/templates - # ** Benchmarking ------------------------------------------------------------ BENCHMARKING: @@ -723,19 +662,19 @@ OS := `ghc -ignore-dot-ghci -package-env - -e 'import System.Info' -e 'putStrLn # run progression benchmark tests and save graphical results\ # ) # tools/progressionbench -- -t png -k png -# # prof: samplejournals \ -# # $(call def-help,prof,\ -# # generate and archive an execution profile\ -# # ) #bin/hledgerprof -# # @echo "Profiling: $(PROFCMD)" -# # -$(PROFCMD) +RTS $(PROFRTSFLAGS) -RTS -# # mv hledgerprof.prof doc/profs/$(TIME).prof -# # (cd doc/profs; rm -f latest*.prof; ln -s $(TIME).prof latest.prof) -# # viewprof: prof \ -# # $(call def-help,viewprof,\ -# # generate, archive, simplify and display an execution profile\ -# # ) -# # tools/simplifyprof.hs doc/profs/latest.prof +# prof: samplejournals \ +# $(call def-help,prof,\ +# generate and archive an execution profile\ +# ) #bin/hledgerprof +# @echo "Profiling: $(PROFCMD)" +# -$(PROFCMD) +RTS $(PROFRTSFLAGS) -RTS +# mv hledgerprof.prof doc/profs/$(TIME).prof +# (cd doc/profs; rm -f latest*.prof; ln -s $(TIME).prof latest.prof) +# viewprof: prof \ +# $(call def-help,viewprof,\ +# generate, archive, simplify and display an execution profile\ +# ) +# tools/simplifyprof.hs doc/profs/latest.prof #{{ STACK }} exec --profile -- hledger +RTS {{ PROFRTSFLAGS }} -RTS -f examples/1000x1000x10.journal {{ CMD }} #>/dev/null # run a hledger CMD against a sample journal and display the execution profile (build hledgerprof first) @@ -759,35 +698,36 @@ quickprof CMD: #hledgerprof #samplejournals (cd doc/profs; rm -f latest.hp; ln -s {{ TIME }}.hp latest.hp; \ hp2ps {{ TIME }}.hp; rm -f latest.ps; ln -s {{ TIME }}.ps latest.ps; rm -f *.aux) -# # viewheap: heap \ -# # $(call def-help,viewheap,\ -# # \ -# # ) -# # $(VIEWPS) doc/profs/latest.ps +# viewheap: heap \ +# $(call def-help,viewheap,\ +# \ +# ) +# $(VIEWPS) doc/profs/latest.ps # quickheap-%: hledgerprof samplejournals \ # $(call def-help,quickheap-"CMD", run some command against a sample journal and display the heap profile ) # $(STACK) exec -- hledgerprof +RTS -hc -RTS $* -f examples/10000x1000x10.journal >/dev/null # hp2ps hledgerprof.hp # @echo generated hledgerprof.ps # $(VIEWPS) hledgerprof.ps -# # quickcoverage: hledgercov \ -# # $(call def-help,quickcoverage,\ -# # display a code coverage text report from running hledger COVCMD\ -# # ) -# # @echo "Generating code coverage text report for hledger command: $(COVCMD)" -# # tools/runhledgercov "report" $(COVCMD) -# # coverage: samplejournals hledgercov \ -# # $(call def-help,coverage,\ -# # generate a code coverage html report from running hledger COVCMD\ -# # ) -# # @echo "Generating code coverage html report for hledger command: $(COVCMD)" -# # tools/runhledgercov "markup --destdir=doc/profs/coverage" $(COVCMD) -# # cd doc/profs/coverage; rm -f index.html; ln -s hpc_index.html index.html -# # viewcoverage: \ -# # $(call def-help,viewcoverage,\ -# # view the last html code coverage report\ -# # ) -# # $(VIEWHTML) doc/profs/coverage/index.html + +# quickcoverage: hledgercov \ +# $(call def-help,quickcoverage,\ +# display a code coverage text report from running hledger COVCMD\ +# ) +# @echo "Generating code coverage text report for hledger command: $(COVCMD)" +# tools/runhledgercov "report" $(COVCMD) +# coverage: samplejournals hledgercov \ +# $(call def-help,coverage,\ +# generate a code coverage html report from running hledger COVCMD\ +# ) +# @echo "Generating code coverage html report for hledger command: $(COVCMD)" +# tools/runhledgercov "markup --destdir=doc/profs/coverage" $(COVCMD) +# cd doc/profs/coverage; rm -f index.html; ln -s hpc_index.html index.html +# viewcoverage: \ +# $(call def-help,viewcoverage,\ +# view the last html code coverage report\ +# ) +# $(VIEWHTML) doc/profs/coverage/index.html # ** Documenting ------------------------------------------------------------ DOCUMENTING: @@ -841,7 +781,6 @@ site: #Shake # ) 2>&1 | tee -a site.log BROWSEDELAY := '5' -#LOCALSITEURL := 'http://localhost:3000/dev/hledger.html' LOCALSITEURL := 'http://localhost:3000/index.html' # open a browser on the website (in ./site) and rerender when docs or web pages change @@ -859,8 +798,8 @@ STACKHADDOCK := 'time ' + STACK + ' --verbosity=error haddock --fast --no-keep-g --only-locals --no-haddock-deps --no-haddock-hyperlink-source \ --haddock-arguments="--no-warnings" \ ' - -# -ghc-options='-optP-P' # workaround for http://trac.haskell.org/haddock/ticket/284 +# workaround for haddock "Module defined in multiple files" trac.haskell.org/haddock/ticket/284 +# -ghc-options='-optP-P' HADDOCKPKGS := 'hledger-lib' @@ -873,6 +812,10 @@ haddock: just haddock just haddock-open +# open the haddock packages contents page in a browser +haddock-open: + {{ BROWSE }} `$STACK path --local-install-root`/doc/index.html + # # Rerenders all hledger packages. Run make haddock-open to open contents page. # haddock-watch1: \ # $(call def-help,haddock-watch, regenerate haddock docs when files change ) @@ -887,21 +830,17 @@ haddock: # $(call def-help,haddock-watch3, quickly regenerate & reload Hledger.hs haddock when files change ) # watchexec -r -e yaml,cabal,hs --print-events --shell=none -- bash -c 'mkdir -p tmp && rm -f tmp/Hledger.html && haddock -h -o tmp hledger-lib/Hledger.hs --no-warnings --no-print-missing-docs 2>&1 | grep -v "Could not find documentation" && open tmp/Hledger.html' -# open the haddock packages contents page in a browser -haddock-open: - {{ BROWSE }} `$STACK path --local-install-root`/doc/index.html - # hoogle-setup: $(call def-help,hoogle-setup, install hoogle then build haddocks and a hoogle db for the project and all deps ) # stack hoogle --rebuild # HOOGLEBROWSER="/Applications/Firefox Dev.app/Contents/MacOS/firefox" # safari not supported # hoogle-serve: $(call def-help,hoogle-serve, run hoogle web app and open in browser after doing setup if needed ) # $(HOOGLEBROWSER) http://localhost:8080 & # stack --verbosity=warn hoogle --server -# # sourcegraph: \ -# # $(call def-help,sourcegraph,\ -# # \ -# # ) -# # for p in $(PACKAGES); do (cd $$p; SourceGraph $$p.cabal); done +# sourcegraph: \ +# $(call def-help,sourcegraph,\ +# \ +# ) +# for p in $(PACKAGES); do (cd $$p; SourceGraph $$p.cabal); done # manuals-watch: Shake \ # $(call def-help,manuals-watch, rerender manuals when their source files change ) # ls $(DOCSOURCEFILES) | entr ./Shake -VV manuals @@ -913,13 +852,13 @@ haddock-open: # shakehelp-watch: \ # $(call def-help,shakehelp-watch, rerender Shake.hs's help when it changes) # ls Shake.hs | entr -c ./Shake.hs -# # The following rule, for updating the website, gets called on hledger.org by: -# # 1. github-post-receive (github webhook handler), when something is pushed -# # to the main or wiki repos on Github. Config: -# # /etc/supervisord.conf -> [program:github-post-receive] -# # /etc/github-post-receive.conf -# # 2. cron, nightly. Config: /etc/crontab -# # 3. manually: "make site" on hledger.org, or "make hledgerorg" elsewhere (cf Makefile.local). +# The following rule, for updating the website, gets called on hledger.org by: +# 1. github-post-receive (github webhook handler), when something is pushed +# to the main or wiki repos on Github. Config: +# /etc/supervisord.conf -> [program:github-post-receive] +# /etc/github-post-receive.conf +# 2. cron, nightly. Config: /etc/crontab +# 3. manually: "make site" on hledger.org, or "make hledgerorg" elsewhere (cf Makefile.local). # Generate packages diagrams for the hledger packages. @packagediags: @@ -1010,6 +949,523 @@ log-push: bin-short: awk '/^----/ { b=!b; next } !b' bin/hledger-script-example.hs | rg -v '^ *-- \w' > bin/hledger-script-example-short.hs +# ** Releasing ------------------------------------------------------------ +RELEASING: + +# Create or switch to this release branch, and set the version string in various places. +relbranch VER: + #!/usr/bin/env bash + set -euo pipefail + [[ -z {{ VER }} ]] && usage + BRANCH=$(just _versionReleaseBranch {{ VER }}) + echo "Switching to $BRANCH, auto-creating it if needed" + just _gitSwitchAutoCreate "$BRANCH" + echo "Setting {{ VER }} in package.yamls and .version.m4 macros" + ./Shake setversion {{ VER }} -c +# Too much at once, allow smaller steps. +# echo "Updating all command help texts for embedding..." +# ./Shake cmddocs -c +# echo "Updating all dates in man pages..." +# ./Shake mandates +# echo "Generating all the manuals in all formats...." +# ./Shake manuals -c +# # echo "Updating CHANGES.md files with latest commits..." +# # ./Shake changelogs $COMMIT + +# update shell completions in hledger package +@completions: + make -C hledger/shell-completion/ + echo "now please commit any changes in hledger/shell-completion/" + +# Make draft release notes from changelogs. Run on release branch. +@relnotes: + just _on-release-branch + tools/relnotes.hs + +# Make git tags for a full release today, but don't push them. Run on release branch. +reltags: + #!/usr/bin/env bash + set -euo pipefail + just _on-release-branch + for p in $PACKAGES; do \ + git tag --force --sign $p-`cat $p/.version` -m "Release $p-`cat $p/.version`"; \ + done + git tag --force --sign `cat .version` -m "Release `cat .version`" + echo "Release has been tagged!" + +# Push the current branch to github binaries branch, generating release binaries. +@relbin: + # assumes the github remote is named "origin" + git push -f origin HEAD:binaries + +# Get the id of the latest run of the named workflow. +@_ghrun-id WORKFLOW: + gh run list --workflow {{ WORKFLOW }} --json databaseId --jq '.[0].databaseId' + +# Browse the latest run of the named workflow. +@ghrun WORKFLOW: + gh run view --web $(just _ghrun-id {{ WORKFLOW }}) + +# Browse the latest run of the main binary workflows. +@ghbin: + just ghrun binaries-linux-x64 + just ghrun binaries-mac-arm64 + just ghrun binaries-mac-x64 + just ghrun binaries-windows-x64 + +# Download any new binaries from the latest runs of the main binary github workflows, and recompress them. +ghbin-download: + mkdir -p tmp + cd tmp; rm -rf hledger-*64 + cd tmp; gh run download $(just _ghrun-id binaries-linux-x64) + cd tmp; gh run download $(just _ghrun-id binaries-mac-arm64) + cd tmp; gh run download $(just _ghrun-id binaries-mac-x64) + cd tmp; gh run download $(just _ghrun-id binaries-windows-x64) + cd tmp; mv */*.tar .; gzip -f *.tar + cd tmp; zip -j hledger-windows-x64.zip hledger-windows-x64/* + cd tmp; rm -rf hledger-*64 + +# Browse the latest github release. +@ghrel: + gh release view -w + +# Upload release notes to the configured github release. (Might also create/publish the release ?) +@ghrel-notes: + just _on-release-branch + doc/ghrelnotes `cat .version` | gh release edit `cat .version` -F- + +# Upload the downloaded binaries to the specified github release. Run after ghbin-download. +ghrel-bin VER: + @read -p "Warning! uploading binaries to release {{ VER }}, are you sure ? Enter to proceed: " + gh release upload --clobber {{ VER }} tmp/hledger-linux-x64.tar.gz + gh release upload --clobber {{ VER }} tmp/hledger-mac-arm64.tar.gz + gh release upload --clobber {{ VER }} tmp/hledger-mac-x64.tar.gz + gh release upload --clobber {{ VER }} tmp/hledger-windows-x64.zip + # gh release upload {{ VER }} tmp/hledger-linux-x64/hledger-linux-x64.tar.gz + # gh release upload {{ VER }} tmp/hledger-mac-arm64/hledger-mac-arm64.tar.gz + # gh release upload {{ VER }} tmp/hledger-mac-x64/hledger-mac-x64.tar.gz + # gh release upload {{ VER }} tmp/hledger-windows-x64/hledger-windows-x64.tar.gz + +# Upload all packages to hackage (run from release branch). +@hackageupload: + tools/hackageupload $PACKAGES + +# Push the 5 release tags for the specified release version. +reltags-push VER: + git push origin {{ VER }} hledger-{{ VER }} hledger-lib-{{ VER }} hledger-ui-{{ VER }} hledger-web-{{ VER }} + +# Push master to github, move the nightly tag there, and start building new nightly binaries. +nightly-push: + #!/usr/bin/env bash + set -euo pipefail + just push + git tag -f nightly master + git push -f origin nightly + git push -f origin master:binaries + echo "Now wait; when nightly binaries have built successfully, run just nightly-bin" + +# Copy the latest-built nightly binaries to the Nightly prerelease. Wait for nightly-push's builds to complete first. +@nightly-bin: + gh workflow run nightly + +# Push the prerelease notes to the github nightly prerelease. +@nightly-notes: + gh release edit nightly -F doc/nightlynotes.md + +# Browse the github nightly prerelease. +@nightly-open: + gh release view -w nightly + +# Point the nightly tag at the latest release, locally and on github. Run after a release. +@nightly-tag-release: + git tag -f nightly $(just relver) + git push -f origin nightly + +# Tag the start of a new dev cycle ("OLDVER.99"), locally and on github. Also update the dev versions/help/manuals. Run on master after a major release. +devtag: + #!/usr/bin/env bash + set -euo pipefail + RELVER=$(just relver) + DEVVER=$RELVER.99 + just _on-master-branch + echo "Creating tag $DEVVER.." + git tag --force --sign "$DEVVER" -m "start of post-$RELVER dev cycle" + echo "Pushing tag $DEVVER.." + git push origin "$DEVVER" + echo "Setting versions to $DEVVER.." + ./Shake setversion "$DEVVER" -c + echo "Setting man page dates to $(date +'%B %Y').." + ./Shake mandates + echo "Regenerating manuals.." + ./Shake manuals -c + echo "Consider also: with $RELVER installed, ./Shake cmddocs -c" + +# ** Installing ------------------------------------------------------------ +INSTALLING: + +# # copy the current ~/.local/bin/hledger to bin/old/hledger-VER +# @copy-as VER: +# cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}" + +# install hledger as bin/old/hledger-VER +@installas VER: + $STACK install --local-bin-path bin/old hledger + for e in hledger ; do mv bin/old/$e bin/old/$e-{{ VER }}; echo "bin/old/$e-{{ VER }}"; done + +# install all hledger executables as bin/old/hledger*-VER +@installallas VER: + $STACK install --local-bin-path bin/old + for e in hledger hledger-ui hledger-web ; do mv bin/old/$e bin/old/$e-{{ VER }}; echo "bin/old/$e-{{ VER }}"; done + +# install hledger with stack traces and ghc-debug support enabled, as bin/hledger*-dbg +@installasdbg *STACKARGS: + $STACK install --local-bin-path bin --flag '*:debug' {{ STACKARGS }} hledger + for e in hledger ; do mv bin/$e bin/$e-dbg; echo "bin/$e-dbg"; done + +# install all hledger executables with stack traces and ghc-debug support enabled, as bin/hledger*-dbg +@installallasdbg *STACKARGS: + $STACK install --local-bin-path bin --flag '*:debug' {{ STACKARGS }} + for e in hledger hledger-ui hledger-web ; do mv bin/$e bin/$e-dbg; echo "bin/$e-dbg"; done + +# On gnu/linux: can't interpolate GTAR here for some reason, and need the shebang line. +# linux / mac only for now, does not handle the windows zip file. +# download github release VER binaries for OS (linux, mac) and ARCH (x64, arm64) to bin/old/hledger*-VER +@installrel VER OS ARCH: + #!/usr/bin/env bash + # if [[ "$OS" == "windows" ]]; then + # cd bin/old && curl -L https://github.com/simonmichael/hledger/releases/download/{{ VER }}/hledger-{{ OS }}-{{ ARCH }}.zip | funzip | `type -P gtar || echo tar` xf - --transform 's/$/-{{ VER }}/' + # else + # fi + cd bin/old && curl -L https://github.com/simonmichael/hledger/releases/download/{{ VER }}/hledger-{{ OS }}-{{ ARCH }}.tar.gz | `type -P gtar || echo tar` xzf - --transform 's/$/-{{ VER }}/' + +# # download recent versions of the hledger executables from github to bin/hledger*-VER +# get-recent-binaries: +# for V in 1.32.2 1.31 1.30 1.29.2 1.28 1.27.1; do just get-binaries $OS x64 $V; done +# just symlink-binaries + +# # add easier symlinks for all the minor hledger releases downloaded by get-binaries. +# symlink-binaries: +# just symlink-binary 1.32.2 +# just symlink-binary 1.29.2 +# just symlink-binary 1.27.1 + +# add an easier symlink for this minor hledger release (hledger-1.29 -> hledger-1.29.2, etc.) +@symlink-binary MINORVER: + cd bin && ln -sf hledger-$MINORVER hledger-`echo $MINORVER | sed -E 's/\.[0-9]+$//'` + +# ** Info ------------------------------------------------------------ +INFO: + +# List git tags approximately most recent first (grouped by package). The available fields vary over time. +tags: + git tag -l --sort=-tag --format='%(refname:short) taggerdate:%(taggerdate:iso8601) committerdate:%(committerdate:iso8601)}' + +# Show the last release date and version (of the hledger package). +@rel: + just rels | head -1 + +# Show last release date (of the hledger package). +@reldate: + awk '/^#+ +[0-9]+\.[0-9].*([0-9]{4}-[0-9]{2}-[0-9]{2})/{print $3;exit}' hledger/CHANGES.md + +# Show the last release version (of the hledger package). +@relver: + just rel | awk '{print $2}' + +# show commit author names since last release +@relauthors: + echo "Commit authors since last release:" + git shortlog -sn `git tag --sort=-creatordate -l '[0-9]*' | head -1`.. + +# Show all release dates and versions (of the hledger package). +@rels: + awk '/^#+ +[0-9]+\.[0-9].*([0-9]{4}-[0-9]{2}-[0-9]{2})/{printf "%s %s\n",$3,$2}' hledger/CHANGES.md + +# Show the release notes for VERSION. +@showrelnotes VER: + awk "/^## .*-${VER//./\\.}$/ {p=1;print;next}; /^## / {p=0}; p" doc/relnotes.md + +# show a precise git-describe version string +@describe: + git describe --tags --match 'hledger-[0-9]*' --dirty + +# show all commit author names +@authors: + echo "Commit authors ($(git shortlog -sn | wc -l | awk '{print $1}'))": + git shortlog -sn + +# show all commit author names and emails +@authorsv: + echo "Commit authors ($(git shortlog -sn | wc -l | awk '{print $1}'))": + git shortlog -sne + +SCC := 'scc -z --cocomo-project-type semi-detached -f wide -s code' + +# count lines of code with scc +scc: + echo "Lines of code including tests:" + {{ SCC }} -i hs,sh,m4,hamlet + +# count lines of code with scc, showing all files +sccv: + echo "Lines of code including tests:" + {{ SCC }} -i hs,sh,m4,hamlet --by-file + +# showreleasestats stats: \ +# showreleasedays \ +# showunreleasedchangecount \ +# showloc \ +# showtestcount \ +# showunittestcoverage \ +# showreleaseauthors \ +# showunreleasedcodechanges \ +# showunpushedchanges \ +# $(call def-help,showreleasestats stats,\ +# show project stats useful for release notes\ +# ) +# # showerrors +# FROMTAG=. +# showreleasedays: \ +# $(call def-help,showreleasedays,\ +# \ +# ) +# @echo Days since last release: +# @tools/dayssincetag.hs $(FROMTAG) | head -1 | cut -d' ' -f-1 +# @echo +# # XXX +# showunreleasedchangecount: \ +# $(call def-help,showunreleasedchangecount,\ +# \ +# ) +# @echo Commits since last release: +# @darcs changes --from-tag $(FROMTAG) --count +# @echo + +# `ls $(SOURCEFILES)` +# sloc: \ +# $(call def-help,sloc,\ +# \ +# ) +# @sloccount hledger-lib hledger hledger-web +# cloc: \ +# $(call def-help,cloc,\ +# \ +# ) +# @echo +# @echo "Lines of code as of `date`:" +# @echo +# @echo "hledger-lib, hledger" +# @cloc -q hledger-lib hledger 2>&1 | grep -v 'defined(' +# @echo +# @echo "hledger-web" +# @cloc -q hledger-web 2>&1 | grep -v 'defined(' +# @echo +# @echo "hledger-lib, hledger, hledger-web" +# @cloc -q hledger-lib hledger hledger-web 2>&1 | grep -v 'defined(' +# showtestcount: \ +# $(call def-help,showtestcount,\ +# \ +# ) +# @echo "Unit tests:" +# @hledger test 2>&1 | cut -d' ' -f2 +# @echo "Functional tests:" +# @make --no-print functest | egrep '^ Total' | awk '{print $$2}' +# @echo +# showunittestcoverage: \ +# $(call def-help,showunittestcoverage,\ +# \ +# ) +# @echo Unit test coverage: +# @make --no-print quickcoverage | grep 'expressions' +# @echo +# # showerrors: +# # @echo Known errors: +# # @awk '/^** errors/, /^** / && !/^** errors/' NOTES.org | grep '^\*\*\* ' | tail +1 +# # @echo +# # XXX +# showunpushedchanges showunpushed: \ +# $(call def-help,showunpushedchanges showunpushed,\ +# \ +# ) +# @echo "Changes not yet pushed upstream (to `darcs show repo | grep 'Default Remote' | cut -c 17-`):" +# @-darcs push simon@joyful.com:/repos/hledger --dry-run | grep '*' | tac +# @echo +# # XXX +# showunreleasedcodechanges showunreleased showchanges: \ +# $(call def-help,showunreleasedcodechanges showunreleased showchanges,\ +# \ +# ) +# @echo "hledger code changes since last release:" +# @darcs changes --from-tag $(FROMTAG) --matches "not (name docs: or name doc: or name site: or name tools:)" | grep '*' +# @echo +# # XXX +# showcodechanges: \ +# $(call def-help,showcodechanges,\ +# \ +# ) +# @echo "hledger code changes:" +# @darcs changes --matches "not (name docs: or name site: or name tools:)" | egrep '^ +(\*|tagged)' +# @echo +# nix-hledger-version: $(call def-help,nix-hledger-version, show which version of hledger has reached nixpkgs) +# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger"' +# nix-hledger-versions: $(call def-help,nix-hledger-versions, show versions of all hledger packages in nixpkgs) +# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger' +# nix-view-commits: $(call def-help,nix-view-commits, show recent haskell commits in nixpkgs) +# @open 'https://github.com/NixOS/nixpkgs/commits/master/pkgs/development/haskell-modules/hackage-packages.nix' +# list-commits: $(call def-help,list-commits, list all commits chronologically and numbered) +# @git log --format='%ad %h %s (%an)' --date=short --reverse | cat -n + +# show upcoming planned dated tasks +schedule *PERIOD: + #!/usr/bin/env osh + P={{ if PERIOD == '' { 'today..30days' } else { PERIOD } }} + hledger -f doc/SCHEDULE print --forecast=$P + +# show recent branches summary with jj +@branches: + echo "Recent branches:" + bash -ic 'jjb | head -20' + +# show recent branches detail with jj +@branchesv: + echo "Recent branches (commits):" + jj log -n 40 -r 'log_default ~ @' + +# Show activity over the last N days (eg 7), for This Week In Hledger. +@_lastweek DAYS: + echo "hledger time last $DAYS days including today (this should be run on a Friday):" + tt bal hledger -DTS -b "$DAYS days ago" --drop 2 + echo + echo "By activity type, percentage:" + tt bal hledger -DTS -b "$DAYS days ago" --pivot t -% -c 1% | tail +1 + echo + echo "Time log details:" + tt print hledger -b "$DAYS days ago" | grep -E '^[^ ]|hledger' + echo + echo "main repo:" + git log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="$DAYS days ago" --reverse + echo + echo "site repo:" + git -C site log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="$DAYS days ago" --reverse + echo + echo "finance repo:" + git -C finance log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="$DAYS days ago" --reverse + echo + +# show the sorted, unique files matched by SOURCEFILES +@_listsourcefiles: + for f in $SOURCEFILES; do echo $f; done | sort | uniq + +# show the sorted, unique subdirectories containing hs files +@_listsourcedirs: + find . -name '*hs' | sed -e 's%[^/]*hs$%%' | sort | uniq + +# show the ghc versions used by all stack files +@_listghcversions: + for F in stack*.yaml; do $STACK --stack-yaml=$F --no-install-ghc exec -- ghc --version; done 2>&1 | grep -v 'To install the correct GHC' + +# Show a bunch of debug messages. +@_dbgmsgs: + rg --sort path -t hs 'dbg.*?(".*")' -r '$1' -o + +# # Extract Hledger.hs examples to jargon.j. +# @_jargon: +# rg '^ *> (.*)' -or '$1' hledger-lib/Hledger.hs > jargon.j +# echo "wrote jargon.j" + +# Extract ledger/hledger/beancount commit stats to project-commits.j. +@_projectcommits: + # https://hledger.org/reporting-version-control-stats.html + printf "account ledger\naccount hledger\naccount beancount\n\n" >project-commits.j + for p in ledger hledger beancount; do git -C ../$p log --format="%cd (%h) %s%n ($p) 1%n" --date=short --reverse >> project-commits.j; done + echo "wrote project-commits.j" + +# show some big directory sizes +@usage: + -du -sh .git bin data doc extra `find . -name '.stack*' -prune -o -name 'dist' -prune -o -name 'dist-newstyle' -prune` 2>/dev/null | sort -hr + +# hledger time report +time *ARGS: + hledger -n -f $TIMEDIR/time-all.journal bal hledger -YTA --transpose -0 {{ ARGS }} + +# *** hledger version number helpers +# (as hidden recipes, since just doesn't support global custom functions) +# See doc/RELEASING.md > Glossary. + +# First 0-2 parts of a dotted version number. +@_versionMajorPart VER: + echo {{ replace_regex(VER, '(\d+(\.\d+)?).*', '$1') }} + +# Third part of a dotted version number, if any. +@_versionMinorPart VER: + echo {{ if VER =~ '\d+(\.\d+){2,}' { replace_regex(VER, '\d+\.\d+\.(\d+).*', '$1') } else { '' } }} + +# Fourth part of a dotted version number, if any. +@_versionFourthPart VER: + echo {{ if VER =~ '\d+(\.\d+){3,}' { replace_regex(VER, '\d+(\.\d+){2}\.(\d+).*', '$2') } else { '' } }} + +# Does this dotted version number have a .99 third part and no fourth part ? +@_versionIsDev VER: + echo {{ if VER =~ '(\d+\.){2}99$' { 'y' } else { '' } }} + +# Does this dotted version number have a .99 third part and a fourth part ? +@_versionIsPreview VER: + echo {{ if VER =~ '(\d+\.){2}99\.\d+' { 'y' } else { '' } }} + +# Increment a major version number to the next. +# @majorVersionIncrement MAJORVER: +# python3 -c "print({{MAJORVER}} + 0.01)" + +# Appropriate release branch name for the given version number. +_versionReleaseBranch VER: + #!/usr/bin/env bash + MAJOR=$(just _versionMajorPart {{ VER }}) + if [[ $(just _versionIsDev {{ VER }}) == y ]] then + echo "{{ VER }} is not a releasable version" >&2 + exit 1 + elif [[ $(just _versionIsPreview {{ VER }}) == y ]] then + # echo "$(just majorVersionIncrement "$MAJOR")-branch" + echo "{{ VER }} is not a releasable version" >&2 + exit 1 + else + echo "$MAJOR-branch" + fi + +# *** git helpers + +# Does the named branch exist in this git repo ? +@_gitBranchExists BRANCH: + git branch -l {{ BRANCH }} | grep -q {{ BRANCH }} + +# Switch to the named git branch, creating it if it doesn't exist. +_gitSwitchAutoCreate BRANCH: + #!/usr/bin/env bash + if just _gitBranchExists {{ BRANCH }}; then + git switch {{ BRANCH }} + else + git switch -c {{ BRANCH }} + fi + +# Check that we're on a release branch. (Hopefully the latest.) +_on-release-branch: + #!/usr/bin/env bash + set -euo pipefail + BRANCH=$(git branch --show-current) + if [[ ! $BRANCH =~ ^[0-9.]*-branch ]]; then + echo "You are currently on $BRANCH branch. Please switch to the latest release branch." + exit 1 + fi + +# Check that we're on the master branch. +_on-master-branch: + #!/usr/bin/env bash + set -euo pipefail + BRANCH=$(git branch --show-current) + if [[ ! $BRANCH =~ master ]]; then + echo "You are currently on $BRANCH branch. Please switch to the master branch." + exit 1 + fi + # ** News ------------------------------------------------------------ NEWS: @@ -1170,471 +1626,20 @@ bloglog: echo "** pta.o: https://plaintextaccounting.org/#`date +%Y`" echo -# # Some evil works against this.. -# # echo "open https://www.reddit.com/r/plaintextaccounting/new, copy links since $DAYS days ago ($DATE), paste into obsidian, select, cut, and paste here for cleaning (in emacs shell use C-c C-d, C-c C-r)" -# # just redditclean > $$.tmp -# # printf "\n\n\n\n\n" -# # cat $$.tmp -# # rm -f $$.tmp -# # -# # Clean links copied from old.reddit.com. +# Some evil works against this.. +# echo "open https://www.reddit.com/r/plaintextaccounting/new, copy links since $DAYS days ago ($DATE), paste into obsidian, select, cut, and paste here for cleaning (in emacs shell use C-c C-d, C-c C-r)" +# just redditclean > $$.tmp +# printf "\n\n\n\n\n" +# cat $$.tmp +# rm -f $$.tmp +# +# Clean links copied from old.reddit.com. # @redditclean: # rg '^(\[.*?]\([^\)]+\)).*self.plaintextaccounting' -or '- $1\n' - -# ** Releasing ------------------------------------------------------------ -RELEASING: - -# Create or switch to this release branch, and set the version string in various places. -relbranch VER: - #!/usr/bin/env bash - set -euo pipefail - [[ -z {{ VER }} ]] && usage - BRANCH=$(just _versionReleaseBranch {{ VER }}) - echo "Switching to $BRANCH, auto-creating it if needed" - just _gitSwitchAutoCreate "$BRANCH" - echo "Setting {{ VER }} in package.yamls and .version.m4 macros" - ./Shake setversion {{ VER }} -c -# Too much at once, allow smaller steps. -# echo "Updating all command help texts for embedding..." -# ./Shake cmddocs -c -# echo "Updating all dates in man pages..." -# ./Shake mandates -# echo "Generating all the manuals in all formats...." -# ./Shake manuals -c -# # echo "Updating CHANGES.md files with latest commits..." -# # ./Shake changelogs $COMMIT - -# Push the current branch to github and generate release binaries from it. -@relbin: - # assumes the github remote is named "origin" - git push -f origin HEAD:binaries - -# Push master to github, move the nightly tag there, and start building new nightly binaries. -nightly-push: - #!/usr/bin/env bash - set -euo pipefail - just push - git tag -f nightly master - git push -f origin nightly - git push -f origin master:binaries - echo "Now wait; when nightly binaries have built successfully, run just nightly-bin" - -# Copy the latest-built nightly binaries to the Nightly prerelease. Wait for nightly-push's builds to complete first. -@nightly-bin: - gh workflow run nightly - -# Push the prerelease notes to the github nightly prerelease. -@nightly-notes: - gh release edit nightly -F doc/nightlynotes.md - -# Browse the github nightly prerelease. -@nightly-open: - gh release view -w nightly - -# Show the last release date and version (of the hledger package). -@rel: - just rels | head -1 - -# Show last release date (of the hledger package). -@reldate: - awk '/^#+ +[0-9]+\.[0-9].*([0-9]{4}-[0-9]{2}-[0-9]{2})/{print $3;exit}' hledger/CHANGES.md - -# Show the last release version (of the hledger package). -@relver: - just rel | awk '{print $2}' - -# show commit author names since last release -@relauthors: - echo "Commit authors since last release:" - git shortlog -sn `git tag --sort=-creatordate -l '[0-9]*' | head -1`.. - -# Show all release dates and versions (of the hledger package). -@rels: - awk '/^#+ +[0-9]+\.[0-9].*([0-9]{4}-[0-9]{2}-[0-9]{2})/{printf "%s %s\n",$3,$2}' hledger/CHANGES.md - -# *** hledger version number helpers -# (as hidden recipes, since just doesn't support global custom functions) -# See doc/RELEASING.md > Glossary. - -# First 0-2 parts of a dotted version number. -@_versionMajorPart VER: - echo {{ replace_regex(VER, '(\d+(\.\d+)?).*', '$1') }} - -# Third part of a dotted version number, if any. -@_versionMinorPart VER: - echo {{ if VER =~ '\d+(\.\d+){2,}' { replace_regex(VER, '\d+\.\d+\.(\d+).*', '$1') } else { '' } }} - -# Fourth part of a dotted version number, if any. -@_versionFourthPart VER: - echo {{ if VER =~ '\d+(\.\d+){3,}' { replace_regex(VER, '\d+(\.\d+){2}\.(\d+).*', '$2') } else { '' } }} - -# Does this dotted version number have a .99 third part and no fourth part ? -@_versionIsDev VER: - echo {{ if VER =~ '(\d+\.){2}99$' { 'y' } else { '' } }} - -# Does this dotted version number have a .99 third part and a fourth part ? -@_versionIsPreview VER: - echo {{ if VER =~ '(\d+\.){2}99\.\d+' { 'y' } else { '' } }} - -# Increment a major version number to the next. -# @majorVersionIncrement MAJORVER: -# python3 -c "print({{MAJORVER}} + 0.01)" - -# Appropriate release branch name for the given version number. -_versionReleaseBranch VER: - #!/usr/bin/env bash - MAJOR=$(just _versionMajorPart {{ VER }}) - if [[ $(just _versionIsDev {{ VER }}) == y ]] then - echo "{{ VER }} is not a releasable version" >&2 - exit 1 - elif [[ $(just _versionIsPreview {{ VER }}) == y ]] then - # echo "$(just majorVersionIncrement "$MAJOR")-branch" - echo "{{ VER }} is not a releasable version" >&2 - exit 1 - else - echo "$MAJOR-branch" - fi - -# *** git helpers - -# Does the named branch exist in this git repo ? -@_gitBranchExists BRANCH: - git branch -l {{ BRANCH }} | grep -q {{ BRANCH }} - -# Switch to the named git branch, creating it if it doesn't exist. -_gitSwitchAutoCreate BRANCH: - #!/usr/bin/env bash - if just _gitBranchExists {{ BRANCH }}; then - git switch {{ BRANCH }} - else - git switch -c {{ BRANCH }} - fi - -# # old/desired release process: -# # a normal release: echo 0.7 >.version; make release -# # a bugfix release: echo 0.7.1 >.version; make release -# #release: releasetest bumpversion tagrelease $(call def-help,release, prepare and test a release and tag the repo ) -# #publish: hackageupload pushtags $(call def-help,upload, publish latest hackage packages and push tags to github ) -# #releaseandpublish: release upload $(call def-help,releaseandpublish, release and upload and publish updated docs ) -# ISCLEAN=git diff-index --quiet HEAD -- -# # stop if the working directory has uncommitted changes -# iscleanwd: -# @$(ISCLEAN) || (echo "please clean the working directory first"; false) -# # stop if the given file(s) have uncommitted changes -# isclean-%: -# @$(ISCLEAN) $* || (echo "please clean these files first: $*"; false) - -# # Update all cabal files based on latest package.yaml files using a specific hpack version. -# # To avoid warnings, this should be the same version as stack's built-in hpack. -# cabal-with-hpack-%: -# $(STACK) build --with-hpack hpack-$* --dry-run --silent -# # updatecabal: gencabal $(call def-help,updatecabal, regenerate cabal files and commit ) -# # @read -p "please review changes then press enter to commit $(shell ls */*.cabal)" -# # git commit -m "update cabal files" $(shell ls */*.cabal) -# # we use shake for this job; so dependencies aren't checked here -# manuals: Shake $(call def-help,manuals, regenerate and commit CLI help and manuals (might need -B) ) -# ./Shake manuals -# git commit -m ";doc: regen manuals" -m "[ci skip]" hledger*/hledger*.{1,5,info,txt} hledger/Hledger/Cli/Commands/*.txt -# tag: $(call def-help,tag, make git release tags for the project and all packages ) -# @for p in $(PACKAGES); do make tag-$$p; done -# @make tag-project -# tag-%: $(call def-help,tag-PKG, make a git release tag for PKG ) -# git tag -fs $*-`cat $*/.version` -m "Release $*-`cat $*/.version`" -# tag-project: $(call def-help,tag-project, make a git release tag for the project as a whole ) -# git tag -fs `cat .version` -m "Release `cat .version`, https://hledger.org/release-notes.html#hledger-`cat .version | sed -e 's/\./-/g'`" -# @printf "if tagging a major release, please also review and run this command:\n" -# @printf " git tag -fs `cat .version`.99 master -m \"Start of next release cycle. This tag influences git describe and dev builds' version strings.\"\n" -# # hackageupload-dry: \ -# # $(call def-help,hackageupload-dry,\ -# # upload all packages to hackage; dry run\ -# # ) -# # for p in $(PACKAGES); do cabal upload $$p/dist/$$p-$(VERSION).tar.gz -v2 --check; done -# hackageupload: \ -# $(call def-help,hackageupload, upload all packages to hackage from a release branch) -# tools/hackageupload $(PACKAGES) -# # showreleasestats stats: \ -# # showreleasedays \ -# # showunreleasedchangecount \ -# # showloc \ -# # showtestcount \ -# # showunittestcoverage \ -# # showreleaseauthors \ -# # showunreleasedcodechanges \ -# # showunpushedchanges \ -# # $(call def-help,showreleasestats stats,\ -# # show project stats useful for release notes\ -# # ) -# # # showerrors -# # FROMTAG=. -# # showreleasedays: \ -# # $(call def-help,showreleasedays,\ -# # \ -# # ) -# # @echo Days since last release: -# # @tools/dayssincetag.hs $(FROMTAG) | head -1 | cut -d' ' -f-1 -# # @echo -# # # XXX -# # showunreleasedchangecount: \ -# # $(call def-help,showunreleasedchangecount,\ -# # \ -# # ) -# # @echo Commits since last release: -# # @darcs changes --from-tag $(FROMTAG) --count -# # @echo - -# show a precise git-describe version string -@describe: - git describe --tags --match 'hledger-[0-9]*' --dirty - -# show all commit author names -@authors: - echo "Commit authors ($(git shortlog -sn | wc -l | awk '{print $1}'))": - git shortlog -sn - -# show all commit author names and emails -@authorsv: - echo "Commit authors ($(git shortlog -sn | wc -l | awk '{print $1}'))": - git shortlog -sne - -SCC := 'scc -z --cocomo-project-type semi-detached -f wide -s code' - -# count lines of code with scc -scc: - echo "Lines of code including tests:" - {{ SCC }} -i hs,sh,m4,hamlet - -# count lines of code with scc, showing all files -sccv: - echo "Lines of code including tests:" - {{ SCC }} -i hs,sh,m4,hamlet --by-file - -# # `ls $(SOURCEFILES)` -# # sloc: \ -# # $(call def-help,sloc,\ -# # \ -# # ) -# # @sloccount hledger-lib hledger hledger-web -# # cloc: \ -# # $(call def-help,cloc,\ -# # \ -# # ) -# # @echo -# # @echo "Lines of code as of `date`:" -# # @echo -# # @echo "hledger-lib, hledger" -# # @cloc -q hledger-lib hledger 2>&1 | grep -v 'defined(' -# # @echo -# # @echo "hledger-web" -# # @cloc -q hledger-web 2>&1 | grep -v 'defined(' -# # @echo -# # @echo "hledger-lib, hledger, hledger-web" -# # @cloc -q hledger-lib hledger hledger-web 2>&1 | grep -v 'defined(' -# # showtestcount: \ -# # $(call def-help,showtestcount,\ -# # \ -# # ) -# # @echo "Unit tests:" -# # @hledger test 2>&1 | cut -d' ' -f2 -# # @echo "Functional tests:" -# # @make --no-print functest | egrep '^ Total' | awk '{print $$2}' -# # @echo -# # showunittestcoverage: \ -# # $(call def-help,showunittestcoverage,\ -# # \ -# # ) -# # @echo Unit test coverage: -# # @make --no-print quickcoverage | grep 'expressions' -# # @echo -# # # showerrors: -# # # @echo Known errors: -# # # @awk '/^** errors/, /^** / && !/^** errors/' NOTES.org | grep '^\*\*\* ' | tail +1 -# # # @echo -# # # XXX -# # showunpushedchanges showunpushed: \ -# # $(call def-help,showunpushedchanges showunpushed,\ -# # \ -# # ) -# # @echo "Changes not yet pushed upstream (to `darcs show repo | grep 'Default Remote' | cut -c 17-`):" -# # @-darcs push simon@joyful.com:/repos/hledger --dry-run | grep '*' | tac -# # @echo -# # # XXX -# # showunreleasedcodechanges showunreleased showchanges: \ -# # $(call def-help,showunreleasedcodechanges showunreleased showchanges,\ -# # \ -# # ) -# # @echo "hledger code changes since last release:" -# # @darcs changes --from-tag $(FROMTAG) --matches "not (name docs: or name doc: or name site: or name tools:)" | grep '*' -# # @echo -# # # XXX -# # showcodechanges: \ -# # $(call def-help,showcodechanges,\ -# # \ -# # ) -# # @echo "hledger code changes:" -# # @darcs changes --matches "not (name docs: or name site: or name tools:)" | egrep '^ +(\*|tagged)' -# # @echo -# nix-hledger-version: $(call def-help,nix-hledger-version, show which version of hledger has reached nixpkgs) -# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger"' -# nix-hledger-versions: $(call def-help,nix-hledger-versions, show versions of all hledger packages in nixpkgs) -# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger' -# nix-view-commits: $(call def-help,nix-view-commits, show recent haskell commits in nixpkgs) -# @open 'https://github.com/NixOS/nixpkgs/commits/master/pkgs/development/haskell-modules/hackage-packages.nix' -# list-commits: $(call def-help,list-commits, list all commits chronologically and numbered) -# @git log --format='%ad %h %s (%an)' --date=short --reverse | cat -n - -# update shell completions in hledger package -@completions: - make -C hledger/shell-completion/ - echo "now please commit any changes in hledger/shell-completion/" - -# Check that we're on a release branch. (Hopefully the latest.) -_on-release-branch: - #!/usr/bin/env bash - set -euo pipefail - BRANCH=$(git branch --show-current) - if [[ ! $BRANCH =~ ^[0-9.]*-branch ]]; then - echo "You are currently on $BRANCH branch. Please switch to the latest release branch." - exit 1 - fi - -# Check that we're on the master branch. -_on-master-branch: - #!/usr/bin/env bash - set -euo pipefail - BRANCH=$(git branch --show-current) - if [[ ! $BRANCH =~ master ]]; then - echo "You are currently on $BRANCH branch. Please switch to the master branch." - exit 1 - fi - -# Make draft release notes from changelogs. Run on release branch. -@relnotes: - just _on-release-branch - tools/relnotes.hs - -# Show the release notes for VERSION. -@showrelnotes VER: - awk "/^## .*-${VER//./\\.}$/ {p=1;print;next}; /^## / {p=0}; p" doc/relnotes.md - -# Browse the latest github release. -@ghrel: - gh release view -w - -# Generate github release notes for the current release branch and push them to the corresponding github release. Run on release branch. Note, might also create or publish the release. -@ghrel-notes: - just _on-release-branch - doc/ghrelnotes `cat .version` | gh release edit `cat .version` -F- - -# Upload the downloaded binaries to the specified github release. Run after ghbin-download. -ghrel-bin VER: - @read -p "Warning! uploading binaries to release {{ VER }}, are you sure ? Enter to proceed: " - gh release upload --clobber {{ VER }} tmp/hledger-linux-x64.tar.gz - gh release upload --clobber {{ VER }} tmp/hledger-mac-arm64.tar.gz - gh release upload --clobber {{ VER }} tmp/hledger-mac-x64.tar.gz - gh release upload --clobber {{ VER }} tmp/hledger-windows-x64.zip - # gh release upload {{ VER }} tmp/hledger-linux-x64/hledger-linux-x64.tar.gz - # gh release upload {{ VER }} tmp/hledger-mac-arm64/hledger-mac-arm64.tar.gz - # gh release upload {{ VER }} tmp/hledger-mac-x64/hledger-mac-x64.tar.gz - # gh release upload {{ VER }} tmp/hledger-windows-x64/hledger-windows-x64.tar.gz - -# Get the id of the latest run of the named workflow. -@ghrun-id WORKFLOW: - gh run list --workflow {{ WORKFLOW }} --json databaseId --jq '.[0].databaseId' - -# Browse the latest run of the named workflow. -@ghrun WORKFLOW: - gh run view --web $(just ghrun-id {{ WORKFLOW }}) - -# Browse the latest run of the main binary workflows. -@ghbin: - just ghrun binaries-linux-x64 - just ghrun binaries-mac-arm64 - just ghrun binaries-mac-x64 - just ghrun binaries-windows-x64 - -# Download any new binaries from the latest runs of the main binary github workflows, and recompress them. -ghbin-download: - mkdir -p tmp - cd tmp; rm -rf hledger-*64 - cd tmp; gh run download $(just ghrun-id binaries-linux-x64) - cd tmp; gh run download $(just ghrun-id binaries-mac-arm64) - cd tmp; gh run download $(just ghrun-id binaries-mac-x64) - cd tmp; gh run download $(just ghrun-id binaries-windows-x64) - cd tmp; mv */*.tar .; gzip -f *.tar - cd tmp; zip -j hledger-windows-x64.zip hledger-windows-x64/* - cd tmp; rm -rf hledger-*64 - -# Make git tags for a full release today, but don't push them. Run on release branch. -reltags: - #!/usr/bin/env bash - set -euo pipefail - just _on-release-branch - for p in $PACKAGES; do \ - git tag --force --sign $p-`cat $p/.version` -m "Release $p-`cat $p/.version`"; \ - done - git tag --force --sign `cat .version` -m "Release `cat .version`" - echo "Release has been tagged!" - -# Push the 5 release tags for the specified release version. -reltags-push VER: - git push origin {{ VER }} hledger-{{ VER }} hledger-lib-{{ VER }} hledger-ui-{{ VER }} hledger-web-{{ VER }} - -# Point the nightly tag at the latest release, locally and on github. Run after a release. -@nightly-tag-release: - git tag -f nightly $(just relver) - git push -f origin nightly - -# Tag the start of a new dev cycle ("OLDVER.99"), locally and on github. Also update the dev versions/help/manuals. Run on master after a major release. -devtag: - #!/usr/bin/env bash - set -euo pipefail - RELVER=$(just relver) - DEVVER=$RELVER.99 - just _on-master-branch - echo "Creating tag $DEVVER.." - git tag --force --sign "$DEVVER" -m "start of post-$RELVER dev cycle" - echo "Pushing tag $DEVVER.." - git push origin "$DEVVER" - echo "Setting versions to $DEVVER.." - ./Shake setversion "$DEVVER" -c - echo "Setting man page dates to $(date +'%B %Y').." - ./Shake mandates - echo "Regenerating manuals.." - ./Shake manuals -c - echo "Consider also: with $RELVER installed, ./Shake cmddocs -c" - -# List git tags approximately most recent first (grouped by package). The available fields vary over time. -tags: - git tag -l --sort=-tag --format='%(refname:short) taggerdate:%(taggerdate:iso8601) committerdate:%(committerdate:iso8601)}' - -# XXX Run this only after .version has been updated to NEWVER -# @reltagmaster: -# git tag -fs `cat .version`.99 master -m "start of next release cycle" - -# Upload all packages to hackage (run from release branch). -@hackageupload: - tools/hackageupload $PACKAGES - - # ** Misc ------------------------------------------------------------ MISC: -# show upcoming planned dated tasks -schedule *PERIOD: - #!/usr/bin/env osh - P={{ if PERIOD == '' { 'today..30days' } else { PERIOD } }} - hledger -f doc/SCHEDULE print --forecast=$P - -# show recent branches summary with jj -@branches: - echo "Recent branches:" - bash -ic 'jjb | head -20' - -# show recent branches detail with jj -@branchesv: - echo "Recent branches (commits):" - jj log -n 40 -r 'log_default ~ @' - # run tests locally, push master to github ci, wait for tests to pass there, refreshing every INTERVAL (default:10s), then push to github master. @push *INTERVAL: just functest --hide && tools/push {{ INTERVAL }} @@ -1647,54 +1652,12 @@ schedule *PERIOD: # @({{ SHELLTEST }} checks \ # && echo $@ PASSED) || echo $@ FAILED -# Show activity over the last N days (eg 7), for This Week In Hledger. -@_lastweek DAYS: - echo "hledger time last $DAYS days including today (this should be run on a Friday):" - tt bal hledger -DTS -b "$DAYS days ago" --drop 2 - echo - echo "By activity type, percentage:" - tt bal hledger -DTS -b "$DAYS days ago" --pivot t -% -c 1% | tail +1 - echo - echo "Time log details:" - tt print hledger -b "$DAYS days ago" | grep -E '^[^ ]|hledger' - echo - echo "main repo:" - git log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="$DAYS days ago" --reverse - echo - echo "site repo:" - git -C site log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="$DAYS days ago" --reverse - echo - echo "finance repo:" - git -C finance log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="$DAYS days ago" --reverse - echo - -# show the sorted, unique files matched by SOURCEFILES -@_listsourcefiles: - for f in $SOURCEFILES; do echo $f; done | sort | uniq - -# show the sorted, unique subdirectories containing hs files -@_listsourcedirs: - find . -name '*hs' | sed -e 's%[^/]*hs$%%' | sort | uniq - -# show the ghc versions used by all stack files -@_listghcversions: - for F in stack*.yaml; do $STACK --stack-yaml=$F --no-install-ghc exec -- ghc --version; done 2>&1 | grep -v 'To install the correct GHC' - -# Show a bunch of debug messages. -@_dbgmsgs: - rg --sort path -t hs 'dbg.*?(".*")' -r '$1' -o - -# # Extract Hledger.hs examples to jargon.j. -# @_jargon: -# rg '^ *> (.*)' -or '$1' hledger-lib/Hledger.hs > jargon.j -# echo "wrote jargon.j" - -# Extract ledger/hledger/beancount commit stats to project-commits.j. -@_projectcommits: - # https://hledger.org/reporting-version-control-stats.html - printf "account ledger\naccount hledger\naccount beancount\n\n" >project-commits.j - for p in ledger hledger beancount; do git -C ../$p log --format="%cd (%h) %s%n ($p) 1%n" --date=short --reverse >> project-commits.j; done - echo "wrote project-commits.j" +# sym-link some directories required by hledger-web dev builds +symlink-web-dirs: + echo "#ln -sf hledger-web/config # disabled, causes makeinfo warnings" + ln -sf hledger-web/messages + ln -sf hledger-web/static + ln -sf hledger-web/templates # symlink tools/commitlint as .git/hooks/commit-msg installcommithook: @@ -1704,10 +1667,6 @@ installcommithook: Shake: # Shake.hs ./Shake.hs -# show some big directory sizes -@usage: - -du -sh .git bin data doc extra `find . -name '.stack*' -prune -o -name 'dist' -prune -o -name 'dist-newstyle' -prune` 2>/dev/null | sort -hr - # Files to include in emacs TAGS file: # 1. haskell source files with hasktags -e (or ctags -aeR) # 2. other source files recognised by (exuberant) ctags and not excluded by .ctags. Keep .ctags up to date. @@ -1741,7 +1700,3 @@ TAGFILES := WEBTEMPLATEFILES + DOCSOURCEFILES + TESTFILES + HPACKFILES + CABALFI # $(call def-help,Clean, thorough cleanup (stack/ghc leftovers/tags) ) # # reverse = $(if $(wordlist 2,2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1))) $(firstword $(1)),$(1)) -# hledger time report -time *ARGS: - hledger -n -f $TIMEDIR/time-all.journal bal hledger -YTA --transpose -0 {{ ARGS }} -