Kategorien: development, html / css, JavaScript, php, b2evolution


Git pre-push hook to check for bad log pattern

I've just written a pre-push hook for Git that will check for certain patterns in the log messages that would get pushed.

This is meant to prevent you from accidentally pushing anything that starts with "fixup!" or "stash!" to certain branches (master, etc). These log messages are meant to be used with the autostash feature, which would setup your file for `git rebase --interactive` accordingly.

The code can be found in my dotfiles: ~df/config/git/template/hooks/pre-push.

I am using this through my Git template directory, which gets used with `git init` (and `git init` in an existing repo will also install missing hooks).

Here's the current version:


# Git pre-push hook to check for "fixup!" and "squash!" in commit messages,
# which are not meant to get pushed to public/non-PR branches.
# It will also prevent fast-forward pushes, because git-log fails for them.
# You can use `--no-verify` with git-push to skip this hook.
# Args:
# 1: name of the remote
# 2: location of the remote
# stdin: <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF
# Which remote heads/branches to check?
# (a regular expression for "grep -E").
# The log pattern to check.
# (a regular expression for "git grep")
# Uncomment for debugging.
# (the ":" is there so the function can be "empty")
debug() {
  # echo "debug: $@"
debug "$0: $1 $2 ($#)"
# Return status of the script.
while read local_ref local_sha remote_ref remote_sha; do
  debug "Pushing: $local_ref ($local_sha) => $remote_ref ($remote_sha)"
  # Is this a new remote ref?
  if [ "$remote_sha" = "0000000000000000000000000000000000000000" ]; then
  # Skip certain branches, but no other refs (tags).
  if [ "$remote_ref" != "$remote_head" ]; then
    # This is a head/branch (no tag).
    # Allow any non-protected branch.
    if ! echo "$remote_head" | grep -qE "$CHECK_REMOTE_HEADS"; then
      debug "Skipping remote head: $remote_ref ($remote_head)"
  # Check for the bad log pattern.
  log_cmd="git log --grep $BAD_LOG_PATTERN --color=always $log_arg"
  if [ "$log_ret" != 0 ]; then
    echo "ERROR: git-log failed (non-fast-forward / forced push?)"
    echo "  cmd: $log_cmd"
  if [ -n "$log" ]; then
    echo "ERROR (pre-push): there are commits with a bad pattern ($BAD_LOG_PATTERN)!"
    echo "       local_ref: $local_ref => remote_ref: $remote_ref"
    debug "git-log argument: $log_arg"
    echo "$log" | sed 's/^/  /'
debug "ret=$ret"
exit $ret
By Daniel in development, Open Source, Snippets05/18/15 English (US) Email
Tags: ,


Deploying a website using Git via SSH remote

Git has a concept of "remotes" (tracked repositories), which allows to have
arbitrary alternate remote locations besides the typical "origin" remote, like "web".

The basic idea is to setup a user on the remote server ($SSH_DEPLOYUSER) which
is allowed to login via SSH (e.g. by adding your public SSH key to the deploy
user's ~/.ssh/authorized_keys file) and will be used to checkout what you want
to deploy.

To accomplish this you have to setup the Git working directory on the server and
add a "post-receive" hook, which will be invoked by Git after you have pushed
to the repository:


$ mkdir /path/to/repo-checkout
$ cd /path/to/repo-checkout
$ git init
# Create the post-receive file/hook (Ctrl-D to end the input to "cat"):
$ cat > .git/hooks/post-receive
export GIT_DIR=$(pwd)
cd ..
git checkout -f
git submodule update --init --recursive
$ chmod +x .git/hooks/post-receive
$ git config --add receive.denyCurrentBranch ignore
$ chown $SSH_DEPLOYUSER -R .

On the local side you have to add a "remote" (named "web" in this case):

The final step is to initially push to it (which requires to specify the "refspec" once - following deployments can be done by just doing a "git push web"):


$ git remote add web ssh://$DEPLOYUSER@host.example.com/path/to/repo-checkout/.git
$ git push web +master:refs/heads/master

These instructions are based on the howto at toroid.org/ams/git-website-howto, but the main difference is that I am not using a "bare" repository here, which would not allow to use Git submodules; submodules require a "full" Git working directory and having a checkout of the repository requires the receive.denyCurrentBranch=ignore setting.


Flattr: you pay for the web

Micro wird ja gerne mit "u" abgekürzt: möchte man nun einen kurzen Twitter-Hash für "Micropayment" erstellen, und das ganze noch in den Zusammenhang des "man bezahlt" stellen, muss "#upay" dabei herauskommen.

Und genau darum geht es:
Einfach bezahlen, und dadurch geben. Bekommen kommt dann wenn man es verdient.

Man sieht etwas, das einem gefällt und hat die Möglichkeit einfach nur "I Like" zu klicken, und dadurch Geld (ein offizielles Tauschmittel) zu transferieren, spenden und zu verteilen.

In diesem Zusammenhang: Flattr wurde als Beta freigegeben: ein Micro-Payment-Dienst, wo das monatliches Budget (z.B. 2€ oder auch 50€) auf alle Upvotes/Klicks in diesem Zeitraum (Monat) verteilt wird: mag man 4 Sachen in der Zeit gibt es für jeden 50¢ oder 12,5€, mag man 50 Sachen bekommt jeder 4¢ oder 1€).

Kleinvieh macht am meisten Mist und die Intention hierbei ist es, ein einfaches Transferieren zu ermöglichen - allerdings natürlich durch ähnlich umfassende Integration, wie es der Facebook-"I like"-Button verlangt (durch Einbinden des JavaScripts auf den Seiten).

Wer bereits einen Flattr-Zugang hat, darf dies nun gerne in meinem Blog-Sidebar ausprobieren und praktizieren, indem er meinem "Thing" (Blog) einen Teil der monatlichen Tantiemen gibt - (auch diesem Eintrag habe ich nun manuell das Widget hinzugefügt).

Ich bin auch angefangen ein umfassenderes b2evolution-Plugin zu schreiben, allerdings mal wieder sehr von Kleinigkeiten im "evocore" frustriert und abgelenkt worden.

Derzeit ist der Dienst noch nicht frei zugänging, man kann sich aber zur Beta anmelden (was ich wohl vor einigen Wochen/Monaten irgendwann getan habe).


tqWorms reloaded

I've noticed some days ago that the DOS game I've written in 1999 can get played still using DOSBox.

The sound is apparently a bit crappy - but fortunately this is not on Linux only..

You can view the old software home at thequod.de/.../tqworms, but this is apparently very old already and I should get it some new home probably. Anyway, https://www.thequod.de/de/comp/mysoft/tqworms should be fine.

Screenshots are up on Flickr finally and it's known to cause maximum pleasure with 5+ users on the same keyboard only.

Would love to play this again - maybe even more when sound stutter (via DOSBox) is being fixed.

By Daniel in development, Ubuntu05/07/10 English (US) Email


TortoiseSVN/VCS GUI integration in jEdit

I've created the following macros to easily launch various SVN commands in TortoiseSVN at work.

To use them yourself, just create the displayed files (VCS/*.bsh) in your personal "macros" directory (~/.jedit/macros).


for i in ~/.jedit/macros/VCS/*; do echo "$i:"; cat $i; done
exec = "c:\\Programme\\TortoiseSVN\\bin\\TortoiseProc.exe /command:blame /path:\""+buffer.getPath()+"\" /line:"+(textArea.getCaretLine()+1);
Runtime.getRuntime().exec( exec );
exec = "c:\\Programme\\TortoiseSVN\\bin\\TortoiseProc.exe /command:commit /path:\""+buffer.getPath()+"\" /logmsg:\""+buffer.getName()+": \"";
Runtime.getRuntime().exec( exec );
exec = "c:\\Programme\\TortoiseSVN\\bin\\TortoiseProc.exe /command:diff /path:\""+buffer.getPath()+"\"";
Runtime.getRuntime().exec( exec );
exec = "c:\\Programme\\TortoiseSVN\\bin\\TortoiseProc.exe /command:log /path:\""+buffer.getPath()+"\"";
Runtime.getRuntime().exec( exec );

You can now execute those macros either by calling them from the "Macros" menu, assign a shortcut to them or (my preferred way) via Ctrl-Enter, typing parts of them and then TAB-completing it (e.g. Ctrl-Enter, "log_", TAB, Enter).

They do not have "svn" in the name, since they might get extended to use the appropriate VCS GUI command in the future, for example by testing if there's a .svn control directory or using commands like "bzr st" or "git status" to check if it's a Bazaar/Git/... file.

(For debugging, you can use Macros.message( view, exec ); to display the "exec" value in a message)

By Daniel in development, Snippets2010-01-27 English (EU) Email


OpenSource is distracting

Having the possibility to report bugs against tools and applications you are using to report bugs in other applications can lead to a whole stack of browser windows, things and stuff being open.

Especially if there are bugs in the application to report the oh-no-it's-starting-to-recurse bug report (Yes, I'm looking at you, Launchpad).


b2evolution/whissip auf Deutsch: wieder zu 100% übersetzt

Dank Tilman ist nun b2evolution (und damit auch whissip) komplett auf Deutsch übersetzt.

Ich bin damals bei b2evolution eingestiegen, indem ich die deutsche Übersetzung beigesteuert habe, aber habe das leider in letzter Zeit vernachlässigt.

Glücklicherweise ist Tilman nun eingesprungen und hat dies nun zu 100% übersetzt.

Eventuelle Bugs/Vorschläge können bei Launchpad hinterlassen werden.

Von Daniel in b2evolution16.04.09 German (DE) E-Mail