1
我想這樣工作就像「git describe」在終端工作。在libgit2中執行git描述
如何獲取我的回購的當前標籤?現在我的計劃是打印
09B8A518
每次我嘗試,這個數字是不同的,所以我不認爲這是提交ID左右。
當我執行「git的描述」在終端,輸出爲「v0.1.2」
有沒有辦法做到這一點?
順便說一句,我怎樣才能轉換「git_describe_result *出」;「字符串?
string path = C://my/local/repo;
string result;
git_libgit2_init();
const char * REPO_PATH = path.c_str();
git_repository * repo = nullptr;
git_repository_open(&repo, REPO_PATH);
git_describe_result *out;
git_describe_options opts = GIT_DESCRIBE_OPTIONS_INIT;
opts.version = GIT_DESCRIBE_FORMAT_OPTIONS_VERSION; // GIT_DESCRIBE_OPTIONS_VERSION;
git_describe_workdir(&out, repo, &opts);
cout << out << endl;
git_describe_result_free(out);
git_repository_free(repo);
git_libgit2_shutdown();
要打印的指針這對我的作品。這裏真正的問題是如何將'git_describe_result'格式化爲一個字符串。 –