src-d / go-git

Project has been moved to: https://github.com/go-git/go-git
https://github.com/go-git/go-git
Apache License 2.0
4.9k stars 540 forks source link

Hotfix/propose git check ref format #1173

Open thecjharries opened 5 years ago

thecjharries commented 5 years ago

This is in response to #1172.

I spent the better part of the last two days attempting to PR a fix in place. I don't know Go or the project well enough to accomplish that so I split out the work I did in the hopes that it might be useful. This can be run at the beginning or end of existing ReferenceName pipelines to ensure the names are up to snuff.

I read the contribution docs before sitting down to code but focused on signing off on my commits and missed the format. I've squashed everything to address that. There's not much lost; these two files were, by and large, copypasta.

mcuadros commented 5 years ago

@thecjharries wonderful contribution.

The validator is following strictly this rules: git-check-ref-format?

Can you move this to a package called plumbing/ref-validator or something similar? and place document the rules (mainly copy paste from the original git documentation) the rules?

And then make it available though a method Refname.Validate() error?

thecjharries commented 5 years ago

Absolutely! I really appreciate you taking the time to go through the code like that. That standard link will be very useful.

I want to make sure I set the package up correctly. plumbing/revlist looks like a good example. Should I mimic that?

It might be a few days before I have time to sit down and fully digest the docs to do this correctly. As I said, I really appreciate your feedback!

mcuadros commented 5 years ago

You can takea lookg to https://github.com/src-d/go-git/tree/master/plumbing/protocol/packp/sideband, but in general you can take a look to any package.