katratxo on Software Development

tail -f /var/log/brain | grep -i software

Archive for July 2011

Improved JSLint check on Mercurial

with 2 comments

We have been working with the previous version of the Mercurial JSLint precommit hook for several months now, and we pretty happy with the results, it catches the most common JavaScript pitfalls.

However this hook was not smart enough, it checked all the modified JavaScript files even if they were not part for the commit, and this situation annoyed some experienced developers:

I have unfinished JavaScript changes, but I’m committing a Java files!! Why this hook is checking files that are not part of the commit!?? I need to do this Java changes now … I’ll disable this hook.

The Solution

The solution is to run the check on the pretxncommit hook, where you have already the list of files that are part of the commit. You can check the modified JavaScript files and if JSLint complains, the transaction is rolled back.

The Code

The changes are simple. Use hg log to get the list of files from $HG_NODE and pass them through JSLint.

Update: The previous version of the script was not working on every case. The problem is that hg log –template ‘{files}’ outputs all the modified files in a single line. That output saw used as input of awk, that was not filtering properly. I found a workaround, perhaps is not the nicest script, but is working.

#!/bin/sh
# Mercurial pretxncommit hook
for i in $(hg log -r $HG_NODE --template '{files}'); do echo $i | awk '/.js$/ | xargs -rn1 /path/to/jslint || exit 1; done;

Credits

As many times, thanks to Juan Pablo and the Mercurial Community for providing the way to check only the files part of the changeset.

Written by katratxo

July 30, 2011 at 8:55 am

Posted in Openbravo

Tagged with , , ,

Openbravo 3 Developer’s Guide

with one comment

We have been working hard to finish the new Developer’s Guide targeting Openbravo 3. This guide contains information on how to change, extend and build further the application providing valuable information for starting developers, medium experienced and Openbravo experts.

The New Structure

Following best practices we are now using Categories as the way to structure our documentation. An overview of the categories is shown in the following diagram:

Developer's Guide Categories

  • Concepts: Contains documents that aim to explain core concepts behind Openbravo architecture.
  • HowTo: Step by step actions to achieve a goal, e.g. How to create and package a Module
  • Data_Model: Automatic generated documentation that contains the Database and Entity Model
  • Example: Documents that explain code present in the product that could be used as base for our developments
  • Reference:The hibernate mapping, REST XML Schema among other reference documents

Feedback

If you find a document that contains something wrong, outdated or not properly explained, please fix it, after all is a wiki. Note: If you want to make a large change in a document, please contact the original author explaining your proposed changes.

You could also log a defect or feature request in the issue tracker in the Documentation project. Remember to pick the right category: ERP Developers Guide.

I’ve also started a forum thread to collect your feedback and ideas on the Developers Guide.

That’s all folks!

Written by katratxo

July 14, 2011 at 12:41 pm

Posted in Openbravo

Tagged with ,