[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnulib-tool: .XXXignore files generation
From: |
Dmitry Selyutin |
Subject: |
gnulib-tool: .XXXignore files generation |
Date: |
Thu, 28 Jun 2018 00:20:34 +0300 |
Hi again,
that's yet another question on gnulib-tool. Now I'm implementing the code
which takes care of .gitignore and .cvsignore files, and I must admit that the
overall algorithm is a bit tricky (perhaps the only reason is that it was
designed so that it is generic and can be applied both to git and CVS with
small changes, which is a nice property). Could someone describe how it works?
As far as I understand, we must iterate over added_files and removed_files so
that on each iteration we yield the following information:
1. dirname
2. operation
3. basename
4. previous dirname
FWIW, this likely resembles the following in Python:
added_files = ["lib/bitrotate.c", "m4/cond.m4"]
removed_files = ["prefix/tests/zerosize-ptr.h", "dir/m4/ctype.m4"]
items = [tuple(["A"] + list(os.path.split(path))) for path in added_files]
items += [tuple(["D"] + list(os.path.split(path))) for path in
removed_files]
for (head, tail) in zip(items, items[1:]):
print(head, tail)
This code will lead to the following output:
('A', 'lib', 'bitrotate.c') ('A', 'm4', 'cond.m4')
('A', 'm4', 'cond.m4') ('D', 'prefix/tests', 'zerosize-ptr.h')
('D', 'prefix/tests', 'zerosize-ptr.h') ('D', 'm4', 'ctype.m4')
However, the tricky part is what to do with that information. Could you help
me on this part, please? Thank you for your help!
--
With best regards,
Dmitry Selyutin
- gnulib-tool: .XXXignore files generation,
Dmitry Selyutin <=