New initializes a new git client.
(opts ...bkgitutil.Option)
| 18 | |
| 19 | // New initializes a new git client. |
| 20 | func 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 | |
| 35 | func (cli *GitCLI) IsInsideWorkTree(ctx context.Context) bool { |
| 36 | out, err := cli.clean(cli.Run(ctx, "rev-parse", "--is-inside-work-tree")) |