Something went wrong. Try again.
Lightweight and easily self-hostable Git forge.
Something went wrong. Try again.
1234567891011121314151617181920212223242526package ssh
import ( "errors" "regexp")
type GitCommand struct { Command string Args string}
// git-upload-pack 'user_loves_bananas/website'var gitCommandRx = regexp.MustCompile(`^(git-upload-pack|git-receive-pack|git-upload-archive) '~([A-Za-z0-9_][A-Za-z0-9_.-]*/[A-Za-z0-9_][A-Za-z0-9_.-]*)'$`)
func parseGitCommand(raw string) (GitCommand, error) { matches := gitCommandRx.FindStringSubmatch(raw) if matches == nil { return GitCommand{}, errors.New("unrecognized command") } return GitCommand{ Command: matches[1], Args: matches[2], // guaranteed to be in "user/repo" form }, nil}