[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu-arch-users] missing feature: text file handling

From: John Meinel
Subject: Re: [Gnu-arch-users] missing feature: text file handling
Date: Thu, 07 Oct 2004 12:50:07 -0500
User-agent: Mozilla Thunderbird 0.8 (Windows/20040913)

Aaron Bentley wrote:
John Meinel wrote:

Aaron Bentley wrote:

Maybe what's desirable is a precommit hook. When new files or changes don't match the coding policy,
a) scream and die or
b) fix them


Actually, I would be interested in this. I run into permissions and file ending problems all the time. (Editing a file with gvim seems to change the permissions, editing it with MSVC changes the line endings, etc.)

I've never written a hook script before, so I'm not very familiar with it. But maybe it's time for me to get over it.

It's pretty simple.  The wiki documentation is the most accurate.


Well, it was indeed not too bad. The hard part is actually figuring out how to handle processing the files. What I've chosen to do is fix file permissions, but just scream and die for line ending issues. Permissions are easy to change, line endings are potentially very dangerous to change.

Anyway, I created a python script which uses 'tla inventory --source' to figure out what files exist. One problem, this doesn't include .arch-inventory, and I know of no way to get it to, is it possible, right now I just check manually. Also, it doesn't include .arch-ids/*, which I would like to check for permissions at the very least.

Still, it will check everything considered source, matching it against a set of regular expressions (similar to .arch-inventory). It looks in 3 places

.file-check             <= just for the current directory.
{arch}/=file-check      <= True for a given project
~/.arch-params/=file-check      <= Global setting

The files are parsed in the given order, and the first rule that matches wins. So make sure to put more specific matches first.

The structure of the file is:


So in ~/.arch-params/=file-check you might have

# Match Visual Studio Project files
crlf    ^(.*\.(dsp|dsw|vcproj|sln))$
# These are binary, don't complain about their endings
none    ^(.*\.(png|bmp|jpg|jpeg))$
# Match Everything else
lf      ^.*$

# Don't set permissions on temporary files, though these probably
# won't show up with tla inventory
0000    ^.*~$
0000    ^.*\.(swp)$
# Default for all files is 0644
0644    ^.*$

Then in a local .file-check you could have:

# Set all python and shell scripts in this directory to executable
0755    ^(.*\.(py|sh))$

The only thing to be aware of, is that if you have a .file-check you need to add this line into .arch-inventory:
source ^(\.file-check)$

Or it will complain that the file violates naming constraints.

Is it better to post this to the mailing list, or to put it on the Wiki, or just have it in a publicly accessible archive? It probably would best fit in tlacontrib.

One final note. Because this script is a little bit involved, it doesn't make a good general hook script. So I wrote it for a hook script like this:
set -e
case "$1" in

I will happily email this to anyone who is interested.


PS> Would it be better to put this stuff into .arch-inventory with a custom line beginning? Like

#~crlf  ^(.*\.(dsp|dsw|vcproj|sln))$

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]