How to verify valid format of URL as a git repo?
git
Solution
It does seem that there is no way to accomplish this with git. The solution I finally used is
git ls-remote the-url-to-test
This returns zero on success and non-zero otherwise. This doesn't satisfy my original question since I don't want to check if the repo exists and is valid... but it does satisfy that the URL is valid if the repo also exists.
This will have to do for my current script.
Problem
I do NOT want to check if the remote repository exists. I just want to test a string and return true if the string is in the valid format for a git repo. I'm writing a groovy script and wish to do a quick check if a string represents a valid possible git repo. For instance if the following strings are entered the test should return true: ``` http://example.com/my-project.git file:///absolute/path/to/my-project.git ssh:user@example.com:my-project my-project ``` The following strings should fail the test and cause false to be returned: ``` fil://example.com/my-project.git ssh:user|example.com:my-project ``` I'm hoping there is a git command that can do this quick test for me and I can call git from the groovy script. I say this because I'd like to use whatever is compiled into git to do the test as opposed to re-implementing the regular expression (or parser) that already exists in git. If I try the latter then inevitably I'll miss something.