41#include <wx/filename.h>
42#include <wx/textfile.h>
57 writeFile( wxT(
"board.kicad_pcb" ), wxT(
"(kicad_pcb)\n" ) );
62 void writeFile(
const wxString& aFile,
const wxString& aContent )
73 std::map<wxString, FileStatus> status = handler.
GetFileStatus( wxEmptyString, aChangedOnly );
74 std::map<wxString, FileStatus> paths;
76 for(
const auto& [
path, fileStatus] : status )
77 paths.emplace(
path.StartsWith( workDir ) ?
path.Mid( workDir.length() ) :
path, fileStatus );
102 wxTextFile file(
ignoreFile().GetFullPath() );
107 for(
size_t ii = 0; ii < file.GetLineCount(); ++ii )
108 contents += file[ii] + wxT(
"\n" );
137 writeFile( wxT(
"out/top.gbr" ), wxT(
"gerber\n" ) );
141 BOOST_REQUIRE( changes( common ).count( wxT(
"out/top.gbr" ) ) == 1 );
148 BOOST_CHECK( changes( common ).count( wxT(
"out/top.gbr" ) ) == 0 );
151 const std::map<wxString, FileStatus> tree = treeStatus( common );
152 const auto entry = tree.find( wxT(
"out/top.gbr" ) );
163 writeFile( wxT(
"gerbers/top.gbr" ), wxT(
"gerber\n" ) );
164 writeFile( wxT(
"gerbers/bottom.gbr" ), wxT(
"gerber\n" ) );
168 BOOST_REQUIRE( changes( common ).count( wxT(
"gerbers/top.gbr" ) ) == 1 );
173 const std::map<wxString, FileStatus> changed = changes( common );
175 BOOST_CHECK( changed.count( wxT(
"gerbers/top.gbr" ) ) == 0 );
176 BOOST_CHECK( changed.count( wxT(
"gerbers/bottom.gbr" ) ) == 0 );
179 const std::map<wxString, FileStatus> tree = treeStatus( common );
180 const auto folder = tree.find( wxT(
"gerbers" ) );
185 BOOST_CHECK( tree.count( wxT(
"gerbers/top.gbr" ) ) == 0 );
191 writeFile( wxT(
"docs/notes.txt" ), wxT(
"notes\n" ) );
202 writeFile( wxT(
"out/top.gbr" ), wxT(
"gerber\n" ) );
210 writeFile( wxT(
".gitignore" ), wxT(
"# my own rules\n*.bak\n" ) );
216 KIGIT::AddIgnoreRules( ignoreFile(), { wxT(
"/out/top.gbr" ), wxT(
"*.bak" ) }, wxEmptyString, error ),
226 wxFFile out( ignoreFile().GetFullPath(), wxT(
"w" ) );
241 writeFile( wxT(
".gitignore" ), wxT(
"# my own rules\n*.gbr\n\n/out/top.gbr\n/gerbers/\n" ) );
267 return m_repoPath + wxFileName::GetPathSeparator() + wxT(
"proj" ) + wxFileName::GetPathSeparator();
277 writeFile( wxT(
"proj/out/top.gbr" ), wxT(
"gerber\n" ) );
278 writeFile( wxT(
"other/out/top.gbr" ), wxT(
"gerber\n" ) );
289 const std::map<wxString, FileStatus> changed = changes( common );
291 BOOST_CHECK( changed.count( wxT(
"proj/out/top.gbr" ) ) == 0 );
292 BOOST_CHECK( changed.count( wxT(
"other/out/top.gbr" ) ) == 1 );
std::map< wxString, FileStatus > GetFileStatus(const wxString &aPathspec=wxEmptyString, bool aChangedOnly=false)
Get detailed file status for all files in the specified path.
wxString GetWorkingDirectory()
Get the repository working directory path.
The project's git session.
Give each test a backend and a temporary directory.
const wxString & TempPath() const
std::unique_ptr< git_repository, decltype([](git_repository *aRepo) { git_repository_free(aRepo); })> GitRepositoryPtr
A unique pointer for git_repository objects with automatic cleanup.
APIEXPORT bool AddIgnoreRules(const wxFileName &aIgnoreFile, const std::vector< wxString > &aRules, const wxString &aHeader, wxString &aError)
Append rules to an ignore file, creating it with aHeader as a comment when it is not there.
APIEXPORT wxFileName ProjectIgnoreFile(const wxString &aProjectPath)
The ignore file that covers a project.
APIEXPORT bool RemoveIgnoreRules(const wxFileName &aIgnoreFile, const std::vector< wxString > &aRules, wxString &aError)
Remove rules from an ignore file.
APIEXPORT wxString ExtensionIgnoreRule(const wxString &aProjectRelPath)
The rule that ignores every file sharing a path's extension, or nothing when it has none.
APIEXPORT IGNORE_STATE IgnoreState(KIGIT_COMMON &aCommon, const wxString &aProjectRelPath, bool aIsDirectory)
What git's rules and its index say about a project path, so the user is offered only what would take ...
APIEXPORT wxString PathIgnoreRule(const wxString &aProjectRelPath, bool aIsDirectory)
The rule that ignores one path and nothing else.
KIGIT::GitRepositoryPtr InitGitRepository(const wxString &aPath, const char *aBranch="main", const char *aAuthorName="QA Test", const char *aAuthorEmail="
[email protected]")
Pin the branch and author so repository setup does not depend on the user's Git config.
void WriteGitFile(const wxString &aRepoPath, const wxString &aRelativePath, const std::string &aContents)
Write test data without staging it. Create parent directories when needed.
git_oid CommitAllGitFiles(git_repository *aRepo, const wxString &aMessage)
Stage all changes, including deletions, and commit them.
A repository holding one committed file, with the project at its root.
virtual wxString projectPath() const
The project directory, which is where its ignore file belongs.
std::map< wxString, FileStatus > changes(KIGIT_COMMON &aCommon)
What the commit list offers, which is changes only.
wxFileName ignoreFile() const
std::map< wxString, FileStatus > reported(KIGIT_COMMON &aCommon, bool aChangedOnly)
What the status reports, keyed by repository relative path.
std::map< wxString, FileStatus > treeStatus(KIGIT_COMMON &aCommon)
What the project tree is built from, ignored paths included.
virtual ~GIT_IGNORE_FIXTURE()=default
git_repository * repo() const
KIGIT::GitRepositoryPtr m_repo
void writeFile(const wxString &aFile, const wxString &aContent)
The project is a folder inside a larger repository, where rules have to be anchored to the project ra...
wxString projectPath() const override
The project directory, which is where its ignore file belongs.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE_MESSAGE(dc.CacheTableInfo(table, { "part_id", "val" }), dc.GetLastError())
BOOST_REQUIRE(res.columns()==1)
static const char * TEST_AUTHOR_NAME
static const char * TEST_AUTHOR_EMAIL
BOOST_AUTO_TEST_SUITE_END()
static const char * TEST_AUTHOR_NAME
static const char * TEST_AUTHOR_EMAIL
BOOST_AUTO_TEST_CASE(RuleNamesOnlyThePathPicked)