Hash :
fd8126e4
Author :
Date :
2014-09-30T08:54:52
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#include "describe_helpers.h"
void assert_describe(
const char *expected_output,
const char *revparse_spec,
git_repository *repo,
git_describe_opts *opts,
git_describe_format_options *fmt_opts,
bool is_prefix_match)
{
git_object *object;
git_buf label = GIT_BUF_INIT;
git_describe_result *result;
cl_git_pass(git_revparse_single(&object, repo, revparse_spec));
cl_git_pass(git_describe_commit(&result, object, opts));
cl_git_pass(git_describe_format(&label, result, fmt_opts));
if (is_prefix_match)
cl_assert_equal_i(0, git__prefixcmp(git_buf_cstr(&label), expected_output));
else
cl_assert_equal_s(expected_output, label);
git_describe_result_free(result);
git_object_free(object);
git_buf_free(&label);
}
void assert_describe_workdir(
const char *expected_output,
const char *expected_suffix,
git_repository *repo,
git_describe_opts *opts,
git_describe_format_options *fmt_opts,
bool is_prefix_match)
{
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));
if (is_prefix_match)
cl_assert_equal_i(0, git__prefixcmp(git_buf_cstr(&label), expected_output));
else
cl_assert_equal_s(expected_output, label);
if (expected_suffix)
cl_assert_equal_i(0, git__suffixcmp(git_buf_cstr(&label), expected_suffix));
git_describe_result_free(result);
git_buf_free(&label);
}