Files
hrynco-kswitcher/src/files_git_changes.h
T

72 lines
2.0 KiB
C++

#pragma once
#include <filesystem>
#include <stop_token>
#include <string>
#include <vector>
namespace ks::files
{
enum class GitChangeKind { staged, unstaged, untracked };
struct GitChange
{
GitChangeKind kind;
std::wstring path;
std::wstring oldPath;
std::wstring flags;
bool operator==(const GitChange &) const = default;
};
struct GitCheckout
{
std::wstring ref, revision;
bool operator==(const GitCheckout &) const = default;
};
struct GitChanges
{
std::filesystem::path executable, root;
std::vector<GitChange> entries;
GitCheckout checkout;
};
struct GitBranch
{
std::wstring ref, label, revision;
bool current{};
};
struct GitCommit
{
std::wstring revision, abbreviated, date, subject;
};
struct GitHistoryPage
{
std::vector<GitCommit> commits;
bool more{};
};
struct GitCommitReview
{
std::filesystem::path root;
GitCheckout checkout;
std::vector<GitChange> staged;
std::string stagedIdentity;
};
GitChanges readGitChanges(const std::filesystem::path &directory,std::stop_token stop);
std::string readGitPatch(const std::filesystem::path &git,const std::filesystem::path &root,
const GitChange &change,std::stop_token stop);
std::vector<GitBranch> readGitBranches(const std::filesystem::path &git,const std::filesystem::path &root,
std::stop_token stop);
GitHistoryPage readGitHistory(const std::filesystem::path &git,const std::filesystem::path &root,
const std::wstring &revision,size_t offset,std::stop_token stop);
std::string readGitCommit(const std::filesystem::path &git,const std::filesystem::path &root,
const std::wstring &revision,std::stop_token stop);
void changeGitIndex(const GitChanges &worktree,const GitChange &entry,bool replaceStaged,std::stop_token stop);
GitCommitReview reviewGitCommit(const GitChanges &worktree,std::stop_token stop);
std::wstring createGitCommit(const GitChanges &worktree,const GitCommitReview &review,
const std::wstring &message,std::stop_token stop);
}