#include "gitrepository.h" #include #include #include #include #include #include GitRepository::GitRepository(const QString& root) : QObject(nullptr) { if(git_repository_open(&m_raw, root.toUtf8().data()) != 0) { qDebug() << "Cannot open repository"; close(); return; } m_root = root; m_path = git_repository_workdir(m_raw); m_name = m_path;//TODO: replace with Human readable name qDebug() << "New repo:" << m_name << m_root << m_path; readBranches(); } GitRepository::~GitRepository() { close(); } void GitRepository::close() { if(m_raw) { git_repository_free(m_raw); } m_raw = nullptr; } void GitRepository::readBranches() { git_reference *branchRef; git_branch_t branchType; git_branch_iterator* iter; git_branch_iterator_new(&iter, m_raw, GIT_BRANCH_ALL); while(git_branch_next(&branchRef, &branchType, iter) == 0) { GitBranch* branch = new GitBranch(branchRef, branchType, this); m_branches.insert(branch->name(), QPointer(branch)); qDebug() << branch->name(); qDebug() << branch->type(); } }