From 7fd6f8333e14fd2b8a19819068a79dea384c6604 Mon Sep 17 00:00:00 2001 From: Christian Lawson-Perfect Date: Wed, 12 Feb 2025 11:00:32 +0000 Subject: [PATCH] add JJController.ignore_paths back in --- thinks/jujutsu.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/thinks/jujutsu.py b/thinks/jujutsu.py index 9e146b1..418a760 100644 --- a/thinks/jujutsu.py +++ b/thinks/jujutsu.py @@ -34,6 +34,23 @@ class JJController: git_url = settings.GIT_REPO_URL_TEMPLATE.format(name=self.think.slug) self.run(['jj','git','remote','add','origin', git_url]) + @ensure_jj + def ignore_paths(self, paths): + paths = self.clean_paths(paths) + gitignore = self.root / '.gitignore' + if len(paths) == 0: + return + + if gitignore.exists(): + with open(gitignore) as f: + ignored = f.read().strip().split('\n') + ignored += [p for p in paths if p not in ignored] + else: + ignored = paths + + with open(gitignore, 'w') as f: + f.write('\n'.join(ignored)) + @ensure_jj def status(self): res = self.run(['jj','st'])