diff options
author | 2024-03-23 10:12:51 +0200 | |
---|---|---|
committer | 2024-03-23 10:12:51 +0200 | |
commit | 39dd2fbd816129dd674665f0198aa58c8668a2c4 (patch) | |
tree | 1a56d55b1e238b4fff50ad6934934de4153e3470 | |
parent | NewerEAPIAvailable: committing new ebuilds with old EAPI (diff) | |
download | pkgcheck-39dd2fbd816129dd674665f0198aa58c8668a2c4.tar.gz pkgcheck-39dd2fbd816129dd674665f0198aa58c8668a2c4.tar.bz2 pkgcheck-39dd2fbd816129dd674665f0198aa58c8668a2c4.zip |
git addon: support user global gitignore
Resolves: https://github.com/pkgcore/pkgcheck/issues/671
Resolves: https://github.com/pkgcore/pkgcheck/issues/672
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | src/pkgcheck/addons/git.py | 9 | ||||
-rw-r--r-- | tests/addons/test_git.py | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/pkgcheck/addons/git.py b/src/pkgcheck/addons/git.py index 7b2435ac..1874e8a6 100644 --- a/src/pkgcheck/addons/git.py +++ b/src/pkgcheck/addons/git.py @@ -536,9 +536,14 @@ class GitAddon(caches.CachedAddon): def _gitignore(self): """Load a repo's .gitignore and .git/info/exclude files for path matching.""" patterns = [] - for path in (".gitignore", ".git/info/exclude"): + paths = ( + pjoin(self.options.target_repo.location, ".gitignore"), + pjoin(self.options.target_repo.location, ".git/info/exclude"), + pjoin(os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")), "git/ignore"), + ) + for path in paths: try: - with open(pjoin(self.options.target_repo.location, path)) as f: + with open(path) as f: patterns.extend(f) except (FileNotFoundError, IOError): pass diff --git a/tests/addons/test_git.py b/tests/addons/test_git.py index b896304d..596a2b34 100644 --- a/tests/addons/test_git.py +++ b/tests/addons/test_git.py @@ -12,6 +12,7 @@ from pkgcore.ebuild.atom import MalformedAtom from pkgcore.ebuild.atom import atom as atom_cls from pkgcore.restrictions import packages from snakeoil.cli.exceptions import UserException +from snakeoil.contexts import os_environ from snakeoil.fileutils import touch from snakeoil.osutils import pjoin from snakeoil.process import CommandNotFound, find_binary @@ -466,6 +467,9 @@ class TestGitAddon: self.addon = git.GitAddon(options) self.cache_file = self.addon.cache_file(self.repo) + with os_environ(XDG_CONFIG_HOME=self.cache_dir): + yield + def test_git_unavailable(self, tool): args = ["scan", "--cache-dir", self.cache_dir, "--repo", self.repo.location] options, _ = tool.parse_args(args) |