bitranox / igittigitt

A spec-compliant gitignore parser for Python
MIT License
24 stars 6 forks source link

Default ignore file in home directory #21

Closed hellcats closed 2 years ago

hellcats commented 3 years ago

Git provides for reading default rules from the user's home directory (e.g. ~/.gitignore). This requires special treatment since ignore rules are interpreted relative to the directory in which the ignore file is located and not just the user's home directory.

Emulating this functionality is already present with the optional base_dir argument to _parse_rule_file (except it is currently broken). I would like to recommend that the base_dir parameter be returned to working order, and that _parse_rule_file be promoted to a public method (i.e. just remove the leading underline '_').

Fixing base_dir can be accomplised with a single line of code:

    path_base_dir = base_dir if base_dir is not None else path_rule_file.parent

User's can then effectively append multiple default ignore files as if they were all part of a single ignore file in the target directory.

 igittigitt.parse_rule_file("~/.myignore', base_dir=target_dir)
 igittigitt.parse_rule_files(target_dir, '.myignore')
bitranox commented 3 years ago

ok, not sure what You are talking about ATM - I will look into it later and come back probably with questions

bitranox commented 2 years ago

good news - default ignore files are implemented in version 2.1.0 thanks for your suggestion !