gruntwork-io / go-commons

A standard library to use in all Gruntwork CLI tools
https://www.gruntwork.io/
MIT License
35 stars 26 forks source link

Add functions for interacting with git #55

Closed yorinasub17 closed 2 years ago

yorinasub17 commented 2 years ago

Description

This implements useful functions for interacting with git in a CLI. These are adapted from our infrastructure-deploy-script python script.

I need this for creating a docker entrypoint script for running steampipe checks in ecs-deploy-runner, which requires cloning the mods.

TODOs

Please ensure all of these TODOs are completed before asking for a review.

zackproser commented 2 years ago

Curious if you've ever played around with https://github.com/go-git/go-git?

yorinasub17 commented 2 years ago

Curious if you've ever played around with https://github.com/go-git/go-git?

I have, and was originally going to use it, but I found it to be difficult to navigate around, especially when it comes to all the rules around checking out the "right" version from a ref (which is simplified to git checkout when using the CLI). E.g., see all the logic that kaniko implements to ensure you can clone the repo at the right version: https://github.com/GoogleContainerTools/kaniko/blob/main/pkg/buildcontext/git.go#L58-L139

I would have used this function directly, if it didn't hardcode the checkout dir...

yorinasub17 commented 2 years ago

Thanks for review! Merging now.