KiCad PCB EDA Suite
Loading...
Searching...
No Matches
text_eval_vcs.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <kicommon.h>
24#include <wx/string.h>
25#include <string>
26#include <cstdint>
27
36namespace TEXT_EVAL_VCS
37{
42KICOMMON_API TEXT_EVAL::ENVIRONMENT::VCS_VALUE ReadSource( const TEXT_EVAL::ENVIRONMENT::VCS_KEY& aKey );
43
51std::string GetCommitHash( const std::string& aPath = ".", int aLength = 40 );
52
60std::string GetNearestTag( const std::string& aMatch = "", bool aAnyTags = false );
61
69int GetDistanceFromTag( const std::string& aMatch = "", bool aAnyTags = false );
70
77bool IsDirty( bool aIncludeUntracked = false );
78
85std::string GetAuthor( const std::string& aPath = "." );
86
93std::string GetAuthorEmail( const std::string& aPath = "." );
94
101std::string GetCommitter( const std::string& aPath = "." );
102
109std::string GetCommitterEmail( const std::string& aPath = "." );
110
116std::string GetBranch();
117
124int64_t GetCommitTimestamp( const std::string& aPath = "." );
125
132std::string GetCommitDate( const std::string& aPath = "." );
133
149KICOMMON_API void SetContextPath( const wxString& aPath );
150
157
160
166{
167public:
168 explicit CONTEXT_PATH_SCOPE( const wxString& aPath );
170
173
174private:
175 wxString m_previous;
177};
178
179} // namespace TEXT_EVAL_VCS
wxString GetCommitHash()
Get the commit hash as a string.
std::tuple< VCS_QUERY, wxString, std::string, int, bool > VCS_KEY
Query, absolute path (Git directory for HEAD), selector or pattern, options, and whether the context ...
CONTEXT_PATH_SCOPE(const CONTEXT_PATH_SCOPE &)=delete
CONTEXT_PATH_SCOPE(const wxString &aPath)
CONTEXT_PATH_SCOPE & operator=(const CONTEXT_PATH_SCOPE &)=delete
#define KICOMMON_API
Definition kicommon.h:27
VCS (Version Control System) utility functions for text evaluation.
std::string GetAuthor(const std::string &aPath)
Get the author name of the HEAD commit.
bool IsDirty(bool aIncludeUntracked)
Check if the repository has uncommitted changes.
wxString GetContextPath()
Return the current context path for repo-scoped VCS queries.
bool GetContextIsFile()
File/directory classification captured when the current context was activated.
TEXT_EVAL::ENVIRONMENT::VCS_VALUE ReadSource(const TEXT_EVAL::ENVIRONMENT::VCS_KEY &aKey)
Re-read an owned query descriptor using any active frame memo.
std::string GetCommitterEmail(const std::string &aPath)
Get the committer email of the HEAD commit.
std::string GetCommitDate(const std::string &aPath)
Get the commit date of the HEAD commit as a timestamp string.
std::string GetAuthorEmail(const std::string &aPath)
Get the author email of the HEAD commit.
void SetContextPath(const wxString &aPath)
Set the filesystem path used for repository discovery and relative file queries.
std::string GetCommitter(const std::string &aPath)
Get the committer name of the HEAD commit.
std::string GetBranch()
Get the current branch name.
std::string GetNearestTag(const std::string &aMatch, bool aAnyTags)
Get the nearest tag/label from HEAD.
int64_t GetCommitTimestamp(const std::string &aPath)
Get the commit timestamp (Unix time) of the HEAD commit.
int GetDistanceFromTag(const std::string &aMatch, bool aAnyTags)
Get the number of commits since the nearest matching tag.