-
Notifications
You must be signed in to change notification settings - Fork 28
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
Undercover fails with shallow repository + grafted commits #175
Comments
I did manage to reproduce this locally as well - will post these steps soon. We worked around this with the following monkey-patch #!/usr/bin/env ruby
# frozen_string_literal: true
require 'undercover'
module Undercover
class Changeset
# Rugged merge_base complains when graft/shallow
# (https://github.com/libgit2/rugged/issues/846)
#
# So we assume we provide the merge-base ourself. Modified from
# https://github.com/grodowski/undercover/blob/32e62f66682ee566032b5970437ed2934ef29701/lib/undercover/changeset.rb#L74-L78
def compare_base_obj
return unless compare_base
repo.lookup(compare_base.to_s)
end
end
end
compare_base = ARGV[0]
compare_base ||= IO.popen(%w(git merge-base origin/master HEAD)) { |p| p.read.chomp }
result = Undercover::CLI.run(%W(-c #{compare_base}))
exit result I'm happy to draft up some PR but unsure if this should be another configuration option, or something else. |
Thanks for reporting this @kuahyeow, I remember getting
I appreciate it and would be happy to help too. My initial thought is that ideally this wouldn't require any extra configuration, given that it's possible to infer what has been passed to |
@grodowski In GitLab's case, we pass in a SHA to For example, GitLab CI provides a variable called Possible ideas:
|
On GitLab CI, the default depth for the cloned git repository is 50 (for projects like https://gitlab.com/gitlab-org/gitlab/, we set it even lower to 20, for speed purposes).
This leads to errors like below
From https://gitlab.com/gitlab-org/gitlab/-/jobs/2627986054
Steps to reproduce
undercover -c ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA}
libgit2/rugged#846 (comment) seems related.
The text was updated successfully, but these errors were encountered: