Esempio n. 1
0
void test_notes_notes__can_iterate_custom_namespace(void)
{
	git_note_iterator *iter;
	git_note *note;
	git_oid note_id, annotated_id;
	git_oid note_created[2];
	const char* note_message[] = {
		"I decorate a65f\n",
		"I decorate c478\n"
	};
	int i, err;

	create_note(&note_created[0], "refs/notes/beer",
		"a65fedf39aefe402d3bb6e24df4d4f5fe4547750", note_message[0]);
	create_note(&note_created[1], "refs/notes/beer",
		"c47800c7266a2be04c571c04d5a6614691ea99bd", note_message[1]);

	cl_git_pass(git_note_iterator_new(&iter, _repo, "refs/notes/beer"));

	for (i = 0; (err = git_note_next(&note_id, &annotated_id, iter)) >= 0; ++i) {
		cl_git_pass(git_note_read(&note, _repo, "refs/notes/beer", &annotated_id));
		cl_assert_equal_s(git_note_message(note), note_message[i]);
		git_note_free(note);
	}

	cl_assert_equal_i(GIT_ITEROVER, err);
	cl_assert_equal_i(2, i);
	git_note_iterator_free(iter);
}
Esempio n. 2
0
File: notes.c Progetto: 0CV0/libgit2
int git_note_foreach(
	git_repository *repo,
	const char *notes_ref,
	git_note_foreach_cb note_cb,
	void *payload)
{
	int error;
	git_note_iterator *iter = NULL;
	git_oid note_id, annotated_id;

	if ((error = git_note_iterator_new(&iter, repo, notes_ref)) < 0)
		return error;

	while (!(error = git_note_next(&note_id, &annotated_id, iter))) {
		if (note_cb(&note_id, &annotated_id, payload)) {
			error = GIT_EUSER;
			break;
		}
	}

	if (error == GIT_ITEROVER)
		error = 0;

	git_note_iterator_free(iter);
	return error;
}
Esempio n. 3
0
PyObject *
NoteIter_iternext(NoteIter *self)
{
    int err;
    git_oid note_id, annotated_id;

    err = git_note_next(&note_id, &annotated_id, self->iter);
    if (err < 0)
        return Error_set(err);

    return (PyObject*) wrap_note(self->repo, &annotated_id, self->ref);
}
Esempio n. 4
0
void test_notes_notes__iterate_from_commit(void)
{
	git_note_iterator *iter;
	git_note *note;
	git_oid note_id, annotated_id;
	git_oid oids[2];
	git_oid notes_commit_oids[2];
	git_commit *notes_commits[2];
	const char* note_message[] = {
		"I decorate a65f\n",
		"I decorate c478\n"
	};
	int i, err;

	cl_git_pass(git_oid_fromstr(&(oids[0]), "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"));
	cl_git_pass(git_oid_fromstr(&(oids[1]), "c47800c7266a2be04c571c04d5a6614691ea99bd"));

	cl_git_pass(git_note_commit_create(&notes_commit_oids[0], NULL, _repo, NULL, _sig, _sig, &(oids[0]), note_message[0], 0));

	git_commit_lookup(&notes_commits[0], _repo, &notes_commit_oids[0]);
	cl_assert(notes_commits[0]);

	cl_git_pass(git_note_commit_create(&notes_commit_oids[1], NULL, _repo, notes_commits[0], _sig, _sig, &(oids[1]), note_message[1], 0));

	git_commit_lookup(&notes_commits[1], _repo, &notes_commit_oids[1]);
	cl_assert(notes_commits[1]);

	cl_git_pass(git_note_commit_iterator_new(&iter, notes_commits[1]));

	for (i = 0; (err = git_note_next(&note_id, &annotated_id, iter)) >= 0; ++i) {
		cl_git_pass(git_note_commit_read(&note, _repo, notes_commits[1], &annotated_id));
		cl_assert_equal_s(git_note_message(note), note_message[i]);
		git_note_free(note);
	}

	cl_assert_equal_i(GIT_ITEROVER, err);
	cl_assert_equal_i(2, i);

	git_note_iterator_free(iter);
	git_commit_free(notes_commits[0]);
	git_commit_free(notes_commits[1]);
}