describe_helpers.c 1.07 KB
Newer Older
1 2 3 4 5 6
#include "describe_helpers.h"

void assert_describe(
	const char *expected_output,
	const char *revparse_spec,
	git_repository *repo,
7
	git_describe_options *opts,
8
	git_describe_format_options *fmt_opts)
9 10
{
	git_object *object;
11 12
	git_buf label = GIT_BUF_INIT;
	git_describe_result *result;
13 14 15

	cl_git_pass(git_revparse_single(&object, repo, revparse_spec));

16 17
	cl_git_pass(git_describe_commit(&result, object, opts));
	cl_git_pass(git_describe_format(&label, result, fmt_opts));
18

19
	cl_must_pass(p_fnmatch(expected_output, git_buf_cstr(&label), 0));
20

21
	git_describe_result_free(result);
22 23 24
	git_object_free(object);
	git_buf_free(&label);
}
25 26 27 28

void assert_describe_workdir(
	const char *expected_output,
	git_repository *repo,
29
	git_describe_options *opts,
30
	git_describe_format_options *fmt_opts)
31 32 33 34 35 36 37
{
	git_buf label = GIT_BUF_INIT;
	git_describe_result *result;

	cl_git_pass(git_describe_workdir(&result, repo, opts));
	cl_git_pass(git_describe_format(&label, result, fmt_opts));

38
	cl_must_pass(p_fnmatch(expected_output, git_buf_cstr(&label), 0));
39 40 41 42

	git_describe_result_free(result);
	git_buf_free(&label);
}