MCPcopy Create free account
hub / github.com/docker/buildx / New

Function New

util/gitutil/gitutil.go:20–33  ·  view source on GitHub ↗

New initializes a new git client.

(opts ...bkgitutil.Option)

Source from the content-addressed store, hash-verified

18
19// New initializes a new git client.
20func New(opts ...bkgitutil.Option) (*GitCLI, error) {
21 cli := bkgitutil.NewGitCLI(append(opts, bkgitutil.WithHostGitConfig())...)
22
23 gitpath, err := gitPath(cli.Dir())
24 if err != nil {
25 return nil, err
26 }
27
28 cli = cli.New(
29 bkgitutil.WithGitBinary(gitpath),
30 bkgitutil.WithArgs("-c", "log.showSignature=false"),
31 )
32 return &GitCLI{*cli}, nil
33}
34
35func (cli *GitCLI) IsInsideWorkTree(ctx context.Context) bool {
36 out, err := cli.clean(cli.Run(ctx, "rev-parse", "--is-inside-work-tree"))

Callers 8

TestGitFunction · 0.92
TestGitFullCommitFunction · 0.92
TestGitShortCommitFunction · 0.92
TestGitFullCommitErrFunction · 0.92
TestGitShortCommitErrFunction · 0.92
TestGitTagsPointsAtFunction · 0.92
TestGitDescribeTagsFunction · 0.92
TestGitRemoteURLFunction · 0.92

Calls 3

DirMethod · 0.80
gitPathFunction · 0.70
NewMethod · 0.65

Tested by 8

TestGitFunction · 0.74
TestGitFullCommitFunction · 0.74
TestGitShortCommitFunction · 0.74
TestGitFullCommitErrFunction · 0.74
TestGitShortCommitErrFunction · 0.74
TestGitTagsPointsAtFunction · 0.74
TestGitDescribeTagsFunction · 0.74
TestGitRemoteURLFunction · 0.74