NewGitCLIRepository creates a new git repository struct with the given parameters
(ctx context.Context, localPath string)
| 18 | |
| 19 | // NewGitCLIRepository creates a new git repository struct with the given parameters |
| 20 | func NewGitCLIRepository(ctx context.Context, localPath string) (*GitCLIRepository, error) { |
| 21 | if !isGitCommandAvailable(ctx) { |
| 22 | return nil, errors.New("git not found in path. Please make sure you have git installed to clone git dependencies") |
| 23 | } |
| 24 | |
| 25 | return &GitCLIRepository{ |
| 26 | LocalPath: localPath, |
| 27 | }, nil |
| 28 | } |
| 29 | |
| 30 | func isGitCommandAvailable(ctx context.Context) bool { |
| 31 | _, err := command.Output(ctx, "", expand.ListEnviron(os.Environ()...), "git", "version") |