MW

Tag git

Recent Posts

A git hook to prevent pushes with untracked source files (August 08, 2014)

Hey all,

do you know this: You work on something locally in git, ensure everything compiles and the tests pass, then commit and hit git push.What could possibly go wrong at that point, eh? Well, far too often I forgot to git add some new source file. Best-case I’ll notice this directly, worst-case I’ll see my CI complaining. But, like yesterday in kdev-clang, I might be afk at that point and someone else will have to revert my change and I’ll have to fix it up the day after, polluting the git history while at it…

Thanks to some simple shell scripting and the powerful git hook architecture, it is pretty simple to protect oneself against such issues:

    #!/bin/sh
     
    #
    # A hook script to verify that a push is not done with untracked source file
    #
    # To use it, either symlink this script to $your-git-clone/.git/hooks/pre-push
    # or include it in your existing pre-push script.
    #
     
    # Perl-style regular expression which limits the files we interpret as source files.
    # The default pattern here excludes CMakeLists.txt files and any .h/.cpp/.cmake files.
    # Extend/adapt this to your needs. Alternatively, set the pattern in your repo via:
    #     git config hooks.prepush.sourcepattern "$your-pattern"
    pattern=$(git config --get hooks.prepush.sourcepattern)
    if [ -z "$pattern" ]; then
      pattern="(?:(?:^|/)CMakeLists\.txt|\.h|\.cpp|\.cmake)$"
    fi
     
    files=$(git status -u --porcelain --no-column | sed "s/^?? //" | grep -P "$pattern")
    if [ -z "$files" ]; then
      exit 0
    fi
     
    echo
    echo "ERROR: Preventing push with untracked source files:"
    echo
    echo "$files" | sed "s/^/    /"
    echo
    echo "Either include these files in your commits, add them to .gitignore"
    echo "or stash them with git stash -u."
    echo
    exit 1

continue reading...

Git commit message highlighting in nano (November 24, 2012)

For those who use nano as their CLI editor of choice: Here’s a syntax highlighting file for Git commit messages which also supports the special KDE commit hook keywords.

    ##  syntax highlighting for git commit messages of KDE projects
    syntax "patch" ".git/COMMIT_EDITMSG$"
     
    # overlong lines
    color brightred "^.{70,}.+$"
     
    # KDE commit hook keywords, see: http://community.kde.org/Sysadmin/GitKdeOrgManual#Commit_hook_keywords
    color yellow "^(FEATURE|BUG|CCBUG|FIXED-IN|CCMAIL|REVIEW|GUI|DIGEST):.*$"
    color yellow "(SVN_SILENT|GIT_SILENT|SVN_MERGE)"
     
    # comment
    color blue "^#.*$"
     
    # special comment lines
    color green "^# Changes to be committed:"
    color red "^# Changes not staged for commit:"
    color brightblue "^# Untracked files:"
    color brightblue "^# On branch .+$"
    color brightblue "^# Your branch is ahead of .+$"
     
    # diff files
    # meh - cannot match against \t ... should be: ^#\t.*$
    color cyan "^#[^ a-zA-Z0-9][^ ].*$"

continue reading...

KDevelop 4.0.2 and KDevelop 4.1 Beta 1 released (September 24, 2010)

Good news everyone, this time in a double feature!

I’m happy to announce the availability of two new additions to the KDevelop release family:

KDevelop 4.0.2 stable release

Lets begin with the boring part: We have released KDevelop 4.0.2, together with KDevplatform and the PHP plugins. You can find the sources here:

http://download.kde.org/download.php?url=stable/kdevelop/4.0.2/src/

This is a bugfix only release and everyone is urged to upgrade as soon as possible. Users should wait for their distributions to provide packages for them. The tarballs contain changelogs if you are interested what happened since 4.0.1. Or read them online:

continue reading...

KDevelop Webdev plugins merged into Quanta GIT (June 14, 2010)

Quick note:

I’ve just merged all webdevelopment related plugins except PHP & PHP-Docs into Quanta git. You can get them all in one place now by cloning Quanta: http://gitorious.org/kdevelop/quanta

Since I also moved all halfworking plugins to UNPORTED (they don’t get installed), you should be fine by just installing all of Quanta to get the plugins. If you only want one of them, going into it’s subfolder and building it standalone should hopefully still work though.

In other notes: Thanks to Ruan Styrdom for starting work on a PHP formatter plugin for KDevelop. It uses phpStylist and it’s already somewhat working. Awesome :)

/me is off to more GSOC hacking, bye

continue reading...