Files @ ba6418fde72f
Branch filter:

Location: kallithea/scripts/whitespacecleanup.sh

Mads Kiilerich
git: more elegant handling of installed pre/post-receive hook failing on direct repo access

The hook would fail with a long backtrace when get_hook_environment raise an error exception.

Instead, as first thing in the entry point from the hook, catch that situation
and report it nicely before "quietly" skipping the hook:

[mk@here myrepo]$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 204 bytes | 204.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Skipping Kallithea Git post-recieve hook 'hooks/post-receive'.
remote: Git was apparently not invoked by Kallithea: Environment variable KALLITHEA_EXTRAS not found
To /tmp/somerepo
* [new branch] master -> master
[mk@here myrepo]$

We could be paranoid and let it (and the pre hook) fail ... but that doesn't
seem helpful.

Reported by Edmund Wong at [1].

[1] https://lists.sfconservancy.org/pipermail/kallithea-general/2019q4/003071.html
#!/bin/bash -x

# Enforce some consistency in whitespace - just to avoid spurious whitespaces changes

files=`hg mani | egrep -v '/fontello/|/email_templates/|(^LICENSE-MERGELY.html|^docs/Makefile|^scripts/whitespacecleanup.sh|/(graph|mergely|native.history)\.js|/test_dump_html_mails.ref.html|\.png|\.gif|\.ico|\.pot|\.po|\.mo|\.tar\.gz|\.diff)$'`

sed -i "s/`printf '\r'`//g" $files
sed -i -e "s,`printf '\t'`,    ,g" $files
sed -i -e "s,  *$,,g" $files
sed -i -e 's,\([^ ]\)\\$,\1 \\,g' -e 's,\(["'"'"']["'"'"']["'"'"']\) \\$,\1\\,g' $files
# ensure one trailing newline - remove empty last line and make last line include trailing newline:
sed -i -e '$,${/^$/d}' -e '$a\' $files

sed -i -e 's,\([^ /]\){,\1 {,g' `hg loc '*.css'`
sed -i -e 's|^\([^ /].*,\)\([^ ]\)|\1 \2|g' `hg loc '*.css'`

hg mani | xargs chmod -x
hg loc 'set:!binary()&grep("^#!")&!(**_tmpl.py)&!(**/template**)' | xargs chmod +x

# isort is installed from dev_requirements.txt
isort --line-width 160 --wrap-length 160 --lines-after-imports 2 `hg loc '*.py'`

hg diff