pronto
pronto copied to clipboard
Error `merge_base': object not found - no match for id
We've encountered an error when using code for github actions integration:
/opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/pronto-0.11.0/lib/pronto/git/repository.rb:87:in `merge_base': object not found - no match for id (646d05a0a847592a34024edb97fcfbd4902368d3) (Rugged::OdbError)
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/pronto-0.11.0/lib/pronto/git/repository.rb:87:in `merge_base'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/pronto-0.11.0/lib/pronto/git/repository.rb:17:in `diff'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/pronto-0.11.0/lib/pronto.rb:64:in `run'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/pronto-0.11.0/lib/pronto/cli.rb:66:in `block in run'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/pronto-0.11.0/lib/pronto/cli.rb:64:in `chdir'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/pronto-0.11.0/lib/pronto/cli.rb:64:in `run'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/lib/ruby/gems/2.6.0/gems/pronto-0.11.0/bin/pronto:6:in `<top (required)>'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/bin/pronto:23:in `load'
from /opt/hostedtoolcache/Ruby/2.6.5/x64/bin/pronto:23:in `<main>'
The solution was to remove --depth=10
from git fetch --no-tags --prune --depth=10 origin +refs/heads/*:refs/remotes/origin/*
. I'm leaving it here, may be useful for someone, but maybe there is something better we can do to get rid of this error?
I am not git expert
Just providing some doc about depth
here:
- https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---depthltdepthgt
- https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---depthltdepthgt (pointed by description in
git fetch
)
Ran into and fixed this, myself. Albeit the fix was removing depth which isn't ideal.
I believe this happens because Rugged, the dependency pronto uses, can't crawl your git history to get your merge base between your branch and the compared branch (I'm assuming main/master). This happens if your supplied --depth
is less than the merge base commit.
I don't know if there's a good way around it. If you're using depth because of a large git repo, you can consider setting a high depth or a long --shallow-since=
date that you think you'll never hit with your development branches. Maybe there's something smart you can try with --deepen=
but I haven't used that flag myself.
We just ran into this, and I'm playing around with something like:
jobs:
pronto:
steps:
- name: Checkout code
uses: actions/checkout@v2
- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git fetch --no-tags --prune --shallow-since="$(git show -s --format=%ci origin/master)" origin +refs/heads/*:refs/remotes/origin/*
That's probably not correct yet tho.
I had a similar problem but it was because the initial checkout defaults to --depth=1
as documented by https://github.com/actions/checkout#usage fetch-depth
param.
If my feature branch only had one commit then fine, but normally they don't before PR created so I set ..
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 100
.. where 100 is arbitrary but hopefully big enough to cover all commits on the feature branch since it was forked from master.
After years of it working fine, I've suddenly started seeing the same error when running on CircleCI ("object not found - cannot read header for (7c12bff1f6ffc4e442e24949edcf31cdbe438fb0)"), but unlike suggestions above, CircleCI doesn;t use a shallow clone. When I SSH onto the CI box and run git fetch --unshallow
I see --unshallow on a complete repository does not make sense
. So in theory, pronto/rugged should have access to all the information it needs. When SSHd into the box, the git repo is usable (can pull/fetch without issues). Any suggestions for other things I could try?
Like @KieranP after years of it working fine on CircleCi, I've seeing this error
/home/circleci/repo/vendor/bundle/ruby/3.3.0/gems/pronto-0.11.2/lib/pronto/git/patches.rb:11:in 'each_patch': object not found - cannot read header for (d7655e8ce194095299e5d85b4650d2a66f004b26) (Rugged::OdbError)
and have tried what I have read here, without success.
Via SSH I've tried
repo = Rugged::Repository.new('path/to/my/repository')
repo.exists?("d7655e8ce194095299e5d85b4650d2a66f004b26")
# => false
The same CircleCI configuration on another rails app, same version of Ruby and of Rails, does not produce this issue :thinking:
I think I have a clue, comparing the CI on this 2 similar app (same versions of Ruby/Rails/Pronto/Pronto-Rubocop and same config.yml
for the configuration of the CircleCI). As you can see on the capture, selected in blue, on the failing CI there is this Creating a blobless clone for better performance
which does not come from the .circleci/config.yml
@quarkgluant Hmm, so CircleCI may have changed how their 'checkout' helper step operates.
As a workaround, I added this to my config, which seems to fix it:
# Workaround for "object not found - cannot read header"
# Refetch and reset to commit SHA
- run: git checkout master
- run: git fetch
- run: git reset --hard $CIRCLE_SHA1
- run: bundle exec pronto run -c origin/master --exit-code
Got a similar error :
/home/runner/work/project/project/vendor/bundle/ruby/3.1.0/gems/pronto-0.11.2/lib/pronto/git/repository.rb:99:in `merge_base': revspec 'origin/master' not found (Rugged::ReferenceError)
from /home/runner/work/project/project/vendor/bundle/ruby/3.1.0/gems/pronto-0.11.2/lib/pronto/git/repository.rb:99:in `merge_base'
from /home/runner/work/project/project/vendor/bundle/ruby/3.1.0/gems/pronto-0.11.2/lib/pronto/git/repository.rb:29:in `diff'
from /home/runner/work/project/project/vendor/bundle/ruby/3.1.0/gems/pronto-0.11.2/lib/pronto.rb:64:in `run'
My fix was adding fetch_depth: 0
in the checkout action. Not sure if this is the best solution but it works 🤷
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0