200
// refs/heads/<defaultBranch>: the branch tip to check ancestry against.
201
// Any other exit code indicates an error (e.g. the object does not exist).
202
>
func resolveModuleOriginForSpec(ctx context.Context, mod moduleSpec, shortHash string) (bool, error) {
main.go
203
>
tmpRepo, err := os.MkdirTemp("", "check-dependencies-*")
204
>
if err != nil {
205
return false, fmt.Errorf("failed to create temp repo dir: %w", err)
206
}
208
209
>
cmd := exec.CommandContext(ctx, "git", "clone", "--bare", "--filter=blob:none", "--single-branch", "--branch", mod.defaultBranch, mod.repoURL, tmpRepo)
main.go
210
>
out, err := cmd.CombinedOutput()
211
>
if err != nil {
212
return false, fmt.Errorf("git clone failed: %w: %s", err, strings.TrimSpace(string(out)))
213
}
214
215
>
out, err = exec.CommandContext(ctx, "git", "-C", tmpRepo, "merge-base", "--is-ancestor", shortHash, "refs/heads/"+mod.defaultBranch).CombinedOutput()
main.go
216
>
if err == nil {
218
>
}
219
var exitErr *exec.ExitError
220
if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 {