I seem to mostly notice this with github-based dependencies when I try to merge in some bundle update
that has changed the commit ref in the lockfile.
As a simple way to reproduce, here's an arbitrary merge conflict I generated:
Gemfile
source 'https://rubygems.org'
<<<<<<< HEAD
gem 'power_assert', github: 'k-tsj/power_assert'
=======
gem 'power_assert', github: 'k-tsj/power_assert', branch: 'power-assert-friendly-inspection'
>>>>>>> branch
Gemfile.lock
GIT
remote: https://github.com/k-tsj/power_assert.git
<<<<<<< HEAD
revision: 49bf25fa5dc6090be70c6057c2e9adb7b27260dd
specs:
power_assert (1.1.4dev)
=======
revision: a68292bcfb94a63872c20a934af9e356ed43e810
branch: power-assert-friendly-inspection
specs:
power_assert (0.1.5dev)
>>>>>>> branch
GEM
remote: https://rubygems.org/
specs:
PLATFORMS
ruby
DEPENDENCIES
power_assert!
BUNDLED WITH
1.17.1
Opening either the Gemfile or the Gemfile.lock results in these errors:
"Gemfile" 6L, 203C
Error detected while processing function <SNR>39_buffer_alter_paths[4]..<SNR>39_project_sorted[1]..<SNR>39_project_paths:
line 54:
E716: Key not present in Dictionary: revision[0:11]
E15: Invalid expression: matchstr(source.remote, '.*/\zs.\{-\}\ze\%(\.git\)\=$') . '-' . source.revision[0:11]
Error detected while processing function <SNR>39_ProjectionistDetect[10]..<SNR>39_project_projections_list[1]..<SNR>39_project_paths:
line 54:
E716: Key not present in Dictionary: revision[0:11]
E15: Invalid expression: matchstr(source.remote, '.*/\zs.\{-\}\ze\%(\.git\)\=$') . '-' . source.revision[0:11]
Press ENTER or type command to continue
Bonus: even after pressing ENTER
and editing away the merge conflicts, I can't :w
the file without getting E13: File exists (add ! to override)
.
Throwing in a debug echo
on the vim-bundler plugin (currently using a996611)...
diff --git a/plugin/bundler.vim b/plugin/bundler.vim
index 23a60c5..59b05d2 100644
--- a/plugin/bundler.vim
+++ b/plugin/bundler.vim
@@ -353,6 +353,7 @@ function! s:project_locked() dict abort
endfor
let self._lock_time = time
endif
+ echo get(self, '_locked', {})
return get(self, '_locked', {})
endfunction
...we can see why revision[0:11]
would be an error - it doesn't get parsed out in the first place:
{
'git': [
{
'remote': 'https://github.com/k-tsj/power_assert.git',
'versions': {}
}
],
'gem': [
{
'remote': 'https://rubygems.org/',
'versions': {}
}
],
'bundled_with': '1.17.1',
'path': []
}
So what's the fix? It's probably a fool's errand to parse arbitrary merge conflicts into anything meaningful - garbage in, garbage out. But I'd even be content if gf
didn't work on conflicted gems or whatnot. It's just a pain wading through these errors when I'm trying to fix merge conflicts. So maybe there's a way to make this more error-safe?