Fix CODEOWNERS file search when .github or docs folders are not present#8
Fix CODEOWNERS file search when .github or docs folders are not present#8comatory merged 3 commits intocomatory:masterfrom
.github or docs folders are not present#8Conversation
There was a problem hiding this comment.
Hey @religiosa1 ! Thank you for the contribution and good catch! The plugin shouldn't error like this. I think it's good to remove the assert I had in place just for this reason, as having CODEOWNERS is totally optional.
I am also attaching a patch, I do not have write access to your fork. I think this functionality is pretty important, so I generated unit tests that would check the correct priority for the file lookup. The patch also adds some small changes so the linter can pass.
Would you be OK with applying the patch on your branch?1 I think it would be best to merge it together. I would like to run the pipeline with the patch applied, that should get rid of the failures. Once we add this to master, I will then create a release tag so it can be installed using package managers.
Footnotes
-
Run
git apply pr-8.patchlocally and push it to your branch 🙏 ↩
|
Hey @comatory, thanks for the review. |
|
@religiosa1 thanks for the contribution again. I released the fix in the new |
Hey @comatory , thank you for the awesome plugin, really helpful stuff.
That said, I encountered an issue when a repo has
docsfolder without any CODEOWNERS in it. On init it throws:stack trace
The immediate issue seems to be caused by missed parentheses in the fallback condition in fs.lua:79:
Though just adding parenthesis will prevent the error on init, it sill leaves the core functionality broken, if you have CODEOWNERS at root. Also, if we have
.githubfolder without the CODEOWNERS file -- and the file being in eitherdocsor at the root level it won't be picked by the plugin as we don't check for the presence of the file in the.githubfolder before choosing it.This PR modifies the behavior of the
FS.getCodeownersFilePathso it checks for the CODEOWNERS file presence in the.githubfoleder, and then root-level, and thendocsfolders (the order as specified in the Github Docs).It also adds "CODEOWNERS" to the
vim.fs.findarguments ingetRootDirectoryNamein FS, so we don't miss the cached codeowners file when neither.githubnordocsfolders are present.I verified the changes on the local test setup with the following scenarios:
docsfolder present, no CODEOWNERS -- no error thrown on initdocsfolder when.githubfolder is also present in the repo.githubanddocsfolders present, either one of them, or none of themdocswhen.githubis both present and not.githubwhendocsis both present and not