void test_network_remotes__save(void) { git_remote_free(_remote); /* Set up the remote and save it to config */ cl_git_pass(git_remote_new(&_remote, _repo, "upstream", "git://github.com/libgit2/libgit2", NULL)); cl_git_pass(git_remote_set_fetchspec(_remote, "refs/heads/*:refs/remotes/upstream/*")); cl_git_pass(git_remote_set_pushspec(_remote, "refs/heads/*:refs/heads/*")); cl_git_pass(git_remote_save(_remote)); git_remote_free(_remote); _remote = NULL; /* Load it from config and make sure everything matches */ cl_git_pass(git_remote_load(&_remote, _repo, "upstream")); _refspec = git_remote_fetchspec(_remote); cl_assert(_refspec != NULL); cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); cl_assert_equal_s(git_refspec_dst(_refspec), "refs/remotes/upstream/*"); _refspec = git_remote_pushspec(_remote); cl_assert(_refspec != NULL); cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); cl_assert_equal_s(git_refspec_dst(_refspec), "refs/heads/*"); }
void test_network_remotes__set_pushspec(void) { cl_git_pass(git_remote_set_pushspec(_remote, "refs/*:refs/*")); _refspec = git_remote_pushspec(_remote); cl_assert_equal_s(git_refspec_src(_refspec), "refs/*"); cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*"); }
void test_network_remotes__add(void) { git_remote_free(_remote); cl_git_pass(git_remote_add(&_remote, _repo, "addtest", "http://github.com/libgit2/libgit2")); git_remote_free(_remote); cl_git_pass(git_remote_load(&_remote, _repo, "addtest")); _refspec = git_remote_fetchspec(_remote); cl_assert(!strcmp(git_refspec_src(_refspec), "refs/heads/*")); cl_assert(!strcmp(git_refspec_dst(_refspec), "refs/remotes/addtest/*")); }
void test_clone_nonetwork__custom_push_spec(void) { const git_refspec *actual_fs; const char *spec = "+refs/heads/master:refs/heads/foo"; g_options.push_spec = spec; cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options)); cl_git_pass(git_remote_load(&g_remote, g_repo, "origin")); actual_fs = git_remote_pushspec(g_remote); cl_assert_equal_s("refs/heads/master", git_refspec_src(actual_fs)); cl_assert_equal_s("refs/heads/foo", git_refspec_dst(actual_fs)); }
PyObject * Remote_fetchspec__get__(Remote *self) { PyObject* py_tuple = NULL; const git_refspec * refspec; refspec = git_remote_fetchspec(self->remote); if (refspec != NULL) { py_tuple = Py_BuildValue( "(ss)", git_refspec_src(refspec), git_refspec_dst(refspec) ); return py_tuple; } return Error_set(GIT_ENOTFOUND); }
/* * $ git remote add addtest http://github.com/libgit2/libgit2 * * $ cat .git/config * [...] * [remote "addtest"] * url = http://github.com/libgit2/libgit2 * fetch = +refs/heads/\*:refs/remotes/addtest/\* */ void test_network_remote_remotes__add(void) { git_remote_free(_remote); _remote = NULL; cl_git_pass(git_remote_create(&_remote, _repo, "addtest", "http://github.com/libgit2/libgit2")); cl_assert_equal_i(GIT_REMOTE_DOWNLOAD_TAGS_AUTO, git_remote_autotag(_remote)); git_remote_free(_remote); _remote = NULL; cl_git_pass(git_remote_lookup(&_remote, _repo, "addtest")); cl_assert_equal_i(GIT_REMOTE_DOWNLOAD_TAGS_AUTO, git_remote_autotag(_remote)); _refspec = git_vector_get(&_remote->refspecs, 0); cl_assert_equal_s("refs/heads/*", git_refspec_src(_refspec)); cl_assert(git_refspec_force(_refspec) == 1); cl_assert_equal_s("refs/remotes/addtest/*", git_refspec_dst(_refspec)); cl_assert_equal_s(git_remote_url(_remote), "http://github.com/libgit2/libgit2"); }
void test_network_remote_remotes__add_pushspec(void) { size_t size; size = git_remote_refspec_count(_remote); cl_git_pass(git_remote_add_push(_repo, "test", "refs/*:refs/*")); size++; git_remote_free(_remote); cl_git_pass(git_remote_lookup(&_remote, _repo, "test")); cl_assert_equal_i((int)size, (int)git_remote_refspec_count(_remote)); _refspec = git_remote_get_refspec(_remote, size - 1); cl_assert_equal_s(git_refspec_src(_refspec), "refs/*"); cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*"); cl_assert_equal_s(git_refspec_string(_refspec), "refs/*:refs/*"); cl_assert_equal_b(_refspec->push, true); }
void test_network_remote_remotes__add_fetchspec(void) { size_t size; size = git_remote_refspec_count(_remote); cl_git_pass(git_remote_add_fetch(_repo, "test", "refs/*:refs/*")); size++; git_remote_free(_remote); cl_git_pass(git_remote_lookup(&_remote, _repo, "test")); cl_assert_equal_i((int)size, (int)git_remote_refspec_count(_remote)); _refspec = git_remote_get_refspec(_remote, size - 1); cl_assert_equal_s(git_refspec_src(_refspec), "refs/*"); cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*"); cl_assert_equal_s(git_refspec_string(_refspec), "refs/*:refs/*"); cl_assert_equal_b(_refspec->push, false); cl_git_fail_with(GIT_EINVALIDSPEC, git_remote_add_fetch(_repo, "test", "refs/*/foo/*:refs/*")); }
void test_network_remotes__refspec_parsing(void) { cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); cl_assert_equal_s(git_refspec_dst(_refspec), "refs/remotes/test/*"); }
PyObject * Refspec_src__get__(Refspec *self) { return to_unicode(git_refspec_src(self->refspec), NULL, NULL); }
void test_network_remotes__refspec_parsing(void) { cl_assert(!strcmp(git_refspec_src(refspec), "refs/heads/*")); cl_assert(!strcmp(git_refspec_dst(refspec), "refs/remotes/test/*")); }
git_config_free(cfg); git_repository_free(repo); END_TEST BEGIN_TEST(refspec0, "remote with refspec works") git_remote *remote; git_repository *repo; git_config *cfg; const git_refspec *refspec = NULL; must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_config(&cfg, repo, NULL, NULL)); must_pass(git_remote_get(&remote, cfg, "test")); refspec = git_remote_fetchspec(remote); must_be_true(refspec != NULL); must_be_true(!strcmp(git_refspec_src(refspec), "refs/heads/*")); must_be_true(!strcmp(git_refspec_dst(refspec), "refs/remotes/test/*")); git_remote_free(remote); git_config_free(cfg); git_repository_free(repo); END_TEST BEGIN_TEST(refspec1, "remote fnmatch works as expected") git_remote *remote; git_repository *repo; git_config *cfg; const git_refspec *refspec = NULL; must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_config(&cfg, repo, NULL, NULL)); must_pass(git_remote_get(&remote, cfg, "test"));