示例#1
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__fetch_default_reflog_message(void)
{
    char *refspec_strings[] = {
        "master:remotes/sloppy/master",
    };
    git_strarray array = {
        refspec_strings,
        1,
    };

    git_reflog *log;
    const git_reflog_entry *entry;
    char expected_reflog_msg[1024];

    connect_to_local_repository(cl_fixture("testrepo.git"));

    cl_git_pass(git_remote_fetch(remote, &array, NULL, NULL));

    cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
    cl_assert_equal_i(1, git_reflog_entrycount(log));
    entry = git_reflog_entry_byindex(log, 0);
    cl_assert_equal_s("*****@*****.**", git_reflog_entry_committer(entry)->email);

    sprintf(expected_reflog_msg, "fetch %s", git_remote_url(remote));
    cl_assert_equal_s(expected_reflog_msg, git_reflog_entry_message(entry));

    git_reflog_free(log);
}
示例#2
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__push_to_non_bare_remote(void)
{
    char *refspec_strings[] = {
        "master:master",
    };
    git_strarray array = {
        refspec_strings,
        1,
    };
    /* Shouldn't be able to push to a non-bare remote */
    git_remote *localremote;
    git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;

    /* Get some commits */
    connect_to_local_repository(cl_fixture("testrepo.git"));
    cl_git_pass(git_remote_fetch(remote, &array, &fetch_opts, NULL));

    /* Set up an empty non-bare repo to push into */
    {
        git_repository *remoterepo = NULL;
        cl_git_pass(git_repository_init(&remoterepo, "localnonbare", 0));
        git_repository_free(remoterepo);
    }

    /* Connect to the bare repo */
    cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare"));
    cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL, NULL));

    /* Try to push */
    cl_git_fail_with(GIT_EBAREREPO, git_remote_upload(localremote, &push_array, NULL));

    /* Clean up */
    git_remote_free(localremote);
    cl_fixture_cleanup("localbare.git");
}
示例#3
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__fetch(void)
{
    char *refspec_strings[] = {
        "master:remotes/sloppy/master",
    };
    git_strarray array = {
        refspec_strings,
        1,
    };

    git_reflog *log;
    const git_reflog_entry *entry;
    git_reference *ref;

    connect_to_local_repository(cl_fixture("testrepo.git"));

    cl_git_pass(git_remote_fetch(remote, &array, NULL, "UPDAAAAAATE!!"));

    cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master"));
    git_reference_free(ref);

    cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
    cl_assert_equal_i(1, git_reflog_entrycount(log));
    entry = git_reflog_entry_byindex(log, 0);
    cl_assert_equal_s("*****@*****.**", git_reflog_entry_committer(entry)->email);
    cl_assert_equal_s("UPDAAAAAATE!!", git_reflog_entry_message(entry));

    git_reflog_free(log);
}
示例#4
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__push_to_bare_remote(void)
{
    char *refspec_strings[] = {
        "master:master",
    };
    git_strarray array = {
        refspec_strings,
        1,
    };

    /* Should be able to push to a bare remote */
    git_remote *localremote;

    /* Get some commits */
    connect_to_local_repository(cl_fixture("testrepo.git"));
    cl_git_pass(git_remote_fetch(remote, &array, NULL, NULL));

    /* Set up an empty bare repo to push into */
    {
        git_repository *localbarerepo;
        cl_git_pass(git_repository_init(&localbarerepo, "./localbare.git", 1));
        git_repository_free(localbarerepo);
    }

    /* Connect to the bare repo */
    cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git"));
    cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL, NULL));

    /* Try to push */
    cl_git_pass(git_remote_upload(localremote, &push_array, NULL));

    /* Clean up */
    git_remote_free(localremote);
    cl_fixture_cleanup("localbare.git");
}
示例#5
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__connected(void)
{
    connect_to_local_repository(cl_fixture("testrepo.git"));
    cl_assert(git_remote_connected(remote));

    git_remote_disconnect(remote);
    cl_assert(!git_remote_connected(remote));
}
示例#6
0
void test_network_remotelocal__retrieve_advertised_references(void)
{
	int how_many_refs = 0;

	connect_to_local_repository(cl_fixture("testrepo.git"));

	cl_git_pass(git_remote_ls(remote, &count_ref__cb, &how_many_refs));

	cl_assert_equal_i(how_many_refs, 26);
}
示例#7
0
void test_network_remotelocal__retrieve_advertised_references(void)
{
	int how_many_refs = 0;

	connect_to_local_repository(cl_fixture("testrepo.git"));

	cl_git_pass(git_remote_ls(remote, &count_ref__cb, &how_many_refs));

	cl_assert(how_many_refs == 14); /* 1 HEAD + 6 heads + 1 lightweight tag + 3 annotated tags + 3 peeled target */
}
示例#8
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__retrieve_advertised_references(void)
{
    const git_remote_head **refs;
    size_t refs_len;

    connect_to_local_repository(cl_fixture("testrepo.git"));

    cl_git_pass(git_remote_ls(&refs, &refs_len, remote));

    cl_assert_equal_i(refs_len, 28);
}
示例#9
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__nested_tags_are_completely_peeled(void)
{
    const git_remote_head **refs;
    size_t refs_len, i;

    connect_to_local_repository(cl_fixture("testrepo.git"));

    cl_git_pass(git_remote_ls(&refs, &refs_len, remote));

    for (i = 0; i < refs_len; i++) {
        if (!strcmp(refs[i]->name, "refs/tags/test^{}"))
            cl_git_pass(git_oid_streq(&refs[i]->oid, "e90810b8df3e80c413d903f631643c716887138d"));
    }
}
示例#10
0
void test_network_remotelocal__retrieve_advertised_references_from_spaced_repository(void)
{
	int how_many_refs = 0;

	cl_fixture_sandbox("testrepo.git");
	cl_git_pass(p_rename("testrepo.git", "spaced testrepo.git"));

	connect_to_local_repository("spaced testrepo.git");

	cl_git_pass(git_remote_ls(remote, &count_ref__cb, &how_many_refs));

	cl_assert_equal_i(how_many_refs, 26);

	git_remote_free(remote);	/* Disconnect from the "spaced repo" before the cleanup */
	remote = NULL;

	cl_fixture_cleanup("spaced testrepo.git");
}
示例#11
0
void test_network_remotelocal__retrieve_advertised_references_from_spaced_repository(void)
{
	int how_many_refs = 0;

	cl_fixture_sandbox("testrepo.git");
	cl_git_pass(p_rename("testrepo.git", "spaced testrepo.git"));

	connect_to_local_repository("spaced testrepo.git");

	cl_git_pass(git_remote_ls(remote, &count_ref__cb, &how_many_refs));

	cl_assert(how_many_refs == 14); /* 1 HEAD + 6 heads + 1 lightweight tag + 3 annotated tags + 3 peeled target */

	git_remote_free(remote);	/* Disconnect from the "spaced repo" before the cleanup */
	remote = NULL;

	cl_fixture_cleanup("spaced testrepo.git");
}
示例#12
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__retrieve_advertised_references_from_spaced_repository(void)
{
    const git_remote_head **refs;
    size_t refs_len;

    cl_fixture_sandbox("testrepo.git");
    cl_git_pass(p_rename("testrepo.git", "spaced testrepo.git"));

    connect_to_local_repository("spaced testrepo.git");

    cl_git_pass(git_remote_ls(&refs, &refs_len, remote));

    cl_assert_equal_i(refs_len, 28);

    git_remote_free(remote);	/* Disconnect from the "spaced repo" before the cleanup */
    remote = NULL;

    cl_fixture_cleanup("spaced testrepo.git");
}
示例#13
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__shorthand_fetch_refspec1(void)
{
    char *refspec_strings[] = {
        "master",
        "hard_tag",
    };
    git_strarray array = {
        refspec_strings,
        2,
    };

    git_reference *ref;

    connect_to_local_repository(cl_fixture("testrepo.git"));

    cl_git_pass(git_remote_fetch(remote, &array, NULL, NULL));

    cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/origin/master"));
    cl_git_fail(git_reference_lookup(&ref, repo, "refs/tags/hard_tag"));
}
示例#14
0
文件: local.c 项目: rlugojr/libgit2
void test_network_remote_local__shorthand_fetch_refspec0(void)
{
    char *refspec_strings[] = {
        "master:remotes/sloppy/master",
        "master:boh/sloppy/master",
    };
    git_strarray array = {
        refspec_strings,
        2,
    };

    git_reference *ref;

    connect_to_local_repository(cl_fixture("testrepo.git"));

    cl_git_pass(git_remote_fetch(remote, &array, NULL, NULL));

    cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master"));
    git_reference_free(ref);

    cl_git_pass(git_reference_lookup(&ref, repo, "refs/heads/boh/sloppy/master"));
    git_reference_free(ref);
}
示例#15
0
void test_network_remotelocal__nested_tags_are_completely_peeled(void)
{
	connect_to_local_repository(cl_fixture("testrepo.git"));

	cl_git_pass(git_remote_ls(remote, &ensure_peeled__cb, NULL));
}