KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGIT::PROJECT_GIT_UTILS Class Reference

Utility class with helper functions for project level git operations. More...

#include <project_git_utils.h>

Static Public Member Functions

static git_repository * GetRepositoryForFile (const char *aFilename)
 Discover and open the repository that contains the given file.
 
static int CreateBranch (git_repository *aRepo, const wxString &aBranchName)
 Create a new branch based on HEAD.
 
static bool RemoveVCS (git_repository *&aRepo, const wxString &aProjectPath=wxEmptyString, bool aRemoveGitDir=false, wxString *aErrors=nullptr)
 Remove version control from a directory by freeing the repository and optionally removing the .git directory.
 

Detailed Description

Utility class with helper functions for project level git operations.

Definition at line 34 of file project_git_utils.h.

Member Function Documentation

◆ CreateBranch()

int KIGIT::PROJECT_GIT_UTILS::CreateBranch ( git_repository *  aRepo,
const wxString &  aBranchName 
)
static

Create a new branch based on HEAD.

Parameters
aRepoRepository in which to create the branch.
aBranchNameName of the new branch.
Returns
0 on success, libgit2 error code on failure.

Definition at line 59 of file project_git_utils.cpp.

References KIGIT_COMMON::GetLastGitError(), and traceGit.

Referenced by PROJECT_TREE_PANE::onGitSwitchBranch().

◆ GetRepositoryForFile()

git_repository * KIGIT::PROJECT_GIT_UTILS::GetRepositoryForFile ( const char *  aFilename)
static

Discover and open the repository that contains the given file.

Parameters
aFilenameAbsolute path to a file inside the repository.
Returns
Newly opened git_repository or nullptr on failure.

Definition at line 35 of file project_git_utils.cpp.

References KIGIT_COMMON::GetLastGitError(), GIT_BUF_INIT, and traceGit.

Referenced by PROJECT_TREE_PANE::ReCreateTreePrj().

◆ RemoveVCS()

bool KIGIT::PROJECT_GIT_UTILS::RemoveVCS ( git_repository *&  aRepo,
const wxString &  aProjectPath = wxEmptyString,
bool  aRemoveGitDir = false,
wxString *  aErrors = nullptr 
)
static

Remove version control from a directory by freeing the repository and optionally removing the .git directory.

Parameters
aRepoRepository to free (will be set to nullptr)
aProjectPathPath to the project directory
aRemoveGitDirIf true, also remove the .git directory from disk
aErrorsOutput parameter for any error messages
Returns
True on success, false on failure

Definition at line 93 of file project_git_utils.cpp.

References RmDirRecursive(), and traceGit.

Referenced by PROJECT_TREE_PANE::EmptyTreePrj(), PROJECT_TREE_PANE::onGitRemoveVCS(), and PROJECT_TREE_PANE::ReCreateTreePrj().


The documentation for this class was generated from the following files: