mirror of
https://git.proxmox.com/git/libgit2
synced 2026-01-04 21:04:07 +00:00
remote: get rid of git_remote_valid_url()
It does the same as git_remote_supported_url() but has a name which implies we'd check the URL for correctness while we're simply looking at the scheme and looking it up in our lists. While here, fix up the tests so we check all the combination of what's supported.
This commit is contained in:
parent
bd3854a09c
commit
ba67c07522
@ -384,15 +384,12 @@ GIT_EXTERN(int) git_remote_fetch(
|
||||
const char *reflog_message);
|
||||
|
||||
/**
|
||||
* Return whether a string is a valid remote URL
|
||||
*
|
||||
* @param url the url to check
|
||||
* @return 1 if the url is valid, 0 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_remote_valid_url(const char *url);
|
||||
|
||||
/**
|
||||
* Return whether the passed URL is supported by this version of the library.
|
||||
* Return whether the library supports a particular URL scheme
|
||||
*
|
||||
* Both the built-in and externally-registered transport lists are
|
||||
* searched for a transport which supports the scheme of the given
|
||||
* URL.
|
||||
*
|
||||
* @param url the url to check
|
||||
* @return 1 if the url is supported, 0 otherwise
|
||||
|
||||
@ -212,24 +212,13 @@ done:
|
||||
return error;
|
||||
}
|
||||
|
||||
/* from remote.h */
|
||||
int git_remote_valid_url(const char *url)
|
||||
{
|
||||
git_transport_cb fn;
|
||||
void *param;
|
||||
|
||||
return !transport_find_fn(&fn, url, ¶m);
|
||||
}
|
||||
|
||||
int git_remote_supported_url(const char* url)
|
||||
{
|
||||
git_transport_cb fn;
|
||||
void *param;
|
||||
|
||||
if (transport_find_fn(&fn, url, ¶m) < 0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
/* The only error we expect is ENOTFOUND */
|
||||
return !transport_find_fn(&fn, url, ¶m);
|
||||
}
|
||||
|
||||
int git_transport_init(git_transport *opts, unsigned int version)
|
||||
|
||||
@ -91,25 +91,30 @@ void test_network_remote_remotes__error_when_no_push_available(void)
|
||||
git_remote_free(r);
|
||||
}
|
||||
|
||||
void test_network_remote_remotes__parsing_ssh_remote(void)
|
||||
{
|
||||
cl_assert( git_remote_valid_url("git@github.com:libgit2/libgit2.git") );
|
||||
}
|
||||
|
||||
void test_network_remote_remotes__parsing_local_path_fails_if_path_not_found(void)
|
||||
{
|
||||
cl_assert( !git_remote_valid_url("/home/git/repos/libgit2.git") );
|
||||
}
|
||||
|
||||
void test_network_remote_remotes__supported_transport_methods_are_supported(void)
|
||||
{
|
||||
cl_assert( git_remote_supported_url("git://github.com/libgit2/libgit2") );
|
||||
cl_assert(git_remote_supported_url("git://github.com/libgit2/libgit2"));
|
||||
cl_assert(git_remote_supported_url("http://github.com/libgit2/libgit2"));
|
||||
|
||||
#ifdef GIT_SSH
|
||||
cl_assert(git_remote_supported_url("git@github.com:libgit2/libgit2.git"));
|
||||
cl_assert(git_remote_supported_url("ssh://git@github.com/libgit2/libgit2.git"));
|
||||
#endif
|
||||
|
||||
#if defined(GIT_SSL) || defined(GIT_WINHTTP)
|
||||
cl_assert(git_remote_supported_url("https://git@github.com/libgit2/libgit2.git"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_network_remote_remotes__unsupported_transport_methods_are_unsupported(void)
|
||||
{
|
||||
#ifndef GIT_SSH
|
||||
cl_assert( !git_remote_supported_url("git@github.com:libgit2/libgit2.git") );
|
||||
cl_assert(!git_remote_supported_url("git@github.com:libgit2/libgit2.git"));
|
||||
cl_assert(!git_remote_supported_url("ssh://git@github.com/libgit2/libgit2.git"));
|
||||
#endif
|
||||
|
||||
#if !defined(GIT_SSL) && !defined(GIT_WINHTTP)
|
||||
cl_assert(!git_remote_supported_url("https://git@github.com/libgit2/libgit2.git"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user