smashwilson / merge-conflicts

Resolve git merge conflicts in Atom
https://atom.io/packages/merge-conflicts
MIT License
432 stars 42 forks source link

Does not work if top-level project is not a git repo. #189

Open xiata opened 8 years ago

xiata commented 8 years ago

atom.project.getRepositories() is fundamentally broken as an atom feature since it demands the user to load each git project as the top most directory. If you have many repositories and prefer organized into folders such as ~/repositories/(project-group)/(project) and open the ~/repositories folder, you are SOL. That said, this module does not work at all for me.

Luckily, the atom api has a better solution for determining the git repo for the active file, atom.project.repositoryForDirectory(Directory). This is capable of finding a parent git repository, but is not a synchronous call as expected by GitBridge::getActiveRepo.

In Atom 2.0 the synchronous Project::getRepositories function is going away, so any project changes to handle promises as mentioned by https://atom.io/docs/api/v1.0.19/Project#instance-getRepositories should be compatible.

In the meantime going to fork to take a stab at fixing this by supporting repositoryForDirectory, and the Atom 2.0 safe replacement for getRepositories

smashwilson commented 8 years ago

Oh hey, I didn't know about Project::repositoryForDirectory.

I've also been keeping an eye on atom/atom#9213, which would let me :hocho: GitBridge entirely in favor of using the bundled, asynchronous nodegit for git operations instead. I suspect that'll take a while to make it in (and no idea when I'll have side-project bandwidth once it does) so a PR like this would be :+1:

emileber commented 8 years ago

In fact, it doesn't work if there are no conflicts in the first project folder.

smashwilson commented 8 years ago

@emileber: Try opening an editor for any file in the project folder with conflicts, then running merge-conflicts:detect-conflicts :wink:

emileber commented 8 years ago

Nope, even if the file with conflicts is opened, I get the following notification (on version 1.4.1):

Nothing to Merge No conflicts here!

If I remove the first project folder (the one without conflicts, leaving the one with conflicts alone) and then I add it again, making it the second project folder and I use merge-conflicts:detect-conflicts, it detect correctly.

smashwilson commented 8 years ago

Oh, interesting. Would you mind opening that as a separate issue? I'd rather keep this one around for the ".git directory doesn't align with project root" cases.

emileber commented 8 years ago

View issue #228