Weekly Shaarli

All links of one week in a single page.

Week 29 (July 14, 2025)

List repos by number of commits

Number of commits in a git repo can be used as a quick-and-dirty proxy of amount of development time spent in a repo. For variations on this theme, see my previous linkpost.

Here's the bash one-liner I wrote and a few lines of its output:

taha@luxor:~
$ THISPATH="/media/bay/taha/projects/ansible/pub/roles"; find "$THISPATH" -maxdepth 2 -iname ".git" -type d -exec bash -c \
"git -C {} rev-list --count --all | tr '\n' '\t'; echo -e ' ${BGreen}${On_Black}{}${Color_Off}' | \
sed 's+/.git++' | sed 's+$THISPATH/++'" \; | sort -n --reverse -
91   dotfiles
42   R
39   lxd-server
36   python3
36   i3wm
Explainer
  • We will look for git repos inside the /media/bay/taha/projects/ansible/pub/roles directory, and since this path needs to be referenced twice more in the command we can DRY by defining a local var $THISPATH.
  • some roles may contain git submodules, so to avoid including them here we limit depth to only include the top-level .git directory (which is 2 levels down from the search path).
  • get the number of commits (across all branches and authors) for each repo.
  • tr replaces the trailing newline (introduced by output from git -C ...) with a tab so that number and repo name (which we print next) show on the same line.
  • echo -e ' {}' the name of the current repo. I added some colouring for flourish.
  • to save on repitition in the output replace full path returned by find by stripping the trailing .git part as well as the dirname part. Note that this is just my cosmetic preference.
  • sort by numeric value -n and list in --reverse order. Note the trailing dash which references the output from before the pipe.
Links
Ansible gotchas for the forgetful developer

include_tasks files that in turn contain import_tasks cause cryptic errors

It appears to be good practice to avoid using import_tasks in a file if the file itself was included with include_tasks.

If you do you will get a cryptic error message like:

# ERROR! Unexpected Exception, this is probably a bug: expected str, bytes or os.PathLike object, not NoneType