Skip to content

Conversation

@PeterSchafer
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented Mar 26, 2024

CLA assistant check
All committers have signed the CLA.

@PeterSchafer PeterSchafer force-pushed the feat/CLI-195_repourl branch from eb2fbff to 6283e6d Compare March 26, 2024 16:14
@PeterSchafer PeterSchafer marked this pull request as ready for review March 26, 2024 16:34
@PeterSchafer PeterSchafer requested a review from a team as a code owner March 26, 2024 16:34
go 1.21

require (
github.com/go-git/go-git/v5 v5.11.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to play a bit of devil's advocate here... what if we parsed the [remote "origin"] section out of .git/config directly, instead of bringing in this dependency? I think it's a pretty well-defined and simple format.

Another thing to consider, we might only need the config parser (https://pkg.go.dev/github.com/go-git/go-git/v5@v5.11.0/config#ReadConfig) out of go-git.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! In this case, I was just following the implementation hints in the ticket.

  • We are using the library in the tests as well, not only for reading the config but also for cloning a test repo.
  • How big is our appetite in avoiding this dependency vs implementing this our own?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, the reason the IDE team suggested go-git is because we will probably end up usong it anyway for https://snyksec.atlassian.net/wiki/spaces/RD/pages/1842544646/IDE+Only+display+delta+findings. So even if we don't add it to code-client-go, we will add it to snyk-ls. Of course, this means the dependency will still be added to the CLI but just an fyi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the code client need git access? Or could/should we pass in an interface here (similar to how we pass in config) and leave it to snyk-ls to implement with go-git?

Copy link
Contributor

@teodora-sandu teodora-sandu Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't but I think it would be better to centralise how we compute the git repo URL so it's not different across the two, which is why it makes sense to do that computation here. What's the reason for not including go-git? If it's a big concern then we could do what you suggested and not use go-git but I prefer letting a library deal with possible edge cases if I can 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Casey meant that we could define an interface based on go-git exported functions, that supports only the operations we need in code-client and that is automatically then implemented by go-git if a go-git type instance is passed in from snyk-ls. This would decouple the client a bit more, although I'm fine with using a 3rd-party library in this case. And using the dependency directly makes the code easier to maintain and navigate, as an indirection layer is removed.

Copy link
Contributor

@teodora-sandu teodora-sandu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@PeterSchafer PeterSchafer merged commit 7fcf00a into main Mar 27, 2024
@PeterSchafer PeterSchafer deleted the feat/CLI-195_repourl branch March 27, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants