Good Git commit
Something about writing good git commit msgs.
My favourite Git commit
https://dhwthompson.com/2019/my-favourite-git-commit
Git commit messages can tell us many things. Dan Carley wrote a good commit message about "Convert template to US-ASCII to fix error
":
1I introduced some tests in a feature branch to match the contents of
2`/etc/nginx/router_routes.conf`. They worked fine when run with `bundle exec
3rake spec` or `bundle exec rspec modules/router/spec`. But when run as
4`bundle exec rake` each should block failed with:
5
6 ArgumentError:
7 invalid byte sequence in US-ASCII
8
9I eventually found that removing the `.with_content(//)` matchers made the
10errors go away. That there weren't any weird characters in the spec file. And
11that it could be reproduced by requiring Puppet in the same interpreter with:
12
13 rake -E 'require "puppet"' spec
14
15That particular template appears to be the only file in our codebase with an
16identified encoding of `utf-8`. All others are `us-ascii`:
17
18 dcarley-MBA:puppet dcarley$ find modules -type f -exec file --mime {} \+ | grep utf
19 modules/router/templates/routes.conf.erb: text/plain; charset=utf-8
20
21Attempting to convert that file back to US-ASCII identified the offending
22character as something that looked like a whitespace:
23
24 dcarley-MBA:puppet dcarley$ iconv -f UTF8 -t US-ASCII modules/router/templates/routes.conf.erb 2>&1 | tail -n5
25 proxy_intercept_errors off;
26
27 # Set proxy timeout to 50 seconds as a quick fix for problems
28 #
29 iconv: modules/router/templates/routes.conf.erb:458:3: cannot convert
30
31After replacing it (by hand) the file identifies as `us-ascii` again:
32
33 dcarley-MBA:puppet dcarley$ file --mime modules/router/templates/routes.conf.erb
34 modules/router/templates/routes.conf.erb: text/plain; charset=us-ascii
35
36Now the tests work! One hour of my life I won't get back..
Write a commit is to comunicate, is to get work done and tell people about it.
Telling stories through your commits
- Make atomic commits.
- Write good commit messages.
- Revise your development history before sharing