-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix subfolder git detection #1715
Conversation
TODO: Add tests |
@utkarshgupta137 I changed the codebase to TypeScript. Do you want to move the changes to the new files? |
@aminya done. |
Could you add some description about the bug this is fixing? |
@aminya done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. I will use this branch for some time to see if everything works as expected.
let repository = null | ||
const projectPaths = atom.project.getPaths() | ||
for (let i = 0, { length } = projectPaths; i < length; ++i) { | ||
const projectPath = projectPaths[i] | ||
if (filePath.indexOf(projectPath) === 0) { | ||
repository = atom.project.getRepositories()[i] | ||
break | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to check the project paths one by one anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, those cases are already covered by atom.project.repositoryForDirectory
.
This change affects the "Ignore VCS" option.
Description
If you add a project folder which is not a git repo but it contains folders which are git repos, then the repository detection doesn't work.
Steps to Reproduce
|-- mainFolderWithoutGit
.....|-- someFolderWithGit
..........|-- .git
Current Behaviour:
The "Ignore VCS" option doesn't work, and the file is still linted.
Expected behavior:
The file should not be linted if the "Ignore VCS" option is enabled.
Solution:
The repositoryForDirectory function in atom.project is able to detect the repository for any Directory, even if it is in a subfolder.
It is an async function, so some changes have to be made in up the call chain.
Also updated the tests to test it.