blob: 282b84c9646fd6f8df3c4a1906fd540bda50bdf3 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package checkout
import (
"context"
"net/url"
"os"
buildbucketpb "go.chromium.org/luci/buildbucket/proto"
"go.fuchsia.dev/infra/execution"
)
// Checkout checks out the git repo at repoURL according to the given build input.
func Checkout(ctx context.Context, input *buildbucketpb.Build_Input, repoURL url.URL, specRef, dir string) error {
strat, err := newStrategy(input, repoURL, specRef)
if err != nil {
return err
}
// Write everything to stderr. Recipes expect the stdout of the build_init tool
// to be a proto.
executor := execution.NewExecutor(os.Stderr, os.Stderr, dir)
return strat.Checkout(ctx, executor)
}